本文整理匯總了Python中neutron_lib.plugins.directory.get_plugin方法的典型用法代碼示例。如果您正苦於以下問題:Python directory.get_plugin方法的具體用法?Python directory.get_plugin怎麽用?Python directory.get_plugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neutron_lib.plugins.directory
的用法示例。
在下文中一共展示了directory.get_plugin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_fcs_by_ids
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def _get_fcs_by_ids(self, fc_ids):
flow_classifiers = []
if not fc_ids:
return flow_classifiers
# Get the portchain flow classifiers
fc_plugin = (
directory.get_plugin(flowclassifier.FLOW_CLASSIFIER_EXT)
)
if not fc_plugin:
LOG.warning("Not found the flow classifier service plugin")
return flow_classifiers
for fc_id in fc_ids:
fc = fc_plugin.get_flow_classifier(self.admin_context, fc_id)
flow_classifiers.append(fc)
return flow_classifiers
示例2: validate_l2_gateway_connection_for_create
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def validate_l2_gateway_connection_for_create(self, context,
l2_gateway_connection):
self._admin_check(context, 'CREATE')
gw_connection = l2_gateway_connection[self.connection_resource]
l2_gw_id = gw_connection.get('l2_gateway_id')
network_id = gw_connection.get('network_id')
plugin = directory.get_plugin()
plugin.get_network(context, network_id)
nw_map = {}
nw_map['network_id'] = network_id
nw_map['l2_gateway_id'] = l2_gw_id
segmentation_id = ""
if constants.SEG_ID in gw_connection:
segmentation_id = gw_connection.get(constants.SEG_ID)
nw_map[constants.SEG_ID] = segmentation_id
is_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(context,
l2_gw_id)
network_id = l2gw_validators.validate_network_mapping_list(nw_map,
is_vlan)
with context.session.begin(subtransactions=True):
if self._retrieve_gateway_connections(context,
l2_gw_id,
nw_map):
raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
gateway_id=l2_gw_id)
示例3: handle_subnet_delete_event
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def handle_subnet_delete_event(self, resource, event, trigger,
context=None, operation=None, row=None,
**kwargs):
subnet = kwargs['subnet']
if event == constants.AFTER_DELETE:
try:
plugin = directory.get_plugin()
network_id = subnet['network_id']
device_id = constants.ODL_DEVICE_ID_START + '-' + subnet['id']
filters = {
'network_id': [network_id],
'device_id': [device_id],
'device_owner': [n_const.DEVICE_OWNER_DHCP]
}
LOG.debug("Retrieving ODL DHCP port for deleted subnet %s",
subnet['id'])
ports = plugin.get_ports(context, filters=filters)
if ports:
self._delete_port_if_dhcp(plugin, context, ports[0])
except Exception as e:
LOG.error("Error while deleting %s subnet %s: %s", operation,
subnet['id'], e)
示例4: test_trunk_subports_set_status_create_parent_down
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def test_trunk_subports_set_status_create_parent_down(
self, mock_set_subport_status):
resource = resources.SUBPORTS
event_type = events.AFTER_CREATE
fake_payload = self._fake_trunk_payload()
core_plugin = directory.get_plugin()
fake_payload.subports = [models.SubPort(port_id='fake_port_id',
segmentation_id=101,
segmentation_type='vlan',
trunk_id='fake_id')]
parent_port = FAKE_PARENT.copy()
parent_port['status'] = n_const.PORT_STATUS_DOWN
with mock.patch.object(core_plugin, '_get_port') as gp:
gp.return_value = parent_port
self.handler.trunk_subports_set_status(resource, event_type,
mock.ANY, fake_payload)
mock_set_subport_status.assert_called_once_with(
core_plugin, mock.ANY, 'fake_port_id',
n_const.PORT_STATUS_DOWN)
示例5: test_trunk_subports_update_status_parent_down_to_active
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def test_trunk_subports_update_status_parent_down_to_active(
self, mock_set_subport_status, mock_get_subports_ids):
resource = resources.PORT
event_type = events.AFTER_UPDATE
core_plugin = directory.get_plugin()
port = FAKE_PARENT.copy()
original_port = FAKE_PARENT.copy()
original_port['status'] = n_const.PORT_STATUS_DOWN
port_kwargs = {'port': port, 'original_port': original_port}
mock_get_subports_ids.return_value = ['fake_port_id']
self.handler.trunk_subports_update_status(resource, event_type,
mock.ANY, **port_kwargs)
mock_set_subport_status.assert_called_once_with(
core_plugin, mock.ANY, 'fake_port_id', n_const.PORT_STATUS_ACTIVE)
示例6: test_trunk_subports_update_status_parent_active_to_down
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def test_trunk_subports_update_status_parent_active_to_down(
self, mock_set_subport_status, mock_get_subports_ids):
resource = resources.PORT
event_type = events.AFTER_UPDATE
core_plugin = directory.get_plugin()
port = FAKE_PARENT.copy()
original_port = FAKE_PARENT.copy()
port['status'] = n_const.PORT_STATUS_DOWN
port_kwargs = {'port': port, 'original_port': original_port}
mock_get_subports_ids.return_value = ['fake_port_id']
self.handler.trunk_subports_update_status(resource, event_type,
mock.ANY, **port_kwargs)
mock_set_subport_status.assert_called_once_with(
core_plugin, mock.ANY, 'fake_port_id', n_const.PORT_STATUS_DOWN)
示例7: setUp
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def setUp(self):
self.cfg = self.useFixture(config_fixture.Config())
self.cfg.config(core_plugin='neutron.plugins.ml2.plugin.Ml2Plugin')
self.cfg.config(mechanism_drivers=[
'logger', 'opendaylight_v2'], group='ml2')
self.useFixture(odl_base.OpenDaylightRestClientFixture())
self.cfg.config(service_plugins=['odl-router_v2'])
core_plugin = cfg.CONF.core_plugin
service_plugins = {'l3_plugin_name': 'odl-router_v2'}
self.useFixture(odl_base.OpenDaylightJournalThreadFixture())
mock.patch.object(mech_driver_v2.OpenDaylightMechanismDriver,
'_record_in_journal').start()
mock.patch.object(mech_driver_v2.OpenDaylightMechanismDriver,
'sync_from_callback_precommit').start()
mock.patch.object(mech_driver_v2.OpenDaylightMechanismDriver,
'sync_from_callback_postcommit').start()
self.useFixture(odl_base.OpenDaylightPeriodicTaskFixture())
self.useFixture(odl_base.OpenDaylightFeaturesFixture())
self.useFixture(odl_base.OpenDaylightPseudoAgentPrePopulateFixture())
super(OpenDaylightL3TestCase, self).setUp(
plugin=core_plugin, service_plugins=service_plugins)
self.plugin = directory.get_plugin()
self.plugin._network_is_external = mock.Mock(return_value=True)
self.driver = directory.get_plugin(constants.L3)
self.thread = journal.OpenDaylightJournalThread()
示例8: get_network_and_subnet_context
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def get_network_and_subnet_context(self, cidr, dhcp_flag, create_subnet,
create_network, ipv4=True):
data = {}
network_id = uuidutils.generate_uuid()
subnet_id = uuidutils.generate_uuid()
plugin = directory.get_plugin()
data['network_id'] = network_id
data['subnet_id'] = subnet_id
data['context'] = self.context
data['plugin'] = plugin
network, network_context = \
self.get_network_context(network_id, create_network, ipv4)
if create_network:
data['network_context'] = network_context
data['network'] = network
subnet, subnet_context = \
self.get_subnet_context(network_id, subnet_id, cidr,
dhcp_flag, create_subnet, ipv4)
if create_subnet:
data['subnet_context'] = subnet_context
data['subnet'] = subnet
return data
示例9: get_network_context
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def get_network_context(self, network_id, create_network, ipv4=True):
netwrk = 'netv4'
if not ipv4:
netwrk = 'netv6'
current = {'status': 'ACTIVE',
'subnets': [],
'name': netwrk,
'provider:physical_network': None,
'admin_state_up': True,
'tenant_id': ODL_TENANT_ID,
'project_id': ODL_TENANT_ID,
'provider:network_type': 'local',
'router:external': False,
'shared': False,
'id': network_id,
'provider:segmentation_id': None}
network = {'network': AttributeDict(current)}
if create_network:
plugin = directory.get_plugin()
result, network_context = plugin._create_network_db(
self.context, network)
return [network, network_context]
return network
示例10: _update_agents_db_row
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def _update_agents_db_row(self, host_config):
if self.agents_db is None:
self.agents_db = directory.get_plugin()
# Update one row in agent db
host_id = host_config['host-id']
host_type = host_config['host-type']
config = host_config['config']
try:
agentdb_row = self._AGENTDB_ROW.copy()
agentdb_row['host'] = host_id
agentdb_row['agent_type'] = host_type
agentdb_row['configurations'] = jsonutils.loads(config)
if (host_id, host_type) in self._old_agents:
agentdb_row.pop('start_flag', None)
self.agents_db.create_or_update_agent(
context.get_admin_context(), agentdb_row)
self._known_agents.add((host_id, host_type))
except Exception:
LOG.exception("Unable to update agentdb.")
示例11: add_gateway_network
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def add_gateway_network(self, context, bgp_speaker_id, network_info):
with db_api.CONTEXT_WRITER.using(context):
# TODO(kengo): This validation is temporary workaround
# until upstream adds a validation for
# existing combination of bgp speaker and gateway network.
if self.get_router_associated_with_bgp_speaker(
context, bgp_speaker_id):
raise bsri.BgpSpeakerInUse(
id=bgp_speaker_id,
reason='is already associated with router.')
core_plugin = directory.get_plugin()
if not core_plugin._network_is_external(
context, network_info['network_id']):
raise bsri.NetworkTypeInvalid()
info = super(MidonetBgpPlugin, self).add_gateway_network(
context, bgp_speaker_id, network_info)
self.set_router_for_bgp_speaker_by_network(
context, bgp_speaker_id, network_info['network_id'])
return info
示例12: get_routes_from_extra_routes
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def get_routes_from_extra_routes(self, context, rt_id, nexthops):
"""This method gets routes for extra routes defined on this router.
* 'nexthop' is the IP address of the ports on this router
that are on the same subnet as the peer IP addresses of
the provided bgp speaker.
* 'dests' are all the networks defined as extra routes
on the router.
"""
changed_extra = []
l3plugin = directory.get_plugin(constants.L3)
extra = l3plugin.get_router(context, rt_id,
fields=['routes'])['routes']
dest_networks = [extra_route['destination'] for extra_route in extra]
for nexthop in nexthops:
changed_extra += self._change_nexthop_to_router_ip(nexthop,
dest_networks)
LOG.debug("advertised routes from extra routes: %s", changed_extra)
return changed_extra
示例13: set_router_for_bgp_speaker_by_network
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def set_router_for_bgp_speaker_by_network(self, context,
bgp_sp_id, net_id):
"""This method selects one router to be a bgp speaker.
To pare down routers, only first subnet in specified external
network is used for selection.
REVISIT(Kengo): There may be a case where there are two subnets
and a router is associated with the second subnet. The case is
a restriction for user and should be improved later.
"""
core_plugin = directory.get_plugin()
subnets = core_plugin.get_subnets_by_network(context, net_id)
if not subnets:
raise bsri.NoSubnetInNetwork(network_id=net_id)
if not subnets[0]['gateway_ip']:
raise bsri.NoGatewayIpOnSubnet(subnet_id=subnets[0]['id'])
filters = {'fixed_ips': {'ip_address': [subnets[0]['gateway_ip']],
'subnet_id': [subnets[0]['id']]}}
ports = core_plugin.get_ports(context, filters=filters)
if not ports:
raise bsri.NoGatewayIpPortOnSubnet(subnet_id=subnets[0]['id'])
router_id = ports[0]['device_id']
# If the router is already associated with bgp-speaker,
# RouterInUse will be raised.
self.set_router_for_bgp_speaker(context, bgp_sp_id, router_id)
示例14: setUp
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def setUp(self):
cfg.CONF.set_override('mechanism_drivers',
['logger', 'fake_agent'],
'ml2')
super(TestBagpipeServiceDriverCallbacks, self).setUp(
"%s.%s" % (__name__, TestCorePluginML2WithAgents.__name__))
self.port_create_status = 'DOWN'
self.plugin = directory.get_plugin()
self.plugin.start_rpc_listeners()
self.bagpipe_driver = self.bgpvpn_plugin.driver
self.patched_driver = mock.patch.object(
self.bgpvpn_plugin.driver,
'_retrieve_bgpvpn_network_info_for_port',
return_value=BGPVPN_INFO)
self.patched_driver.start()
# we choose an agent of type const.AGENT_TYPE_OFA
# because this is the type used by the fake_agent mech driver
helpers.register_ovs_agent(helpers.HOST, const.AGENT_TYPE_OFA)
helpers.register_l3_agent()
示例15: registry_router_interface_deleted
# 需要導入模塊: from neutron_lib.plugins import directory [as 別名]
# 或者: from neutron_lib.plugins.directory import get_plugin [as 別名]
def registry_router_interface_deleted(self, resource, event, trigger,
payload=None):
try:
context = payload.context
# for router_interface after_delete, in stable/newton, the
# callback does not include the router_id directly, but we find
# it in the port device_id
router_id = payload.resource_id
subnet_id = payload.metadata['subnet_id']
# find the network for this subnet
network_id = directory.get_plugin().get_subnet(
context, subnet_id)['network_id']
self.notify_router_interface_deleted(
context, router_id, network_id)
except Exception as e:
_log_callback_processing_exception(
resource, event, trigger,
{'subnet_id': subnet_id, 'router_id': router_id}, e)