diff --git a/nova/compute/api.py b/nova/compute/api.py index 2826c683a590..c039b3a796df 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -817,8 +817,8 @@ class API(base.Base): # InstancePCIRequests object pci_request_info = pci_request.get_pci_requests_from_flavor( instance_type) - self.network_api.create_pci_requests_for_sriov_ports(context, - pci_request_info, requested_networks) + self.network_api.create_resource_requests( + context, requested_networks, pci_request_info) base_options = { 'reservation_id': reservation_id, diff --git a/nova/network/api.py b/nova/network/api.py index e01daec9309b..2ffb1eca13da 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -385,15 +385,13 @@ class API(base_api.NetworkAPI): # the requested number in this case. return num_instances - def create_pci_requests_for_sriov_ports(self, context, - pci_requests, - requested_networks): - """Check requested networks for any SR-IOV port request. - - Create a PCI request object for each SR-IOV port, and add it to the - pci_requests object that contains a list of PCI request object. + def create_resource_requests(self, context, requested_networks, + pci_requests=None): + """Retrieve all information for the networks passed at the time of + creating the server. """ - # This is NOOP for Nova network since it doesn't support SR-IOV. + # This is NOOP for Nova network since it doesn't support SR-IOV or + # NUMA-aware vSwitch functionality. pass def get_dns_domains(self, context): diff --git a/nova/network/base_api.py b/nova/network/base_api.py index 99ac59aed35b..c66f973ec5b2 100644 --- a/nova/network/base_api.py +++ b/nova/network/base_api.py @@ -261,16 +261,6 @@ class NetworkAPI(base.Base): """Template method, so a subclass can implement for neutron/network.""" raise NotImplementedError() - def create_pci_requests_for_sriov_ports(self, context, - pci_requests, - requested_networks): - """Check requested networks for any SR-IOV port request. - - Create a PCI request object for each SR-IOV port, and add it to the - pci_requests object that contains a list of PCI request object. - """ - raise NotImplementedError() - def validate_networks(self, context, requested_networks, num_instances): """validate the networks passed at the time of creating the server. @@ -280,6 +270,19 @@ class NetworkAPI(base.Base): """ raise NotImplementedError() + def create_resource_requests(self, context, requested_networks): + """Retrieve all information for the networks passed at the time of + creating the server. + + :param context: The request context. + :param requested_networks: The networks requested for the server. + :type requested_networks: nova.objects.RequestedNetworkList + :param pci_requests: The list of PCI requests to which additional PCI + requests created here will be added. + :type pci_requests: nova.objects.InstancePCIRequests + """ + raise NotImplementedError() + def get_dns_domains(self, context): """Returns a list of available dns domains. These can be used to create DNS entries for floating IPs. diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index badb40a5d96c..d8295a547ade 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -1612,12 +1612,10 @@ class API(base_api.NetworkAPI): return vnic_type, trusted, network_id - def create_pci_requests_for_sriov_ports(self, context, pci_requests, - requested_networks): - """Check requested networks for any SR-IOV port request. - - Create a PCI request object for each SR-IOV port, and add it to the - pci_requests object that contains a list of PCI request object. + def create_resource_requests(self, context, requested_networks, + pci_requests=None): + """Retrieve all information for the networks passed at the time of + creating the server. """ if not requested_networks or requested_networks.no_allocate: return diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 8f32cb89a901..fb2a92534db9 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -1214,7 +1214,7 @@ class NeutronFixture(fixtures.Fixture): lambda *args, **kwargs: 1) self.test.stub_out( 'nova.network.neutronv2.api.API.' - 'create_pci_requests_for_sriov_ports', + 'create_resource_requests', lambda *args, **kwargs: None) self.test.stub_out( 'nova.network.neutronv2.api.API.setup_networks_on_host', diff --git a/nova/tests/unit/api/openstack/fakes.py b/nova/tests/unit/api/openstack/fakes.py index 300f901bf209..f1c80a2afb70 100644 --- a/nova/tests/unit/api/openstack/fakes.py +++ b/nova/tests/unit/api/openstack/fakes.py @@ -201,9 +201,8 @@ def stub_out_nw_api(test, cls=None, private=None, publics=None): def validate_networks(self, context, networks, max_count): return max_count - def create_pci_requests_for_sriov_ports(self, context, - system_metadata, - requested_networks): + def create_resource_requests(self, context, requested_networks, + pci_requests): pass if cls is None: diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index aa9de6d0c8fd..995d5ca08e0b 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -219,7 +219,7 @@ class _ComputeAPIUnitTestMixIn(object): port_id=port)]) with mock.patch.object(self.compute_api.network_api, - 'create_pci_requests_for_sriov_ports'): + 'create_resource_requests'): self.compute_api.create(self.context, instance_type, 'image_id', requested_networks=requested_networks, max_count=None) diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py index 00c1c17eaa55..972332ef2593 100644 --- a/nova/tests/unit/network/test_neutronv2.py +++ b/nova/tests/unit/network/test_neutronv2.py @@ -4902,8 +4902,8 @@ class TestNeutronv2WithMock(test.TestCase): self.assertTrue(mock_log.called) @mock.patch.object(neutronapi, 'get_client') - def test_create_pci_requests_for_sriov_ports_no_allocate(self, getclient): - """Tests that create_pci_requests_for_sriov_ports is a noop if + def test_create_resource_requests_no_allocate(self, getclient): + """Tests that create_resource_requests is a noop if networks are specifically requested to not be allocated. """ requested_networks = objects.NetworkRequestList(objects=[ @@ -4911,14 +4911,14 @@ class TestNeutronv2WithMock(test.TestCase): ]) pci_requests = objects.InstancePCIRequests() api = neutronapi.API() - api.create_pci_requests_for_sriov_ports( - self.context, pci_requests, requested_networks) + api.create_resource_requests( + self.context, requested_networks, pci_requests) self.assertFalse(getclient.called) @mock.patch.object(neutronapi.API, '_get_physnet_info') @mock.patch.object(neutronapi.API, "_get_port_vnic_info") @mock.patch.object(neutronapi, 'get_client') - def test_create_pci_requests_for_sriov_ports(self, getclient, + def test_create_resource_requests(self, getclient, mock_get_port_vnic_info, mock_get_physnet_info): requested_networks = objects.NetworkRequestList( objects = [ @@ -4943,8 +4943,8 @@ class TestNeutronv2WithMock(test.TestCase): ] api = neutronapi.API() - api.create_pci_requests_for_sriov_ports( - self.context, pci_requests, requested_networks) + api.create_resource_requests( + self.context, requested_networks, pci_requests) self.assertEqual(5, len(pci_requests.requests)) has_pci_request_id = [net.pci_request_id is not None for net in