Merge "Move get_vif_type hook point into mech_agent"
This commit is contained in:
commit
40acf55dc4
@ -169,12 +169,19 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
|
|||||||
def try_to_bind_segment_for_agent(self, context, segment, agent):
|
def try_to_bind_segment_for_agent(self, context, segment, agent):
|
||||||
if self.check_segment_for_agent(segment, agent):
|
if self.check_segment_for_agent(segment, agent):
|
||||||
context.set_binding(segment[api.ID],
|
context.set_binding(segment[api.ID],
|
||||||
self.vif_type,
|
self.get_vif_type(context, agent, segment),
|
||||||
self.vif_details)
|
self.get_vif_details(context, agent, segment))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_vif_details(self, context, agent, segment):
|
||||||
|
return self.vif_details
|
||||||
|
|
||||||
|
def get_vif_type(self, context, agent, segment):
|
||||||
|
"""Return the vif type appropriate for the agent and segment."""
|
||||||
|
return self.vif_type
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_allowed_network_types(self, agent=None):
|
def get_allowed_network_types(self, agent=None):
|
||||||
"""Return the agent's or driver's allowed network types.
|
"""Return the agent's or driver's allowed network types.
|
||||||
|
@ -23,7 +23,6 @@ from oslo_config import cfg
|
|||||||
|
|
||||||
from neutron.agent import securitygroups_rpc
|
from neutron.agent import securitygroups_rpc
|
||||||
from neutron.plugins.common import constants as p_constants
|
from neutron.plugins.common import constants as p_constants
|
||||||
from neutron.plugins.ml2 import driver_api as api
|
|
||||||
from neutron.plugins.ml2.drivers import mech_agent
|
from neutron.plugins.ml2.drivers import mech_agent
|
||||||
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
||||||
import constants as a_const
|
import constants as a_const
|
||||||
@ -69,16 +68,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
|
|||||||
"""Currently Openvswitch driver doesn't support vlan transparency."""
|
"""Currently Openvswitch driver doesn't support vlan transparency."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def try_to_bind_segment_for_agent(self, context, segment, agent):
|
def get_vif_type(self, context, agent, segment):
|
||||||
if self.check_segment_for_agent(segment, agent):
|
|
||||||
context.set_binding(segment[api.ID],
|
|
||||||
self.get_vif_type(agent, context),
|
|
||||||
self.get_vif_details(agent, context))
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_vif_type(self, agent, context):
|
|
||||||
caps = agent['configurations'].get('ovs_capabilities', {})
|
caps = agent['configurations'].get('ovs_capabilities', {})
|
||||||
if (any(x in caps.get('iface_types', []) for x
|
if (any(x in caps.get('iface_types', []) for x
|
||||||
in [a_const.OVS_DPDK_VHOST_USER,
|
in [a_const.OVS_DPDK_VHOST_USER,
|
||||||
@ -96,7 +86,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
|
|||||||
return portbindings.VHOST_USER_MODE_SERVER
|
return portbindings.VHOST_USER_MODE_SERVER
|
||||||
return portbindings.VHOST_USER_MODE_CLIENT
|
return portbindings.VHOST_USER_MODE_CLIENT
|
||||||
|
|
||||||
def get_vif_details(self, agent, context):
|
def get_vif_details(self, context, agent, segment):
|
||||||
vif_details = self._pre_get_vif_details(agent, context)
|
vif_details = self._pre_get_vif_details(agent, context)
|
||||||
self._set_bridge_name(context.current, vif_details)
|
self._set_bridge_name(context.current, vif_details)
|
||||||
return vif_details
|
return vif_details
|
||||||
@ -116,7 +106,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
|
|||||||
|
|
||||||
def _pre_get_vif_details(self, agent, context):
|
def _pre_get_vif_details(self, agent, context):
|
||||||
a_config = agent['configurations']
|
a_config = agent['configurations']
|
||||||
vif_type = self.get_vif_type(agent, context)
|
vif_type = self.get_vif_type(context, agent, segment=None)
|
||||||
if vif_type != portbindings.VIF_TYPE_VHOST_USER:
|
if vif_type != portbindings.VIF_TYPE_VHOST_USER:
|
||||||
details = dict(self.vif_details)
|
details = dict(self.vif_details)
|
||||||
hybrid = portbindings.OVS_HYBRID_PLUG
|
hybrid = portbindings.OVS_HYBRID_PLUG
|
||||||
|
@ -228,11 +228,11 @@ class OpenvswitchMechanismDPDKTestCase(OpenvswitchMechanismBaseTestCase):
|
|||||||
self.assertEqual(portbindings.VHOST_USER_MODE_SERVER, result)
|
self.assertEqual(portbindings.VHOST_USER_MODE_SERVER, result)
|
||||||
|
|
||||||
def test_get_vif_type(self):
|
def test_get_vif_type(self):
|
||||||
result = self.driver.get_vif_type(self.AGENT, None)
|
result = self.driver.get_vif_type(None, self.AGENT, None)
|
||||||
self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)
|
self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)
|
||||||
|
|
||||||
result = self.driver.get_vif_type(self.AGENT_SERVER, None)
|
result = self.driver.get_vif_type(None, self.AGENT_SERVER, None)
|
||||||
self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)
|
self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)
|
||||||
|
|
||||||
result = self.driver.get_vif_type(self.AGENT_SYSTEM, None)
|
result = self.driver.get_vif_type(None, self.AGENT_SYSTEM, None)
|
||||||
self.assertEqual(portbindings.VIF_TYPE_OVS, result)
|
self.assertEqual(portbindings.VIF_TYPE_OVS, result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user