From 7d7d2d971434d88e48e6ee85b6d94d0b8e14e65b Mon Sep 17 00:00:00 2001 From: paul-ruth Date: Fri, 24 Aug 2018 08:48:39 -0400 Subject: [PATCH 1/3] still in dev. works for adding/removing nodes to either switch --- .../devices/corsa_devices/__init__.py | 189 +++++++++++++++--- .../devices/corsa_devices/corsavfc.py | 124 +++++++++++- .../generic_switch_mech.py | 14 +- 3 files changed, 293 insertions(+), 34 deletions(-) diff --git a/networking_generic_switch/devices/corsa_devices/__init__.py b/networking_generic_switch/devices/corsa_devices/__init__.py index 806b581c..8e4cf2f3 100644 --- a/networking_generic_switch/devices/corsa_devices/__init__.py +++ b/networking_generic_switch/devices/corsa_devices/__init__.py @@ -115,10 +115,18 @@ def add_network(self, segmentation_id, network_id, of_controller=None): cont_ip, cont_port = of_controller if 'controllerNamespace' in self.config: c_controller_namespace = self.config['controllerNamespace'] - + + isVFCHost = True + if not 'VFCHost' in self.config and self.config['VFCHost'] == 'True': + LOG.info("PRUTH: Skipping VFC Creation: isVFCHost " + str(isVFCHost)) + isVFCHost = False + return + + LOG.info("controller: cont_ip = " + str(cont_ip) + ", cont_port = " + str(cont_port) + ", c_controller_namespace = " + str(c_controller_namespace)) LOG.info("segmentation_id " + str(segmentation_id)) LOG.info("provisioning vlan " + str(self.config['provisioningVLAN'])) + LOG.info("PRUTH: isVFCHost " + str(isVFCHost)) try: if self.config.has_key('provisioningVLAN'): if str(segmentation_id) == self.config['provisioningVLAN']: @@ -146,7 +154,8 @@ def add_network(self, segmentation_id, network_id, of_controller=None): for uplink in c_uplink_ports.split(','): #Attach the uplink tunnel LOG.info("About to get_ofport: c_br: " + str(c_br) + ", uplink: " + str(uplink)) - ofport=self.get_ofport(c_br,'P '+str(uplink)) + #The logical port number of an uplink is assumed to be the VLAN id + ofport=c_vlan LOG.info("ofport: " + str(ofport)) corsavfc.bridge_attach_tunnel_ctag_vlan(headers, url_switch, br_id = c_br, ofport = ofport, port = int(uplink), vlan_id = c_vlan) @@ -169,6 +178,14 @@ def del_network(self, segmentation_id): sw_ip_addr = self.config['switchIP'] url_switch = protocol + sw_ip_addr + isVFCHost = True + if not 'VFCHost' in self.config and self.config['VFCHost'] == 'True': + LOG.info("PRUTH: Skipping VFC Deletion: isVFCHost " + str(isVFCHost)) + isVFCHost = False + return + + + bridge = None try: with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): @@ -183,15 +200,16 @@ def del_network(self, segmentation_id): # Example: bridge=br3,port=P 32 -> ofport 332 # bridge=br33,port=P 2 -> ofport 3302 def get_ofport(self, bridge, port): + #return port from mapping + ofport = bridge[2:] if int(port[2:]) < 10: ofport += '0' ofport += port[2:] - - return ofport + return ofport - def plug_port_to_network(self, port, segmentation_id): + def plug_port_to_network(self, port, segmentation_id, vfc_host): #OpenStack requires port ids to not be numbers #Corsa uses numbers #We are lying to OpenStack by adding a 'p ' to the beging of each port number. @@ -207,34 +225,142 @@ def plug_port_to_network(self, port, segmentation_id): sw_ip_addr = self.config['switchIP'] url_switch = protocol + sw_ip_addr + + LOG.info("PRUTH: switch: " + str(self) + ", switch: " + self.config['name'] ) + LOG.info("PRUTH: self.config: " + str(self.config)) + LOG.info("PRUTH: Binding port " + str(port) + " to network " + str(segmentation_id)) + ofport=None + node_vlan=None + dst_switch_name=None + if port in self.config: + LOG.info("PRUTH: Binding port " + str(port) + " maps to " + str(self.config[port])) + ofport=str(int(self.config[port])+10000) + node_vlan=self.config[port] + else: + LOG.info("PRUTH: Binding port " + str(port) +" missing") + LOG.info("PRUTH: Binding port " + str(self.config)) + + if 'name' in self.config: + dst_switch_name=self.config['name'] + + if not vfc_host == self: + #Step 1: config local switch + #For now, VLANs are staticlly configured so this is a no-op + + #Step 2: config VFCHost with ctag tunnel + #params: segmentaion_id, node_vlan, destination_switch_name + vfc_host.__bind_ctag_tunnel(segmentation_id, node_vlan, dst_switch_name) + + else: + #Step 2: config VFCHost (i.e. local host) with passthrough tunnel + self.__bind_passthrough_tunnel(port, segmentation_id, ofport) + + + def __bind_passthrough_tunnel(self, port, segmentation_id, ofport): + port_num=port[2:] + token = self.config['token'] + headers = {'Authorization': token} + + logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) + + protocol = 'https://' + sw_ip_addr = self.config['switchIP'] + url_switch = protocol + sw_ip_addr + try: - with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): - # Make sure the tunnel_mode is 'passthrough' - corsavfc.port_modify_tunnel_mode(headers, url_switch, port_num, 'passthrough') + with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): + # Make sure the tunnel_mode is 'passthrough' + corsavfc.port_modify_tunnel_mode(headers, url_switch, port_num, 'passthrough') - # get the bridge from segmentation_id - br_id = corsavfc.get_bridge_by_segmentation_id(headers, url_switch, segmentation_id) + # get the bridge from segmentation_id + br_id = corsavfc.get_bridge_by_segmentation_id(headers, url_switch, segmentation_id) - try: - # unbind the port (probably not necessary) - # openflow port was mapped to the physical port with the same port number in plug_port_to_network - ofport = self.get_ofport(br_id,port) - corsavfc. bridge_detach_tunnel(headers, url_switch, br_id, ofport) - LOG.info("needed to delete_port: probably a leaked port from a node that did not completely boot the previous time. ") - except Exception as e: - LOG.info("Tried to delete_port but it was not there: this is expected." + traceback.format_exc()) - pass - - # bind the port - # physical port is mapped to the openflow port with the same port number - ofport = self.get_ofport(br_id,port) - corsavfc.bridge_attach_tunnel_passthrough(headers, url_switch, br_id, port_num, ofport, tc = None, descr = None, shaped_rate = None) + corsavfc.bridge_attach_tunnel_passthrough(headers, url_switch, br_id, port_num, ofport, tc = None, descr = None, shaped_rate = None) except Exception as e: LOG.error("Failed to plug to network: " + str(traceback.format_exc())) raise e - - def delete_port(self, port, segmentation_id): + + + + def __bind_ctag_tunnel(self, segmentation_id, node_vlan, dst_switch_name): + LOG.info("adding to vfc_host: __bind_ctag_tunnel") + LOG.info("PRUTH: switch: " + self.config['name'] + ", VFCHost: " + str(segmentation_id) + ", " + str(node_vlan) + ", " + str(dst_switch_name)) + + #port_num=port[2:] + token = self.config['token'] + headers = {'Authorization': token} + + logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) + + protocol = 'https://' + sw_ip_addr = self.config['switchIP'] + url_switch = protocol + sw_ip_addr + + dst_port=None + if dst_switch_name in self.config: + dst_port=self.config[dst_switch_name] + + + try: + with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): + LOG.info("About to dst_port: " + str(dst_port) ) + br_id = corsavfc.get_bridge_by_segmentation_id(headers, url_switch, segmentation_id) + ofport=str(int(str(node_vlan))+10000) + LOG.info("ofport: " + str(ofport)) + LOG.info("br_id: " + str(br_id)) + corsavfc.bridge_attach_tunnel_ctag_vlan(headers, url_switch, br_id = br_id, ofport = ofport, port = int(dst_port), vlan_id = node_vlan) + + except Exception as e: + raise e + + def delete_port(self, port, segmentation_id, vfc_host, ofport=None): + + + if ofport == None and port in self.config: + LOG.info("PRUTH: delete port " + str(port) + " maps to " + str(self.config[port])) + ofport=str(int(self.config[port])+10000) + + if not vfc_host == self: + vfc_host.delete_port(port, segmentation_id, vfc_host, ofport=ofport) + else: + self.__delete_ofport(ofport, segmentation_id) + + def __delete_ofport(self, ofport, segmentation_id): + #OpenStack requires port ids to not be numbers + #Corsa uses numbers + #We are lying to OpenStack by adding a 'p ' to the beging of each port number. + #We need to strip the 'p ' off of the port number. + #port_num=port[2:] + + token = self.config['token'] + headers = {'Authorization': token} + + logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) + + protocol = 'https://' + sw_ip_addr = self.config['switchIP'] + url_switch = protocol + sw_ip_addr + + LOG.info("PRUTH: delete port: switch: " + self.config['name'] + ", ofport: " + str(ofport) + ", segmentation_id: " + str(segmentation_id)) + + try: + with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): + # get the bridge from segmentation_id + br_id = corsavfc.get_bridge_by_segmentation_id(headers, url_switch, segmentation_id) + + # unbind the port + # openflow port was mapped to the physical port with the same port number in plug_port_to_network + #ofport = self.get_ofport(br_id,port) + corsavfc.bridge_detach_tunnel(headers, url_switch, br_id, ofport) + + except Exception as e: + LOG.error("Failed delete_port: " + traceback.format_exc()) + raise e + + + + def __delete_port(self, port, segmentation_id): #OpenStack requires port ids to not be numbers #Corsa uses numbers #We are lying to OpenStack by adding a 'p ' to the beging of each port number. @@ -250,6 +376,13 @@ def delete_port(self, port, segmentation_id): sw_ip_addr = self.config['switchIP'] url_switch = protocol + sw_ip_addr + LOG.info("PRUTH: delete port: switch: " + self.config['name'] + ", port: " + str(port) + ", segmentation_id: " + str(segmentation_id)) + + ofport=None + if port in self.config: + LOG.info("PRUTH: delete port " + str(port) + " maps to " + str(self.config[port])) + ofport=str(int(self.config[port])+10000) + try: with ngs_lock.PoolLock(self.locker, **self.lock_kwargs): # get the bridge from segmentation_id @@ -257,8 +390,8 @@ def delete_port(self, port, segmentation_id): # unbind the port # openflow port was mapped to the physical port with the same port number in plug_port_to_network - ofport = self.get_ofport(br_id,port) - corsavfc. bridge_detach_tunnel(headers, url_switch, br_id, ofport) + #ofport = self.get_ofport(br_id,port) + corsavfc.bridge_detach_tunnel(headers, url_switch, br_id, ofport) except Exception as e: LOG.error("Failed delete_port: " + traceback.format_exc()) diff --git a/networking_generic_switch/devices/corsa_devices/corsavfc.py b/networking_generic_switch/devices/corsa_devices/corsavfc.py index 878ab7e5..c3a90fe8 100644 --- a/networking_generic_switch/devices/corsa_devices/corsavfc.py +++ b/networking_generic_switch/devices/corsa_devices/corsavfc.py @@ -296,6 +296,7 @@ def bridge_attach_tunnel_ctag_vlan(headers, raise Exception(" Attach ctag vlan port to bridge Failed: " + "url: " + str(url) + ", " + str(output.status_code) + " Unknown Error") except Exception as e: + reclaim_ofport(headers, url_switch, ofport) raise e return output @@ -337,6 +338,7 @@ def bridge_attach_tunnel_passthrough(headers, if output.status_code == 400: raise Exception(" Attach passthrough port to bridge Failed: " + "url: " + str(url) + ", " + str(output.status_code) + " Bad Request") elif output.status_code == 403: + reclaim_port(headers,url_switch,port) raise Exception(" Attach passthrough port to bridge Failed: " + "url: " + str(url) + ", " + str(output.status_code) + " Forbidden") elif output.status_code == 404: raise Exception(" Attach passthrough port to bridge Failed: " + "url: " + str(url) + ", " + str(output.status_code) + " Not Found") @@ -348,7 +350,22 @@ def bridge_attach_tunnel_passthrough(headers, raise e return output - +#public facing function that tries to clean up and retry once on failure +#def bridge_attach_tunnel_passthrough(headers, +# url_switch, +# br_id, +# port, +# ofport = None, +# tc = None, +# descr = None, +# shaped_rate = None): +# +# try: +# __bridge_attach_tunnel_passthrough(headers, url_switch, br_id, port, ofport, tc, descr, shaped_rate) +# except Exception as e: +# reclaim_port(headers,url_switch,port) +# __bridge_attach_tunnel_passthrough(headers, url_switch, br_id, port, ofport, tc, descr, shaped_rate) + # # ATTACH TUNNEL - VLAN RANGE @@ -395,8 +412,8 @@ def bridge_attach_tunnel_ctag_vlan_range(headers, def bridge_detach_tunnel(headers, url_switch, br_id, - port): - url = url_switch + ep_bridges + '/' + str(br_id) + '/tunnels' + '/' + str(port) + ofport): + url = url_switch + ep_bridges + '/' + str(br_id) + '/tunnels' + '/' + str(ofport) try: output = requests.delete(url, headers=headers, verify=False) @@ -450,6 +467,22 @@ def get_bridge(headers, return r +# +# GET INFO +# +# 200 +# 403 Forbidden +def get_info(headers, + url_switch, + info_url): + + try: + r = requests.get(info_url, headers=headers, verify=False) + except Exception as e: + raise e + return r + + # # @@ -494,5 +527,90 @@ def get_bridge_by_segmentation_id(headers, return None +# +# reclaim ofport +# +# +def reclaim_ofport(headers, + url_switch, + ofport): + + bridges = get_bridges(headers,url_switch) + + links=bridges.json()["links"] + LOG.info("PRUTH: bridges: " + str(links)) + for bridge,value in links.items(): + #bridge = 'br'+str(i) + #bridgeInfo = get_bridge(headers,url_switch,bridges[bridge]) + #link=links[str(bridge)] + LOG.info("PRUTH: bridge: " + str(bridge) + ", value: " + str(value ) ) + url=value['href'] + LOG.info("PRUTH: bridge url: " + str(bridge) + ", href: " + str(url) ) + bridge_data = get_bridge(headers,url_switch,url) + bridge_tunnels_url = str(bridge_data.json()['links']['tunnels']['href']) + LOG.info("PRUTH: bridge tunnels url: " + str(bridge_tunnels_url)) + bridge_tunnels = get_info(headers,url_switch,bridge_tunnels_url) + LOG.info("PRUTH: bridge tunnels: " + str(bridge_tunnels.json())) + for tunnel,value in bridge_tunnels.json()['links'].items(): + LOG.info("PRUTH: bridge tunnel: " + str(tunnel) + ", value: " + str(value)) + tunnel_url=value['href'] + LOG.info("PRUTH: bridge tunnel_url: " + str(tunnel_url)) + tunnel_info = get_info(headers,url_switch,tunnel_url) + LOG.info("PRUTH: bridge tunnel_info: " + str(tunnel_info.json())) + current_port = tunnel_info.json()['port'] + current_ofport = tunnel_info.json()['ofport'] + LOG.info("PRUTH: current_port: " + str(current_port) + ", ofport: " + str(ofport) + ", current_ofport: " + str(current_ofport)) + if str(current_ofport) == str(ofport): + LOG.info("PRUTH: FOUND PORT. KILL IT. ") + bridge_detach_tunnel(headers, url_switch, str(bridge), str(current_ofport)) + + return None + + + +# +# +# +# reclaim physical port. +# If we try to bind a port to a VFC and get a "forbidden" return code this could mean +# that the port is already bound. In this case we can try to reclaim to port by +# checking all VFCs for the port and then unbinding it if the port is found. +# +def reclaim_port(headers, + url_switch, + port): + + bridges = get_bridges(headers,url_switch) + + links=bridges.json()["links"] + LOG.info("PRUTH: bridges: " + str(links)) + for bridge,value in links.items(): + #bridge = 'br'+str(i) + #bridgeInfo = get_bridge(headers,url_switch,bridges[bridge]) + #link=links[str(bridge)] + LOG.info("PRUTH: bridge: " + str(bridge) + ", value: " + str(value ) ) + url=value['href'] + LOG.info("PRUTH: bridge url: " + str(bridge) + ", href: " + str(url) ) + bridge_data = get_bridge(headers,url_switch,url) + bridge_tunnels_url = str(bridge_data.json()['links']['tunnels']['href']) + LOG.info("PRUTH: bridge tunnels url: " + str(bridge_tunnels_url)) + bridge_tunnels = get_info(headers,url_switch,bridge_tunnels_url) + LOG.info("PRUTH: bridge tunnels: " + str(bridge_tunnels.json())) + for tunnel,value in bridge_tunnels.json()['links'].items(): + LOG.info("PRUTH: bridge tunnel: " + str(tunnel) + ", value: " + str(value)) + tunnel_url=value['href'] + LOG.info("PRUTH: bridge tunnel_url: " + str(tunnel_url)) + tunnel_info = get_info(headers,url_switch,tunnel_url) + LOG.info("PRUTH: bridge tunnel_info: " + str(tunnel_info.json())) + current_port = tunnel_info.json()['port'] + current_ofport = tunnel_info.json()['ofport'] + LOG.info("PRUTH: current_port: " + str(current_port) + ", port: " + str(port) + ", current_ofport: " + str(current_ofport)) + if current_port == port: + LOG.info("PRUTH: FOUND PORT. KILL IT. ") + bridge_detach_tunnel(headers, url_switch, str(bridge), str(current_ofport)) + + return None + + diff --git a/networking_generic_switch/generic_switch_mech.py b/networking_generic_switch/generic_switch_mech.py index 3a1a1680..45769f3e 100644 --- a/networking_generic_switch/generic_switch_mech.py +++ b/networking_generic_switch/generic_switch_mech.py @@ -38,12 +38,17 @@ def initialize(self): been initialized. No abstract methods defined below will be called prior to this method being called. """ + LOG.info("PRUTH: GenericSwitchDriver") + self.vfcHost=None gsw_devices = gsw_conf.get_devices() self.switches = {} for switch_info, device_cfg in gsw_devices.items(): switch = devices.device_manager(device_cfg) + device_cfg['name']=switch_info self.switches[switch_info] = switch + if 'VFCHost' in device_cfg and device_cfg['VFCHost'] == 'True': + self.vfcHost = switch LOG.info('Devices %s have been loaded', self.switches.keys()) if not self.switches: LOG.error('No devices have been loaded') @@ -80,11 +85,13 @@ def create_network_postcommit(self, context): of_controller = self.__get_of_controller(network) + LOG.info("PRUTH: create_network: " + str(network) + ", network_id: " + str(network_id)) + if provider_type == 'vlan' and segmentation_id: # Create vlan on all switches from this driver for switch_name, switch in self.switches.items(): try: - if of_controller and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + if of_controller and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): switch.add_network(segmentation_id, network_id, of_controller) else: switch.add_network(segmentation_id, network_id) @@ -451,6 +458,7 @@ def bind_port(self, context): port = context.current binding_profile = port['binding:profile'] local_link_information = binding_profile.get('local_link_information') + LOG.info("PRUTH: Bindport, port: " + str(port) + ", binding_profile: " + str(binding_profile)) if self._is_port_supported(port) and local_link_information: switch_info = local_link_information[0].get('switch_info') switch_id = local_link_information[0].get('switch_id') @@ -474,7 +482,7 @@ def bind_port(self, context): switch_info=switch_info, segmentation_id=segmentation_id)) # Move port to network - switch.plug_port_to_network(port_id, segmentation_id) + switch.plug_port_to_network(port_id, segmentation_id, vfc_host=self.vfcHost) LOG.info("Successfully bound port %(port_id)s in segment " " %(segment_id)s on device %(device)s", {'port_id': port['id'], 'device': switch_info, @@ -538,7 +546,7 @@ def _unplug_port_from_network(self, port, network): switch_info=switch_info, segmentation_id=segmentation_id)) try: - switch.delete_port(port_id, segmentation_id) + switch.delete_port(port_id, segmentation_id, vfc_host=self.vfcHost) except Exception as e: LOG.error("Failed to unplug port %(port_id)s " "on device: %(switch)s from network %(net_id)s " From 50387c45680c044abadbba125ae7f84ce2de9727 Mon Sep 17 00:00:00 2001 From: paul-ruth Date: Fri, 21 Sep 2018 19:35:28 +0000 Subject: [PATCH 2/3] finalized fixes for rainbow vlans --- .../devices/corsa_devices/__init__.py | 4 ++-- networking_generic_switch/generic_switch_mech.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/networking_generic_switch/devices/corsa_devices/__init__.py b/networking_generic_switch/devices/corsa_devices/__init__.py index 8e4cf2f3..c9425193 100644 --- a/networking_generic_switch/devices/corsa_devices/__init__.py +++ b/networking_generic_switch/devices/corsa_devices/__init__.py @@ -117,7 +117,7 @@ def add_network(self, segmentation_id, network_id, of_controller=None): c_controller_namespace = self.config['controllerNamespace'] isVFCHost = True - if not 'VFCHost' in self.config and self.config['VFCHost'] == 'True': + if not 'VFCHost' in self.config or not self.config['VFCHost'] == 'True': LOG.info("PRUTH: Skipping VFC Creation: isVFCHost " + str(isVFCHost)) isVFCHost = False return @@ -179,7 +179,7 @@ def del_network(self, segmentation_id): url_switch = protocol + sw_ip_addr isVFCHost = True - if not 'VFCHost' in self.config and self.config['VFCHost'] == 'True': + if not 'VFCHost' in self.config or not self.config['VFCHost'] == 'True': LOG.info("PRUTH: Skipping VFC Deletion: isVFCHost " + str(isVFCHost)) isVFCHost = False return diff --git a/networking_generic_switch/generic_switch_mech.py b/networking_generic_switch/generic_switch_mech.py index 45769f3e..2050268f 100644 --- a/networking_generic_switch/generic_switch_mech.py +++ b/networking_generic_switch/generic_switch_mech.py @@ -45,7 +45,8 @@ def initialize(self): self.switches = {} for switch_info, device_cfg in gsw_devices.items(): switch = devices.device_manager(device_cfg) - device_cfg['name']=switch_info + if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + device_cfg['name']=switch_info self.switches[switch_info] = switch if 'VFCHost' in device_cfg and device_cfg['VFCHost'] == 'True': self.vfcHost = switch @@ -482,7 +483,11 @@ def bind_port(self, context): switch_info=switch_info, segmentation_id=segmentation_id)) # Move port to network - switch.plug_port_to_network(port_id, segmentation_id, vfc_host=self.vfcHost) + if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + switch.plug_port_to_network(port_id, segmentation_id, vfc_host=self.vfcHost) + else: + switch.plug_port_to_network(port_id, segmentation_id) + LOG.info("Successfully bound port %(port_id)s in segment " " %(segment_id)s on device %(device)s", {'port_id': port['id'], 'device': switch_info, @@ -546,7 +551,11 @@ def _unplug_port_from_network(self, port, network): switch_info=switch_info, segmentation_id=segmentation_id)) try: - switch.delete_port(port_id, segmentation_id, vfc_host=self.vfcHost) + if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + switch.delete_port(port_id, segmentation_id, vfc_host=self.vfcHost) + else: + switch.delete_port(port_id, segmentation_id) + except Exception as e: LOG.error("Failed to unplug port %(port_id)s " "on device: %(switch)s from network %(net_id)s " From cf7bbcb5ad7689b757ad1e0e4f04f5274928562d Mon Sep 17 00:00:00 2001 From: mcevik0 Date: Mon, 24 Sep 2018 18:09:16 +0000 Subject: [PATCH 3/3] Fixes for checking corsa_devices attribute on devices --- .../devices/corsa_devices/__init__.py | 2 +- networking_generic_switch/generic_switch_mech.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/networking_generic_switch/devices/corsa_devices/__init__.py b/networking_generic_switch/devices/corsa_devices/__init__.py index c9425193..4d27caec 100644 --- a/networking_generic_switch/devices/corsa_devices/__init__.py +++ b/networking_generic_switch/devices/corsa_devices/__init__.py @@ -100,7 +100,7 @@ def add_network(self, segmentation_id, network_id, of_controller=None): url_switch = protocol + sw_ip_addr #./create-vfc.py br1 5 openflow VFC-1 192.168.201.164 6653 100-105 - c_br_res = self.config['dafaultVFCRes'] + c_br_res = self.config['defaultVFCRes'] c_br_type = self.config['VFCType'] c_br_descr = "VLAN-" + str(segmentation_id) c_vlan = segmentation_id diff --git a/networking_generic_switch/generic_switch_mech.py b/networking_generic_switch/generic_switch_mech.py index 2050268f..87b9ed14 100644 --- a/networking_generic_switch/generic_switch_mech.py +++ b/networking_generic_switch/generic_switch_mech.py @@ -45,7 +45,7 @@ def initialize(self): self.switches = {} for switch_info, device_cfg in gsw_devices.items(): switch = devices.device_manager(device_cfg) - if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + if hasattr(devices,'corsa_devices') and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): device_cfg['name']=switch_info self.switches[switch_info] = switch if 'VFCHost' in device_cfg and device_cfg['VFCHost'] == 'True': @@ -92,7 +92,7 @@ def create_network_postcommit(self, context): # Create vlan on all switches from this driver for switch_name, switch in self.switches.items(): try: - if of_controller and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + if of_controller and hasattr(devices,'corsa_devices') and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): switch.add_network(segmentation_id, network_id, of_controller) else: switch.add_network(segmentation_id, network_id) @@ -483,7 +483,7 @@ def bind_port(self, context): switch_info=switch_info, segmentation_id=segmentation_id)) # Move port to network - if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + if hasattr(devices,'corsa_devices') and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): switch.plug_port_to_network(port_id, segmentation_id, vfc_host=self.vfcHost) else: switch.plug_port_to_network(port_id, segmentation_id) @@ -551,7 +551,7 @@ def _unplug_port_from_network(self, port, network): switch_info=switch_info, segmentation_id=segmentation_id)) try: - if isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): + if hasattr(devices,'corsa_devices') and isinstance(switch, devices.corsa_devices.corsa2100.CorsaDP2100): switch.delete_port(port_id, segmentation_id, vfc_host=self.vfcHost) else: switch.delete_port(port_id, segmentation_id)