From: kate Date: Tue, 24 Jan 2017 03:57:06 +0000 (-0800) Subject: Changes in vimconn_vmware.py: provided implementation for get_image_list specification X-Git-Tag: v1.1.0~19 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F1001%2F1;p=osm%2FRO.git Changes in vimconn_vmware.py: provided implementation for get_image_list specification Change-Id: Ia9ce852a1670bcdd6cbc67c4b941f2e1358dccfe Signed-off-by: kate --- diff --git a/vimconn_vmware.py b/vimconn_vmware.py index 19382d67..bd427a98 100644 --- a/vimconn_vmware.py +++ b/vimconn_vmware.py @@ -1072,6 +1072,42 @@ class vimconnector(vimconn.vimconnector): return self.get_catalogid(catalog_md5_name, vca.get_catalogs()) + def get_image_list(self, filter_dict={}): + '''Obtain tenant images from VIM + Filter_dict can be: + name: image name + id: image uuid + checksum: image checksum + location: image path + Returns the image list of dictionaries: + [{}, ...] + List can be empty + ''' + vca = self.connect() + if not vca: + raise vimconn.vimconnConnectionException("self.connect() is failed.") + try: + image_list = [] + catalogs = vca.get_catalogs() + if len(catalogs) == 0: + return image_list + else: + for catalog in catalogs: + catalog_uuid = catalog.get_id().split(":")[3] + name = catalog.name + filtered_dict = {} + + if ("name" not in filter_dict and "id" not in filter_dict) or \ + (filter_dict.get('id') == catalog_uuid or filter_dict.get('name') == name): + filtered_dict ["name"] = name + filtered_dict ["id"] = catalog_uuid + image_list.append(filtered_dict) + + self.logger.debug("List of already created catalog items: {}".format(image_list)) + return image_list + except Exception as exp: + self.logger.error("Exception occured while retriving catalog items {}".format(exp)) + def get_vappid(self, vdc=None, vapp_name=None): """ Method takes vdc object and vApp name and returns vapp uuid or None