Move SR-IOV VIF type constants to the portbindings extension

While referencing VIF types during the QoS plugin drivers refactor
I noticed that SR-IOV had the VIF type constants defined in the
mech_driver itself, instead of the portbindings extension.

I wanted to make all the VIF type constants available from a single
place instead of scattered.

Change-Id: Iabb7e5e953c4509c39b2029839752b88af87387b
This commit is contained in:
Miguel Angel Ajo 2016-11-17 09:13:28 -05:00
parent d41bed0ee6
commit 299c3f8871
3 changed files with 12 additions and 10 deletions

View File

@ -89,6 +89,9 @@ VIF_TYPE_OTHER = 'other'
# which is defined further below. E.g. Macvtap agent uses
# vnic_type 'normal'.
VIF_TYPE_MACVTAP = 'macvtap'
# SR-IOV VIF types
VIF_TYPE_HW_VEB = 'hw_veb'
VIF_TYPE_HOSTDEV_PHY = 'hostdev_physical'
# VNIC_TYPE: It's used to determine which mechanism driver to use to bind a
# port. It can be specified via the Neutron API. Default is normal,

View File

@ -27,8 +27,6 @@ from neutron.services.qos import qos_consts
LOG = log.getLogger(__name__)
VIF_TYPE_HW_VEB = 'hw_veb'
VIF_TYPE_HOSTDEV_PHY = 'hostdev_physical'
FLAT_VLAN = 0
@ -66,9 +64,9 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
self.supported_vnic_types = supported_vnic_types
# NOTE(ndipanov): PF passthrough requires a different vif type
self.vnic_type_for_vif_type = (
{vtype: VIF_TYPE_HOSTDEV_PHY
{vtype: portbindings.VIF_TYPE_HOSTDEV_PHY
if vtype == portbindings.VNIC_DIRECT_PHYSICAL
else VIF_TYPE_HW_VEB
else portbindings.VIF_TYPE_HW_VEB
for vtype in self.supported_vnic_types})
self.vif_details = vif_details
@ -118,8 +116,9 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def try_to_bind_segment_for_agent(self, context, segment, agent):
vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_DIRECT)
vif_type = self.vnic_type_for_vif_type.get(vnic_type,
VIF_TYPE_HW_VEB)
vif_type = self.vnic_type_for_vif_type.get(
vnic_type, portbindings.VIF_TYPE_HW_VEB)
if not self.check_segment_for_agent(segment, agent):
return False
port_status = (constants.PORT_STATUS_ACTIVE if agent is None

View File

@ -52,7 +52,7 @@ class TestFakePortContext(base.FakePortContext):
class SriovNicSwitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
VIF_TYPE = mech_driver.VIF_TYPE_HW_VEB
VIF_TYPE = portbindings.VIF_TYPE_HW_VEB
CAP_PORT_FILTER = False
AGENT_TYPE = constants.AGENT_TYPE_NIC_SWITCH
VLAN_SEGMENTS = base.AgentMechanismVlanTestCase.VLAN_SEGMENTS
@ -135,15 +135,15 @@ class SriovSwitchMechVnicTypeTestCase(SriovNicSwitchMechanismBaseTestCase):
def test_vnic_type_direct(self):
self._check_vif_type_for_vnic_type(portbindings.VNIC_DIRECT,
mech_driver.VIF_TYPE_HW_VEB)
portbindings.VIF_TYPE_HW_VEB)
def test_vnic_type_macvtap(self):
self._check_vif_type_for_vnic_type(portbindings.VNIC_MACVTAP,
mech_driver.VIF_TYPE_HW_VEB)
portbindings.VIF_TYPE_HW_VEB)
def test_vnic_type_direct_physical(self):
self._check_vif_type_for_vnic_type(portbindings.VNIC_DIRECT_PHYSICAL,
mech_driver.VIF_TYPE_HOSTDEV_PHY)
portbindings.VIF_TYPE_HOSTDEV_PHY)
class SriovSwitchMechVifDetailsTestCase(SriovNicSwitchMechanismBaseTestCase):