network: Rename 'create_pci_requests_for_sriov_ports'

In a future change, this function will provide a generic way to get all
resources required due to the requested networks. Get ahead of this by
renaming the function now.

Part of blueprint numa-aware-vswitches

Change-Id: I9d1bb3dfe0f1f5a9d804841c6880c0d6bdcb5c80
This commit is contained in:
Stephen Finucane 2018-06-22 15:51:28 +01:00
parent 2bb9e5563c
commit 2d2700fb9b
8 changed files with 36 additions and 38 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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.

View File

@ -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

View File

@ -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',

View File

@ -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:

View File

@ -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)

View File

@ -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