From 1dfe9939de013695210e4e0495b15ca75bd81321 Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 18 Jun 2020 08:50:10 +0000 Subject: [PATCH] openstack: get vlan from port binding:vif_details Change-Id: I828cfa02a32e95a9a161ce0db288a11a4e9a591c Signed-off-by: tierno --- .../osm_rovim_openstack/vimconn_openstack.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index 61231411..ba8b004c 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1655,11 +1655,16 @@ class vimconnector(vimconn.VimConnector): # interface["pci"] = pci[:-4] + "00." + str(int(pci[-1]) % 2) interface["pci"] = pci interface["vlan"] = None - #if network is of type vlan and port is of type direct (sr-iov) then set vlan id - network = self.neutron.show_network(port["network_id"]) - if network['network'].get('provider:network_type') == 'vlan' and \ - port.get("binding:vnic_type") in ("direct", "direct-physical"): - interface["vlan"] = network['network'].get('provider:segmentation_id') + if port.get('binding:vif_details'): + interface["vlan"] = port['binding:vif_details'].get('vlan') + # Get vlan from network in case not present in port for those old openstacks and cases where + # it is needed vlan at PT + if not interface["vlan"]: + # if network is of type vlan and port is of type direct (sr-iov) then set vlan id + network = self.neutron.show_network(port["network_id"]) + if network['network'].get('provider:network_type') == 'vlan': + # and port.get("binding:vnic_type") in ("direct", "direct-physical"): + interface["vlan"] = network['network'].get('provider:segmentation_id') ips=[] #look for floating ip address try: -- 2.25.1