X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcommon%2Futils.py;h=94bd72f9c762c84cca5de6d24cb404301a715b66;hb=85fe6ebf08098c66cfb3b140fc994835f70d9efc;hp=937e12175ee2942169a26dfadf695cdd6f53659a;hpb=d6eb17bc67230c86a053a71ccc7bb44a567618fc;p=osm%2Fosmclient.git diff --git a/osmclient/common/utils.py b/osmclient/common/utils.py index 937e121..94bd72f 100644 --- a/osmclient/common/utils.py +++ b/osmclient/common/utils.py @@ -66,25 +66,29 @@ def get_key_val_from_pkg(descriptor_file): 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()): - if not k2.endswith('nsd') and not k2.endswith('vnfd'): + for k in dict: + if 'nsd' in k: + result['type'] = 'nsd' + else: + result['type'] = 'vnfd' + if 'type' not in result: + for k1, v1 in list(dict.items()): + if not k1.endswith('-catalog'): continue + for k2, v2 in v1.items(): + if not k2.endswith('nsd') and not k2.endswith('vnfd'): + continue + if 'nsd' in k2: + result['type'] = 'nsd' + else: + result['type'] = 'vnfd' + for entry in v2: + for k3, v3 in list(entry.items()): + # strip off preceeding chars before : + key_name = k3.split(':').pop() + result[key_name] = v3 - if 'nsd' in k2: - result['type'] = 'nsd' - else: - result['type'] = 'vnfd' - - for entry in v2: - for k3, v3 in list(entry.items()): - # strip off preceeding chars before : - key_name = k3.split(':').pop() - - result[key_name] = v3 tar.close() return result