def request_vif(self, pod, project_id, subnets, security_groups): neutron = clients.get_neutron_client() req = self._get_port_request(pod, project_id, subnets, security_groups) vm_port = self._get_parent_port(neutron, pod) container_port = neutron.create_port(req).get('port') container_mac = container_port['mac_address'] container_ips = frozenset(entry['ip_address'] for entry in container_port['fixed_ips']) with self.lock: self._add_to_allowed_address_pairs(neutron, vm_port, container_ips, container_mac) return ovu.neutron_to_osvif_vif_nested_macvlan(container_port, subnets)
def request_vif(self, pod, project_id, subnets, security_groups): os_net = clients.get_network_client() req = self._get_port_request(pod, project_id, subnets, security_groups) attempts = kuryr_config.CONF.pod_vif_nested.rev_update_attempts container_port = None while attempts > 0: vm_port = self._get_parent_port(pod) if not container_port: container_port = os_net.create_port(**req) utils.tag_neutron_resources([container_port]) container_mac = container_port.mac_address container_ips = frozenset(entry['ip_address'] for entry in container_port.fixed_ips) attempts = self._try_update_port( attempts, self._add_to_allowed_address_pairs, vm_port, container_ips, container_mac) return ovu.neutron_to_osvif_vif_nested_macvlan(container_port, subnets)
def test_neutron_to_osvif_nested_macvlan(self, m_mk_vif, m_make_vif_network, m_is_port_active, m_get_vif_name): vif_plugin = const.K8S_OS_VIF_NOOP_PLUGIN port_id = mock.sentinel.port_id mac_address = mock.sentinel.mac_address port_filter = mock.sentinel.port_filter subnets = mock.sentinel.subnets network = mock.sentinel.network port_active = mock.sentinel.port_active vif_name = mock.sentinel.vif_name vif = mock.sentinel.vif m_make_vif_network.return_value = network m_is_port_active.return_value = port_active m_get_vif_name.return_value = vif_name m_mk_vif.return_value = vif port = { 'id': port_id, 'mac_address': mac_address, 'binding:vif_details': { 'port_filter': port_filter }, } self.assertEqual( vif, ovu.neutron_to_osvif_vif_nested_macvlan(port, subnets)) m_make_vif_network.assert_called_once_with(port, subnets) m_is_port_active.assert_called_once_with(port) m_get_vif_name.assert_called_once_with(port) m_mk_vif.assert_called_once_with(id=port_id, address=mac_address, network=network, has_traffic_filtering=port_filter, preserve_on_delete=False, active=port_active, plugin=vif_plugin, vif_name=vif_name)
def request_vif(self, pod, project_id, subnets, security_groups): neutron = clients.get_neutron_client() req = self._get_port_request(pod, project_id, subnets, security_groups) attempts = kuryr_config.CONF.pod_vif_nested.rev_update_attempts container_port = None while attempts > 0: vm_port = self._get_parent_port(pod) if not container_port: container_port = neutron.create_port({'port': req}).get('port') _tag_neutron_port(container_port['id']) container_mac = container_port['mac_address'] container_ips = frozenset(entry['ip_address'] for entry in container_port['fixed_ips']) attempts = self._try_update_port( attempts, self._add_to_allowed_address_pairs, vm_port, container_ips, container_mac) return ovu.neutron_to_osvif_vif_nested_macvlan(container_port, subnets)