From af80b5ddd01038e617977ade6d8ead801ff55889 Mon Sep 17 00:00:00 2001 From: Mike Marchetti Date: Thu, 15 Jun 2017 13:32:23 -0400 Subject: [PATCH] retrieve key/val method from pkg Signed-off-by: Mike Marchetti --- osmclient/v1/package.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osmclient/v1/package.py b/osmclient/v1/package.py index 48e69ff..b383003 100644 --- a/osmclient/v1/package.py +++ b/osmclient/v1/package.py @@ -54,7 +54,7 @@ class Package(object): # method opens up a package and finds the name of the resulting # descriptor (vnfd or nsd name) - def get_descriptor_type_from_pkg(self, descriptor_file): + def get_key_val_from_pkg(self, descriptor_file): tar = tarfile.open(descriptor_file) yamlfile = None for member in tar.getmembers(): @@ -81,17 +81,18 @@ class Package(object): for entry in v2: for k3, v3 in entry.items(): - if k3 == 'name' or k3.endswith(':name'): - result['name'] = v3 - return result + # strip off preceeding chars before : + key_name = k3.split(':').pop() + + result[key_name] = v3 tar.close() - return None + return result def wait_for_upload(self, filename): """wait(block) for an upload to succeed. The filename passed is assumed to be a descriptor tarball. """ - pkg_type = self.get_descriptor_type_from_pkg(filename) + pkg_type = self.get_key_val_from_pkg(filename) if pkg_type is None: raise ClientException("Cannot determine package type") -- 2.25.1