neutron: pci_request logic considers 'direct-physical' vnic type
Since the following change: If1ab969c2002c649a3d51635ca2765c262e2d37f Neutron supports this vnic type, which ties in with the work that enabled PF passthrough. This patch makes sure to properly translate the 'direct-physical' vnic-type port from Neutron to a request for a PF. Change-Id: I51af36fc2edca3404a8f9efb32462f3680944be1 Partially-Implements: sriov-pf-passthrough-neutron-port
This commit is contained in:
parent
281ed64d1a
commit
969a0c5a30
@ -96,7 +96,8 @@ VNIC_TYPE_MACVTAP = 'macvtap'
|
||||
VNIC_TYPE_DIRECT_PHYSICAL = 'direct-physical'
|
||||
VNIC_TYPE_BAREMETAL = 'baremetal'
|
||||
|
||||
VNIC_TYPES_SRIOV = (VNIC_TYPE_DIRECT, VNIC_TYPE_MACVTAP)
|
||||
VNIC_TYPES_SRIOV = (VNIC_TYPE_DIRECT, VNIC_TYPE_MACVTAP,
|
||||
VNIC_TYPE_DIRECT_PHYSICAL)
|
||||
|
||||
# Constants for the 'vif_model' values
|
||||
VIF_MODEL_VIRTIO = 'virtio'
|
||||
|
@ -1069,9 +1069,13 @@ class API(base_api.NetworkAPI):
|
||||
context, neutron, request_net.port_id)
|
||||
pci_request_id = None
|
||||
if vnic_type in network_model.VNIC_TYPES_SRIOV:
|
||||
spec = {pci_request.PCI_NET_TAG: phynet_name}
|
||||
dev_type = pci_request.DEVICE_TYPE_FOR_VNIC_TYPE.get(vnic_type)
|
||||
if dev_type:
|
||||
spec[pci_request.PCI_DEVICE_TYPE_TAG] = dev_type
|
||||
request = objects.InstancePCIRequest(
|
||||
count=1,
|
||||
spec=[{pci_request.PCI_NET_TAG: phynet_name}],
|
||||
spec=[spec],
|
||||
request_id=str(uuid.uuid4()))
|
||||
pci_requests.requests.append(request)
|
||||
pci_request_id = request.request_id
|
||||
|
@ -45,11 +45,18 @@ import six
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.network import model as network_model
|
||||
from nova import objects
|
||||
from nova.objects import fields as obj_fields
|
||||
from nova.pci import utils
|
||||
|
||||
PCI_NET_TAG = 'physical_network'
|
||||
PCI_DEVICE_TYPE_TAG = 'dev_type'
|
||||
|
||||
DEVICE_TYPE_FOR_VNIC_TYPE = {
|
||||
network_model.VNIC_TYPE_DIRECT_PHYSICAL: obj_fields.PciDeviceType.SRIOV_PF
|
||||
}
|
||||
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
@ -2926,20 +2926,24 @@ class TestNeutronv2(TestNeutronv2Base):
|
||||
objects.NetworkRequest(network_id='net1'),
|
||||
objects.NetworkRequest(port_id='my_portid2'),
|
||||
objects.NetworkRequest(port_id='my_portid3'),
|
||||
objects.NetworkRequest(port_id='my_portid4')])
|
||||
objects.NetworkRequest(port_id='my_portid4'),
|
||||
objects.NetworkRequest(port_id='my_portid5')])
|
||||
pci_requests = objects.InstancePCIRequests(requests=[])
|
||||
mock_get_port_vnic_info.side_effect = [
|
||||
(model.VNIC_TYPE_DIRECT, 'phynet1'),
|
||||
(model.VNIC_TYPE_NORMAL, ''),
|
||||
(model.VNIC_TYPE_MACVTAP, 'phynet1'),
|
||||
(model.VNIC_TYPE_MACVTAP, 'phynet2')
|
||||
(model.VNIC_TYPE_MACVTAP, 'phynet2'),
|
||||
(model.VNIC_TYPE_DIRECT_PHYSICAL, 'phynet3')
|
||||
]
|
||||
api.create_pci_requests_for_sriov_ports(
|
||||
None, pci_requests, requested_networks)
|
||||
self.assertEqual(3, len(pci_requests.requests))
|
||||
self.assertEqual(4, len(pci_requests.requests))
|
||||
has_pci_request_id = [net.pci_request_id is not None for net in
|
||||
requested_networks.objects]
|
||||
expected_results = [True, False, False, True, True]
|
||||
self.assertEqual(pci_requests.requests[3].spec[0]["dev_type"],
|
||||
"type-PF")
|
||||
expected_results = [True, False, False, True, True, True]
|
||||
self.assertEqual(expected_results, has_pci_request_id)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user