Merge "Move SR-IOV VIF type constants to the portbindings extension"

This commit is contained in:
Jenkins 2016-11-22 02:15:04 +00:00 committed by Gerrit Code Review
commit 35d780423c
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 # which is defined further below. E.g. Macvtap agent uses
# vnic_type 'normal'. # vnic_type 'normal'.
VIF_TYPE_MACVTAP = 'macvtap' 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 # 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, # 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__) LOG = log.getLogger(__name__)
VIF_TYPE_HW_VEB = 'hw_veb'
VIF_TYPE_HOSTDEV_PHY = 'hostdev_physical'
FLAT_VLAN = 0 FLAT_VLAN = 0
@ -66,9 +64,9 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
self.supported_vnic_types = supported_vnic_types self.supported_vnic_types = supported_vnic_types
# NOTE(ndipanov): PF passthrough requires a different vif type # NOTE(ndipanov): PF passthrough requires a different vif type
self.vnic_type_for_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 if vtype == portbindings.VNIC_DIRECT_PHYSICAL
else VIF_TYPE_HW_VEB else portbindings.VIF_TYPE_HW_VEB
for vtype in self.supported_vnic_types}) for vtype in self.supported_vnic_types})
self.vif_details = vif_details 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): def try_to_bind_segment_for_agent(self, context, segment, agent):
vnic_type = context.current.get(portbindings.VNIC_TYPE, vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_DIRECT) portbindings.VNIC_DIRECT)
vif_type = self.vnic_type_for_vif_type.get(vnic_type, vif_type = self.vnic_type_for_vif_type.get(
VIF_TYPE_HW_VEB) vnic_type, portbindings.VIF_TYPE_HW_VEB)
if not self.check_segment_for_agent(segment, agent): if not self.check_segment_for_agent(segment, agent):
return False return False
port_status = (constants.PORT_STATUS_ACTIVE if agent is None port_status = (constants.PORT_STATUS_ACTIVE if agent is None

View File

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