def test_some_value_in_local_link_info_is_missing(self): for missing in self.lli[0]: tmp = copy.copy(self.lli[0]) tmp[missing] = "" self.port['binding:profile']['local_link_information'] = [tmp] local_link_info = fj_util.get_physical_connectivity(self.port) self.assertEqual({}, local_link_info)
def get_physical_net_params(self, mech_context): """Validate physical network parameters for baremetal deployment. Validates network & port params and returns dictionary. 'local_link_information' is a dictionary from Ironic-port. This value includes as follows: 'switch_id': A string of switch's MAC address This value is equal to 'chassis_id' from LLDP TLV. 'port_id': A string of switch interface name. This value is equal to 'port_id' from LLDP TLV. 'switch_info': A string of switch name. This value is equal to 'system_name' from LLDP TLV. @param mech_context a Context instance @return A dictionary parameters for baremetal deploy """ port = mech_context.current # currently supports only one segment per network segment = mech_context.network.network_segments[0] vfab_id = self._get_vfab_id(segment[driver_api.PHYSICAL_NETWORK]) vlanid = segment[driver_api.SEGMENTATION_ID] local_link_info = fj_util.get_physical_connectivity(port) physical_ports = ','.join(p['port_id'] for p in local_link_info) return { "address": self._switch['address'], "username": self._switch['username'], "password": self._switch['password'], "ports": physical_ports, "vfab_id": vfab_id, "vlanid": vlanid, "mac": port['mac_address'], "lag": fj_util.is_lag(local_link_info) }
def validate_baremetal_deploy(mech_context): """Validate baremetal deploy. @param mech_context a context object @return True if enable to baremetal deploy otherwise False """ port = mech_context.current network = mech_context.network if (fj_util.is_baremetal(port) and is_supported(network) and fj_util.get_physical_connectivity(port)): return True return False
def test_local_link_info_is_empty(self): self.port['binding:profile']['local_link_information'] = [] local_link_info = fj_util.get_physical_connectivity(self.port) self.assertEqual({}, local_link_info)
def test_get_correct_data(self): self.port['binding:profile']['local_link_information'] = self.lli expect = self.lli local_link_info = fj_util.get_physical_connectivity(self.port) self.assertEqual(expect, local_link_info)