def delete_port_postcommit(self, mech_context): """Calls cleanup process for C-Fabric. Case1: Baremetal deploy Clear VLAN/LAG for specified physical port. Case2: Otherwise Dissociate MAC address from the portprofile. """ method = 'delete_port_postcommit' port = mech_context.current port_id = port['id'] network_id = port['network_id'] tenant_id = port['tenant_id'] if fj_util.is_baremetal(port): if validate_baremetal_deploy(mech_context): params = self.get_physical_net_params(mech_context) try: self.clear_vlan(params) except Exception: LOG.exception(_LE("Failed to clear vlan%s."), params['vlanid']) raise ml2_exc.MechanismDriverError(method=method) elif not is_supported(mech_context.network): pass else: segments = mech_context.network.network_segments # currently supports only one segment per network segment = segments[0] vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK]) vlanid = segment[driver_api.SEGMENTATION_ID] interface_mac = port['mac_address'] try: self._driver.dissociate_mac_from_network( self._switch['address'], self._switch['username'], self._switch['password'], vfab_id, vlanid, interface_mac) except Exception: LOG.exception( _LE("Fujitsu Mechanism: failed to dissociate MAC %s") % interface_mac) raise ml2_exc.MechanismDriverError(method=method) LOG.info( _LI("delete port (postcommit): port_id=%(port_id)s " "network_id=%(network_id)s tenant_id=%(tenant_id)s"), {'port_id': port_id, 'network_id': network_id, 'tenant_id': tenant_id})
def create_port_postcommit(self, mech_context): """Calls setup process for C-Fabric. Case1: Baremetal deploy Setup VLAN for specified physical port. Case2: Otherwise Associate the assigned MAC address to the portprofile. """ if fj_util.is_baremetal(mech_context.current): return if not is_supported(mech_context.network): return method = 'create_port_postcommit' port = mech_context.current port_id = port['id'] network_id = port['network_id'] tenant_id = port['tenant_id'] segments = mech_context.network.network_segments # currently supports only one segment per network segment = segments[0] vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK]) vlanid = segment[driver_api.SEGMENTATION_ID] interface_mac = port['mac_address'] try: self._driver.associate_mac_to_network(self._switch['address'], self._switch['username'], self._switch['password'], vfab_id, vlanid, interface_mac) except Exception: LOG.exception( _LE("Fujitsu Mechanism: failed to associate mac %s") % interface_mac) raise ml2_exc.MechanismDriverError(method=method) LOG.info( _LI("created port (postcommit): port_id=%(port_id)s " "network_id=%(network_id)s tenant_id=%(tenant_id)s"), {'port_id': port_id, 'network_id': network_id, 'tenant_id': tenant_id})
def clear_vlan(self, params): """Clear VLAN with specified port(s). This method will select driver's method. Case1: param['lag'] is True This method calls 'clear_vlan_with_lag' and clears VLAN and LAG. Case2: param['lag'] is False This method calls 'clear_vlan' and clears only VLAN. @param params A dictionary of the return value for get_physical_net_params @return None """ target = 'clear_vlan_with_lag' call_target = target if params['lag'] else 'clear_vlan' try: clear_method = getattr(self._driver, call_target) except AttributeError: LOG.exception(_LE("Unexpected error happend.")) raise ml2_exc.MechanismDriverError(method="clear_vlan") try: # This plugin supposes 1 C-Fabric(fabric_id) management. # Therefore, not to identify target IP address by using # switch_info(mac_address). LOG.info(_LI("call %(target)s. params: %(params)s"), {'target': call_target, 'params': params}) clear_method( params['address'], params['username'], params['password'], params['vfab_id'], params['vlanid'], params['ports'], params['mac'], ) except Exception: LOG.exception(_LE("Fujitsu Mechanism: " "failed to clear vlan %s"), params['vlanid']) raise ml2_exc.MechanismDriverError(method="clear_vlan")