X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcommon%2Futils.py;h=ec0e0b0633d2feb2f82fd39236b1c22810844f25;hb=refs%2Fchanges%2F68%2F9568%2F1;hp=8ef325fbf570f7f663ba9bc93092193ea70d57a0;hpb=be96096ebd71c8d36c8375387f8e671f12eedfb0;p=osm%2Fosmclient.git diff --git a/osmclient/common/utils.py b/osmclient/common/utils.py index 8ef325f..ec0e0b0 100644 --- a/osmclient/common/utils.py +++ b/osmclient/common/utils.py @@ -21,6 +21,7 @@ import tarfile import re import yaml + def wait_for_value(func, result=True, wait_time=10, catch_exception=None): maxtime = time.time() + wait_time while time.time() < maxtime: @@ -29,7 +30,7 @@ def wait_for_value(func, result=True, wait_time=10, catch_exception=None): return True except catch_exception: pass - time.sleep(1) + time.sleep(5) try: return func() == result except catch_exception: @@ -53,24 +54,24 @@ def md5(fname): def get_key_val_from_pkg(descriptor_file): -# method opens up a package and finds the name of the resulting -# descriptor (vnfd or nsd name) + # method opens up a package and finds the name of the resulting + # descriptor (vnfd or nsd name) tar = tarfile.open(descriptor_file) yamlfile = None for member in tar.getmembers(): if (re.match('.*.yaml', member.name) and - len(member.name.split('/')) == 2): + len(member.name.split('/')) == 2): yamlfile = member.name break if yamlfile is None: return None - dict = yaml.load(tar.extractfile(yamlfile)) + dict = yaml.safe_load(tar.extractfile(yamlfile)) result = {} for k1, v1 in list(dict.items()): if not k1.endswith('-catalog'): continue - for k2, v2 in list(v1.items()): + for k2, v2 in v1.items(): if not k2.endswith('nsd') and not k2.endswith('vnfd'): continue @@ -87,4 +88,3 @@ def get_key_val_from_pkg(descriptor_file): result[key_name] = v3 tar.close() return result -