From: tierno Date: Tue, 10 Mar 2020 16:31:03 +0000 (+0000) Subject: Bug 1019. Fix ovim.get_ports needed for wim X-Git-Tag: v7.1.0rc1~1^2~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f99006654443713256d2528ec624b4eb81ba3b77;p=osm%2FRO.git Bug 1019. Fix ovim.get_ports needed for wim Change-Id: I3696fad4c49ce43844c6c97ffaf90ba9ebad95a5 Signed-off-by: tierno --- diff --git a/RO/osm_ro/sdn.py b/RO/osm_ro/sdn.py index 636be552..a1999288 100755 --- a/RO/osm_ro/sdn.py +++ b/RO/osm_ro/sdn.py @@ -345,3 +345,21 @@ class Sdn: else: map["service_mapping_info"] = {} return maps + + def get_ports(self, instance_wim_net_id): + # get wim_id + instance_wim_net = self.db.get_rows(FROM='instance_wim_nets', WHERE={"uuid": instance_wim_net_id}) + wim_id = instance_wim_net[0]["wim_id"] + switch_ports = [] + ports = self.db.get_rows(FROM='instance_interfaces', WHERE={"instance_wim_net_id": instance_wim_net_id}) + maps = self.get_of_port_mappings(db_filter={"wim_id": wim_id}) + for port in ports: + map_ = next((x for x in maps if x.get("device_id") == port["compute_node"] and + x.get("device_interface_id") == port["pci"]), None) + if map_: + switch_port = {'switch_dpid': map_.get('switch_dpid') or map_.get('switch_id'), + 'switch_port': map_.get('switch_port')} + if switch_port not in switch_ports: + switch_ports.append(switch_port) + return switch_ports + diff --git a/RO/osm_ro/wim/wan_link_actions.py b/RO/osm_ro/wim/wan_link_actions.py index 458f3d52..7409fb78 100644 --- a/RO/osm_ro/wim/wan_link_actions.py +++ b/RO/osm_ro/wim/wan_link_actions.py @@ -207,9 +207,8 @@ class WanLinkCreate(RefreshMixin, CreateAction): return merge_dicts(wan_port_mapping, service_mapping_info=mapping) def _get_port_sdn(self, ovim, instance_net): - criteria = {'net_id': instance_net['sdn_net_id']} try: - local_port_mapping = ovim.get_ports(filter=criteria) + local_port_mapping = ovim.get_ports(instance_net['sdn_net_id']) if local_port_mapping: return (local_port_mapping[0]['switch_dpid'], @@ -217,7 +216,7 @@ class WanLinkCreate(RefreshMixin, CreateAction): except: # noqa self.logger.exception('Problems when calling OpenVIM') - self.logger.debug('No ports found using criteria:\n%r\n.', criteria) + self.logger.debug("No ports found for sdn_net_id='{}'", instance_net['sdn_net_id']) return None def _evaluate_rules(self, rules, vim_info):