Exemple #1
0
    def can_be_trunked(self, context):
        """"Return true if a port can be trunked."""
        if not self.is_bound(context):
            # An unbound port can be trunked, always.
            return True

        trunk_plugin = directory.get_plugin('trunk')
        vif_type = self._port.get(portbindings.VIF_TYPE)
        binding_host = self._port.get(portbindings.HOST_ID)

        # Determine the driver that will be in charge of the trunk: this
        # can be determined based on the vif type, whether or not the
        # driver is agent-based, and whether the host is running the agent
        # associated to the driver itself.
        host_agent_types = utils.get_agent_types_by_host(context, binding_host)
        drivers = [
            driver for driver in trunk_plugin.registered_drivers
            if utils.is_driver_compatible(
                context, driver, vif_type, host_agent_types)
        ]
        if len(drivers) > 1:
            raise trunk_exc.TrunkPluginDriverConflict()
        elif len(drivers) == 1:
            return drivers[0].can_trunk_bound_port
        else:
            return False
Exemple #2
0
    def can_be_trunked(self, context):
        """"Return true if a port can be trunked."""
        if not self.is_bound(context):
            # An unbound port can be trunked, always.
            return True

        trunk_plugin = directory.get_plugin('trunk')
        vif_type = self._port.get(portbindings.VIF_TYPE)
        binding_host = self._port.get(portbindings.HOST_ID)

        # Determine the driver that will be in charge of the trunk: this
        # can be determined based on the vif type, whether or not the
        # driver is agent-based, and whether the host is running the agent
        # associated to the driver itself.
        host_agent_types = utils.get_agent_types_by_host(context, binding_host)
        drivers = [
            driver for driver in trunk_plugin.registered_drivers
            if utils.is_driver_compatible(
                context, driver, vif_type, host_agent_types)
        ]
        if len(drivers) > 1:
            raise trunk_exc.TrunkPluginDriverConflict()
        elif len(drivers) == 1:
            return drivers[0].can_trunk_bound_port
        else:
            return False
Exemple #3
0
 def _test_is_driver_compatible(self, driver, interface, host, agents=None):
     with mock.patch("neutron.db.agents_db.AgentDbMixin.get_agents") as f:
         f.return_value = agents or []
         return utils.is_driver_compatible(self.context,
                                           driver,
                                           interface,
                                           host)
Exemple #4
0
 def _test_is_driver_compatible(self, driver, interface, agent_types):
     return utils.is_driver_compatible(self.context, driver, interface,
                                       agent_types)
Exemple #5
0
 def _test_is_driver_compatible(self, driver, interface, agent_types):
     return utils.is_driver_compatible(self.context, driver, interface, agent_types)
Exemple #6
0
 def _test_is_driver_compatible(self, driver, interface, host, agents=None):
     with mock.patch("neutron.db.agents_db.AgentDbMixin.get_agents") as f:
         f.return_value = agents or []
         return utils.is_driver_compatible(self.context, driver, interface,
                                           host)