def _mgmt_cna_to_vif(self, cna): """Converts the mgmt CNA to VIF format for network injection.""" mac = vm.norm_mac(cna.mac) ipv6_link_local = self._mac_to_link_local(mac) subnet = network_model.Subnet( version=6, cidr=_LLA_SUBNET, ips=[network_model.FixedIP(address=ipv6_link_local)]) network = network_model.Network(id='mgmt', subnets=[subnet], injected='yes') return network_model.VIF(id='mgmt_vif', address=mac, network=network)
def _mgmt_cna_to_vif(self, cna): """Converts the mgmt CNA to VIF format for network injection.""" mac = vm.norm_mac(cna.mac) ipv6_link_local = self._mac_to_link_local(mac) subnet = network_model.Subnet( version=6, cidr=_LLA_SUBNET, ips=[network_model.FixedIP(address=ipv6_link_local)]) network = network_model.Network(id='mgmt', subnets=[subnet], injected='yes') return network_model.VIF(id='mgmt_vif', address=mac, network=network)
def _find_cna_for_vif(cna_w_list, vif): """Finds the PowerVM CNA for a given Nova VIF. :param cna_w_list: The list of Client Network Adapter wrappers from pypowervm. :param vif: The Nova Virtual Interface (virtual network interface). :return: The CNA that corresponds to the VIF. None if one is not part of the cna_w_list. """ for cna_w in cna_w_list: if vm.norm_mac(cna_w.mac) == vif['address']: return cna_w return None
def _find_cna_for_vif(cna_w_list, vif): """Finds the PowerVM CNA for a given Nova VIF. :param cna_w_list: The list of Client Network Adapter wrappers from pypowervm. :param vif: The Nova Virtual Interface (virtual network interface). :return: The CNA that corresponds to the VIF. None if one is not part of the cna_w_list. """ for cna_w in cna_w_list: if vm.norm_mac(cna_w.mac) == vif['address']: return cna_w return None
def _vif_exists(self, network_info): """Does the instance have a CNA for a given net? :param network_info: A network information dict. This method expects it to contain key 'address' (MAC address). :return: True if a CNA with the network_info's MAC address exists on the instance. False otherwise. """ if self.cnas is None: self.cnas = vm.get_cnas(self.adapter, self.instance) vifs = self.cnas return network_info['address'] in [vm.norm_mac(v.mac) for v in vifs]
def _vif_exists(self, network_info): """Does the instance have a CNA for a given net? :param network_info: A network information dict. This method expects it to contain key 'address' (MAC address). :return: True if a CNA with the network_info's MAC address exists on the instance. False otherwise. """ if self.cnas is None: self.cnas = vm.get_cnas(self.adapter, self.instance) vifs = self.cnas return network_info['address'] in [vm.norm_mac(v.mac) for v in vifs]
def test_norm_mac(self): EXPECTED = "12:34:56:78:90:ab" self.assertEqual(EXPECTED, vm.norm_mac("12:34:56:78:90:ab")) self.assertEqual(EXPECTED, vm.norm_mac("1234567890ab")) self.assertEqual(EXPECTED, vm.norm_mac("12:34:56:78:90:AB")) self.assertEqual(EXPECTED, vm.norm_mac("1234567890AB"))
def test_norm_mac(self): EXPECTED = "12:34:56:78:90:ab" self.assertEqual(EXPECTED, vm.norm_mac("12:34:56:78:90:ab")) self.assertEqual(EXPECTED, vm.norm_mac("1234567890ab")) self.assertEqual(EXPECTED, vm.norm_mac("12:34:56:78:90:AB")) self.assertEqual(EXPECTED, vm.norm_mac("1234567890AB"))