Update detach/attach to handle sriov macvtap

The vendor/product ID's used when attaching a SR-IOV interface to a
guest with macvtap will be different then when using direct or
direct-physical. Update the test to add an option for virtio
vendor/product that can correctly match the ID's that will be in the
guest.

Change-Id: I26e2eea0d173e975abf5f0baa76cb3c65201a078
This commit is contained in:
jamepark4 2024-07-22 11:04:08 -04:00
parent df1d9f764e
commit 66f6c71cd0
2 changed files with 26 additions and 8 deletions

View File

@ -855,12 +855,12 @@ class SRIOVAttachAndDetach(SRIOVBase):
return port return port
def _check_device_in_guest(self, linux_client, product_id): def _check_device_in_guest(self, linux_client, vendor_id, product_id):
"""Check attached SR-IOV NIC is present in guest """Check attached SR-IOV NIC is present in guest
""" """
vendor = CONF.whitebox_hardware.sriov_nic_vendor_id cmd = "lspci -nn | grep {0}:{1} | wc -l".format(
cmd = "lspci -nn | grep {0}:{1} | wc -l".format(vendor, product_id) vendor_id, product_id)
sys_out = linux_client.exec_command(cmd) sys_out = linux_client.exec_command(cmd)
self.assertIsNotNone( self.assertIsNotNone(
sys_out, 'Unable to find vendor id %s when checking the guest' % sys_out, 'Unable to find vendor id %s when checking the guest' %
@ -959,6 +959,13 @@ class SRIOVAttachAndDetach(SRIOVBase):
vnic_type=vnic_type vnic_type=vnic_type
) )
if vnic_type == 'macvtap':
vendor_id = CONF.whitebox_hardware.macvtap_virtio_vendor_id
product_id = CONF.whitebox_hardware.macvtap_virtio_product_id
else:
vendor_id = CONF.whitebox_hardware.sriov_nic_vendor_id
product_id = CONF.whitebox_hardware.sriov_vf_product_id
# Iterate over both servers, attaching the sr-iov port, checking the # Iterate over both servers, attaching the sr-iov port, checking the
# the attach was successful from an API, XML, and guest level and # the attach was successful from an API, XML, and guest level and
# then detach the interface from the guest # then detach the interface from the guest
@ -986,9 +993,7 @@ class SRIOVAttachAndDetach(SRIOVBase):
self.vlan_id) self.vlan_id)
# Confirm the vendor and vf product id are present in the guest # Confirm the vendor and vf product id are present in the guest
self._check_device_in_guest( self._check_device_in_guest(linux_client, vendor_id, product_id)
linux_client,
CONF.whitebox_hardware.sriov_vf_product_id)
# Validate the port mappings are correct in the nova DB # Validate the port mappings are correct in the nova DB
self._verify_neutron_port_binding( self._verify_neutron_port_binding(
@ -1000,14 +1005,18 @@ class SRIOVAttachAndDetach(SRIOVBase):
self.wait_for_port_detach(port['port']['id']) self.wait_for_port_detach(port['port']['id'])
@testtools.skipUnless(CONF.whitebox_hardware.sriov_vf_product_id, @testtools.skipUnless(CONF.whitebox_hardware.sriov_vf_product_id,
"Requires sriov NIC's VF Prodcut ID")
@testtools.skipUnless(CONF.whitebox_hardware.sriov_nic_vendor_id,
"Requires sriov NIC's VF ID") "Requires sriov NIC's VF ID")
def test_sriov_direct_attach_detach_port(self): def test_sriov_direct_attach_detach_port(self):
"""Verify sriov direct port can be attached/detached from live guest """Verify sriov direct port can be attached/detached from live guest
""" """
self._base_test_attach_and_detach_sriov_port(vnic_type='direct') self._base_test_attach_and_detach_sriov_port(vnic_type='direct')
@testtools.skipUnless(CONF.whitebox_hardware.sriov_vf_product_id, @testtools.skipUnless(CONF.whitebox_hardware.macvtap_virtio_product_id,
"Requires sriov NIC's VF ID") "Requires sriov NIC's virtio product ID")
@testtools.skipUnless(CONF.whitebox_hardware.macvtap_virtio_vendor_id,
"Requires sriov NIC's virtio vendor ID")
def test_sriov_macvtap_attach_detach_port(self): def test_sriov_macvtap_attach_detach_port(self):
"""Verify sriov macvtap port can be attached/detached from live guest """Verify sriov macvtap port can be attached/detached from live guest
""" """
@ -1064,6 +1073,7 @@ class SRIOVAttachAndDetach(SRIOVBase):
# are present in the guest # are present in the guest
self._check_device_in_guest( self._check_device_in_guest(
linux_client, linux_client,
CONF.whitebox_hardware.sriov_nic_vendor_id,
CONF.whitebox_hardware.sriov_pf_product_id) CONF.whitebox_hardware.sriov_pf_product_id)
# Confirm the nova db mappings for the port are correct # Confirm the nova db mappings for the port are correct

View File

@ -217,6 +217,14 @@ hardware_opts = [
default=None, default=None,
help='The product/device id of the underlying sriov PF port of the ' help='The product/device id of the underlying sriov PF port of the '
'NIC. An example with Intel would be 1572'), 'NIC. An example with Intel would be 1572'),
cfg.StrOpt(
'macvtap_virtio_vendor_id',
default=None,
help='The vendor id of the virtio interface device'),
cfg.StrOpt(
'macvtap_virtio_product_id',
default=None,
help='The product id of the virtio interface device'),
cfg.ListOpt( cfg.ListOpt(
'smt_hosts', 'smt_hosts',
default=[], default=[],