From: tierno Date: Tue, 13 Mar 2018 17:52:23 +0000 (+0100) Subject: VNFFG fixed some issues X-Git-Tag: v4.0.0~40 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F80%2F5880%2F2;p=osm%2FRO.git VNFFG fixed some issues Change-Id: I5d1a481687c37e58a1202091ff8534a4253a82f0 Signed-off-by: tierno --- diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index f5ffe09e..bf32c245 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -3687,7 +3687,7 @@ def delete_instance(mydb, tenant_id, instance_id): # 2.3 deleting VNFFGs - for sfp in instanceDict['sfps']: + for sfp in instanceDict.get('sfps', ()): vimthread_affected[sfp["datacenter_tenant_id"]] = None datacenter_key = (sfp["datacenter_id"], sfp["datacenter_tenant_id"]) if datacenter_key not in myvims: @@ -3724,7 +3724,7 @@ def delete_instance(mydb, tenant_id, instance_id): task_index += 1 db_vim_actions.append(db_vim_action) - for sf in instanceDict['sfs']: + for sf in instanceDict.get('sfs', ()): vimthread_affected[sf["datacenter_tenant_id"]] = None datacenter_key = (sf["datacenter_id"], sf["datacenter_tenant_id"]) if datacenter_key not in myvims: @@ -3761,7 +3761,7 @@ def delete_instance(mydb, tenant_id, instance_id): task_index += 1 db_vim_actions.append(db_vim_action) - for sfi in instanceDict['sfis']: + for sfi in instanceDict.get('sfis', ()): vimthread_affected[sfi["datacenter_tenant_id"]] = None datacenter_key = (sfi["datacenter_id"], sfi["datacenter_tenant_id"]) if datacenter_key not in myvims: diff --git a/osm_ro/nfvo_db.py b/osm_ro/nfvo_db.py index e9db4799..87e3f1e1 100644 --- a/osm_ro/nfvo_db.py +++ b/osm_ro/nfvo_db.py @@ -1025,25 +1025,25 @@ class nfvo_db(db_base.db_base): self.cur.execute(cmd) instance_dict['sfps'] = self.cur.fetchall() - for sfp in instance_dict['sfps']: - #instance_sfs - cmd = "SELECT uuid,vim_sf_id,sce_rsp_hop_id,datacenter_id,"\ - "datacenter_tenant_id,status,error_msg,vim_info"\ - " FROM instance_sfs" \ - " WHERE instance_scenario_id='{}' ORDER BY created_at".format(instance_dict['uuid']) # TODO: replace instance_scenario_id with instance_sfp_id - self.logger.debug(cmd) - self.cur.execute(cmd) - instance_dict['sfs'] = self.cur.fetchall() + # for sfp in instance_dict['sfps']: + #instance_sfs + cmd = "SELECT uuid,vim_sf_id,sce_rsp_hop_id,datacenter_id,"\ + "datacenter_tenant_id,status,error_msg,vim_info"\ + " FROM instance_sfs" \ + " WHERE instance_scenario_id='{}' ORDER BY created_at".format(instance_dict['uuid']) # TODO: replace instance_scenario_id with instance_sfp_id + self.logger.debug(cmd) + self.cur.execute(cmd) + instance_dict['sfs'] = self.cur.fetchall() - for sf in instance_dict['sfs']: - #instance_sfis - cmd = "SELECT uuid,vim_sfi_id,sce_rsp_hop_id,datacenter_id,"\ - "datacenter_tenant_id,status,error_msg,vim_info"\ - " FROM instance_sfis" \ - " WHERE instance_scenario_id='{}' ORDER BY created_at".format(instance_dict['uuid']) # TODO: replace instance_scenario_id with instance_sf_id - self.logger.debug(cmd) - self.cur.execute(cmd) - instance_dict['sfis'] = self.cur.fetchall() + #for sf in instance_dict['sfs']: + #instance_sfis + cmd = "SELECT uuid,vim_sfi_id,sce_rsp_hop_id,datacenter_id,"\ + "datacenter_tenant_id,status,error_msg,vim_info"\ + " FROM instance_sfis" \ + " WHERE instance_scenario_id='{}' ORDER BY created_at".format(instance_dict['uuid']) # TODO: replace instance_scenario_id with instance_sf_id + self.logger.debug(cmd) + self.cur.execute(cmd) + instance_dict['sfis'] = self.cur.fetchall() # for sfi in instance_dict['sfi']: #instance_classifications diff --git a/osm_ro/vimconn_openstack.py b/osm_ro/vimconn_openstack.py index e8263ade..fd16f544 100644 --- a/osm_ro/vimconn_openstack.py +++ b/osm_ro/vimconn_openstack.py @@ -36,7 +36,7 @@ __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes, xFlow Research, Igor __date__ = "$22-sep-2017 23:59:59$" import vimconn -import json +# import json import logging import netaddr import time @@ -493,9 +493,10 @@ class vimconnector(vimconn.vimconnector): self.logger.debug("Getting network from VIM filter: '%s'", str(filter_dict)) try: self._reload_connection() - if self.api_version3 and "tenant_id" in filter_dict: - filter_dict['project_id'] = filter_dict.pop('tenant_id') #TODO check - net_dict = self.neutron.list_networks(**filter_dict) + filter_dict_os = filter_dict.copy() + if self.api_version3 and "tenant_id" in filter_dict_os: + filter_dict_os['project_id'] = filter_dict_os.pop('tenant_id') #T ODO check + net_dict = self.neutron.list_networks(**filter_dict_os) net_list = net_dict["networks"] self.__net_os2mano(net_list) return net_list @@ -840,9 +841,9 @@ class vimconnector(vimconn.vimconnector): self.logger.debug("Getting image list from VIM filter: '%s'", str(filter_dict)) try: self._reload_connection() - filter_dict_os=filter_dict.copy() + filter_dict_os = filter_dict.copy() #First we filter by the available filter fields: name, id. The others are removed. - filter_dict_os.pop('checksum',None) + filter_dict_os.pop('checksum', None) image_list = self.nova.images.findall(**filter_dict_os) if len(image_list) == 0: return [] @@ -851,7 +852,7 @@ class vimconnector(vimconn.vimconnector): for image in image_list: try: image_class = self.glance.images.get(image.id) - if 'checksum' not in filter_dict or image_class['checksum']==filter_dict.get('checksum'): + if 'checksum' not in filter_dict or image_class['checksum'] == filter_dict.get('checksum'): filtered_list.append(image_class.copy()) except gl1Exceptions.HTTPNotFound: pass @@ -1717,12 +1718,13 @@ class vimconnector(vimconn.vimconnector): self.logger.debug("Getting Classifications from VIM filter: '%s'", str(filter_dict)) try: + filter_dict_os = filter_dict.copy() self._reload_connection() - if self.api_version3 and "tenant_id" in filter_dict: - filter_dict['project_id'] = filter_dict.pop('tenant_id') + if self.api_version3 and "tenant_id" in filter_dict_os: + filter_dict_os['project_id'] = filter_dict_os.pop('tenant_id') classification_dict = self.neutron.list_sfc_flow_classifiers( - **filter_dict) - classification_list = cliassification_dict["flow_classifiers"] + **filter_dict_os) + classification_list = classification_dict["flow_classifiers"] self.__classification_os2mano(classification_list) return classification_list except (neExceptions.ConnectionFailed, ksExceptions.ClientException, @@ -1796,9 +1798,10 @@ class vimconnector(vimconn.vimconnector): "VIM filter: '%s'", str(filter_dict)) try: self._reload_connection() - if self.api_version3 and "tenant_id" in filter_dict: - filter_dict['project_id'] = filter_dict.pop('tenant_id') - sfi_dict = self.neutron.list_sfc_port_pairs(**filter_dict) + filter_dict_os = filter_dict.copy() + if self.api_version3 and "tenant_id" in filter_dict_os: + filter_dict_os['project_id'] = filter_dict_os.pop('tenant_id') + sfi_dict = self.neutron.list_sfc_port_pairs(**filter_dict_os) sfi_list = sfi_dict["port_pairs"] self.__sfi_os2mano(sfi_list) return sfi_list @@ -1868,9 +1871,10 @@ class vimconnector(vimconn.vimconnector): str(filter_dict)) try: self._reload_connection() - if self.api_version3 and "tenant_id" in filter_dict: - filter_dict['project_id'] = filter_dict.pop('tenant_id') - sf_dict = self.neutron.list_sfc_port_pair_groups(**filter_dict) + filter_dict_os = filter_dict.copy() + if self.api_version3 and "tenant_id" in filter_dict_os: + filter_dict_os['project_id'] = filter_dict_os.pop('tenant_id') + sf_dict = self.neutron.list_sfc_port_pair_groups(**filter_dict_os) sf_list = sf_dict["port_pair_groups"] self.__sf_os2mano(sf_list) return sf_list @@ -1937,9 +1941,10 @@ class vimconnector(vimconn.vimconnector): "'%s'", str(filter_dict)) try: self._reload_connection() - if self.api_version3 and "tenant_id" in filter_dict: - filter_dict['project_id'] = filter_dict.pop('tenant_id') - sfp_dict = self.neutron.list_sfc_port_chains(**filter_dict) + filter_dict_os = filter_dict.copy() + if self.api_version3 and "tenant_id" in filter_dict_os: + filter_dict_os['project_id'] = filter_dict_os.pop('tenant_id') + sfp_dict = self.neutron.list_sfc_port_chains(**filter_dict_os) sfp_list = sfp_dict["port_chains"] self.__sfp_os2mano(sfp_list) return sfp_list