本文整理汇总了Python中neutron_lib.api.definitions.portbindings.HOST_ID属性的典型用法代码示例。如果您正苦于以下问题:Python portbindings.HOST_ID属性的具体用法?Python portbindings.HOST_ID怎么用?Python portbindings.HOST_ID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类neutron_lib.api.definitions.portbindings
的用法示例。
在下文中一共展示了portbindings.HOST_ID属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_flow_classifier_precommit
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_create_flow_classifier_precommit(self):
with self.port(
name='port1',
device_owner='compute',
device_id='test',
arg_list=(
portbindings.HOST_ID,
),
**{portbindings.HOST_ID: 'test'}
) as src_port:
with self.flow_classifier(flow_classifier={
'name': 'test1',
'logical_source_port': src_port['port']['id']
}) as fc:
fc_context = fc_ctx.FlowClassifierContext(
self.flowclassifier_plugin, self.ctx,
fc['flow_classifier']
)
self.driver.create_flow_classifier_precommit(fc_context)
示例2: _create_scenario_test_ports
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def _create_scenario_test_ports(self, tenant_id, port_configs):
ports = []
for item in port_configs:
port_data = {
'port': {'name': 'test1',
'network_id': item['net_id'],
'tenant_id': tenant_id,
'admin_state_up': True,
'device_id': _uuid(),
'device_owner': 'compute:nova',
'mac_address': n_const.ATTR_NOT_SPECIFIED,
'fixed_ips': n_const.ATTR_NOT_SPECIFIED,
portbindings.HOST_ID: item['host']}}
port = self.plugin.create_port(self.context, port_data)
ports.append(port)
return ports
示例3: test_create_mido_portbinding_no_host_binding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_create_mido_portbinding_no_host_binding(self):
# Create a binding when there is no host binding.
# ML2 allows it and makes the port UNBOUND.
# (Unlike midonet_v2, where it fails with 400.)
with self.network() as net:
args = {'port': {'tenant_id': net['network']['tenant_id'],
'network_id': net['network']['id'],
portbindings.PROFILE:
{'interface_name': 'if_name'},
portbindings.HOST_ID: None}}
req = self.new_create_request('ports', args, self.fmt)
res = req.get_response(self.api)
self.assertEqual(201, res.status_int)
result = self.deserialize(self.fmt, res)
self.assertDictSupersetOf({
portbindings.PROFILE: {'interface_name': 'if_name'},
portbindings.VIF_TYPE: portbindings.VIF_TYPE_UNBOUND,
}, result['port'])
示例4: test_create_mido_portbinding_no_interface
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_create_mido_portbinding_no_interface(self):
# Create binding with no interface name.
# ML2 allows it.
# (Unlike midonet_v2, where a non empty profile should always have
# a valid interface_name and otherwise fails with 400.)
with self.network() as net:
args = {'port': {'tenant_id': net['network']['tenant_id'],
'network_id': net['network']['id'],
portbindings.PROFILE: {'foo': ''},
portbindings.HOST_ID: 'host'}}
req = self.new_create_request('ports', args, self.fmt)
res = req.get_response(self.api)
self.assertEqual(201, res.status_int)
result = self.deserialize(self.fmt, res)
self.assertDictSupersetOf({
portbindings.PROFILE: {'foo': ''},
portbindings.VIF_TYPE: m_const.VIF_TYPE_MIDONET,
}, result['port'])
示例5: test_bagpipe_callback_to_rpc_deleted_ignore_external_net
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_bagpipe_callback_to_rpc_deleted_ignore_external_net(self):
with self.subnet(network=self.external_net) as subnet, \
self.port(subnet=subnet,
arg_list=(portbindings.HOST_ID,),
**{portbindings.HOST_ID: helpers.HOST}) as port:
self._update_port_status(port, const.PORT_STATUS_DOWN)
self.mock_attach_rpc.reset_mock()
self.mock_detach_rpc.reset_mock()
self.bagpipe_driver.registry_port_deleted(
None, None, None,
context=self.ctxt,
port_id=port['port']['id']
)
self.assertFalse(self.mock_attach_rpc.called)
self.assertFalse(self.mock_detach_rpc.called)
示例6: test_delete_port_to_bgpvpn_rpc
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_delete_port_to_bgpvpn_rpc(self):
with self.network() as net, \
self.subnet(network=net) as subnet, \
self.port(subnet=subnet,
arg_list=(portbindings.HOST_ID,),
**{portbindings.HOST_ID: helpers.HOST}) as port, \
mock.patch.object(self.plugin, 'get_port',
return_value=port['port']), \
mock.patch.object(self.plugin, 'get_network',
return_value=net['network']):
self.plugin.delete_port(self.ctxt, port['port']['id'])
self.mock_detach_rpc.assert_called_once_with(
mock.ANY,
self._build_expected_return_down(port['port']),
helpers.HOST)
示例7: port_callback
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def port_callback(self, resource, event, trigger, **kwargs):
if event != events.AFTER_UPDATE:
return
original_port = kwargs['original_port']
updated_port = kwargs['port']
if not updated_port.get('fixed_ips'):
return
original_host = original_port.get(portbindings.HOST_ID)
updated_host = updated_port.get(portbindings.HOST_ID)
device_owner = updated_port.get('device_owner')
# if host in the port binding has changed, update next-hops
if original_host != updated_host and bool('compute:' in device_owner):
ctx = context.get_admin_context()
with ctx.session.begin(subtransactions=True):
ext_nets = self.get_external_networks_for_port(ctx,
updated_port)
for ext_net in ext_nets:
bgp_speakers = (
self._get_bgp_speaker_ids_by_binding_network(
ctx, ext_nets))
# Refresh any affected BGP speakers
for bgp_speaker in bgp_speakers:
routes = self.get_advertised_routes(ctx, bgp_speaker)
self.start_route_advertisements(ctx, self._bgp_rpc,
bgp_speaker, routes)
示例8: _get_ip_details
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def _get_ip_details(self, context, port):
host = port[portbindings.HOST_ID]
if (not host and
(port['device_owner'] == n_const.DEVICE_OWNER_DVR_INTERFACE)):
return self._get_l3_dvr_agent_details(context, port)
agent = self._get_agent_details(context, host)
conf_dict = agent.get("configurations")
dst_ip = conf_dict.get("tunneling_ip")
fixed_ip_list = port.get('fixed_ips')
fixed_ip_list = fixed_ip_list[0]
return dst_ip, fixed_ip_list.get('ip_address')
示例9: _get_agent_by_mac
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def _get_agent_by_mac(self, context, mac):
host = None
mac_addr = mac.get('mac')
port = self._get_port_by_mac(context, mac_addr)
for port_dict in port:
host = port_dict[portbindings.HOST_ID]
agent_l2_pop_enabled = self._get_agent_details_by_host(context, host)
return agent_l2_pop_enabled
示例10: _call_before_port_binding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def _call_before_port_binding(self, host):
kwargs = {
'context': mock.Mock(),
'port': {
portbindings.HOST_ID: host
}
}
registry.notify(resources.PORT, events.BEFORE_CREATE, self.ml2_plugin,
**kwargs)
示例11: before_port_binding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def before_port_binding(self, resource, event, trigger, **kwargs):
LOG.debug("before_port resource %s event %s %s",
resource, event, kwargs)
assert resource == resources.PORT
assert event in [events.BEFORE_CREATE, events.BEFORE_UPDATE]
ml2_plugin = trigger
context = kwargs['context']
port = kwargs['port']
host = nl_const.ATTR_NOT_SPECIFIED
if port and portbindings.HOST_ID in port:
host = port.get(portbindings.HOST_ID)
if host == nl_const.ATTR_NOT_SPECIFIED or not host:
return
agent_type = PseudoAgentDBBindingWorker.L2_TYPE
if self._worker.known_agent(host, agent_type):
return
agents = ml2_plugin.get_agents(
context, filters={'agent_type': [agent_type], 'host': [host]})
if agents and all(agent['alive'] for agent in agents):
self._worker.add_known_agents(agents)
LOG.debug("agents %s", agents)
return
# This host may not be created/updated by worker.
# try to populate it.
urlpath = "hostconfig/{0}/{1}".format(
host, PseudoAgentDBBindingWorker.L2_TYPE)
try:
response = self.odl_rest_client.get(urlpath)
response.raise_for_status()
except Exception:
LOG.warning("REST/GET odl hostconfig/%s failed.", host,
exc_info=True)
return
LOG.debug("response %s", response.json())
hostconfig = response.json().get('hostconfig', [])
if hostconfig:
self._worker.update_agents_db_row(hostconfig[0])
示例12: port_with_binding_profile
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def port_with_binding_profile(self, host='host', if_name='if_name'):
args = {portbindings.PROFILE: {'interface_name': if_name},
portbindings.HOST_ID: host}
with test_plugin.optional_ctx(None, self.subnet) as subnet_to_use:
net_id = subnet_to_use['subnet']['network_id']
port = self._make_port(self.fmt, net_id,
arg_list=(portbindings.PROFILE,
portbindings.HOST_ID,), **args)
yield port
示例13: test_create_mido_portbinding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_create_mido_portbinding(self):
keys = {portbindings.PROFILE: {'interface_name': 'if_name'},
portbindings.HOST_ID: 'host'}
with self.port_with_binding_profile() as port:
self.assertDictSupersetOf(keys, port['port'])
示例14: test_show_mido_portbinding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_show_mido_portbinding(self):
keys = {portbindings.PROFILE: {'interface_name': 'if_name'},
portbindings.HOST_ID: 'host'}
with self.port_with_binding_profile() as port:
self.assertDictSupersetOf(keys, port['port'])
req = self.new_show_request('ports', port['port']['id'])
res = self.deserialize(self.fmt, req.get_response(self.api))
self.assertDictSupersetOf(keys, res['port'])
示例15: test_update_mido_portbinding
# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import HOST_ID [as 别名]
def test_update_mido_portbinding(self):
keys = {portbindings.HOST_ID: 'host2',
portbindings.PROFILE: {'interface_name': 'if_name2'},
'admin_state_up': False,
'name': 'test_port2'}
with self.port_with_binding_profile() as port:
args = {
'port': {portbindings.PROFILE: {'interface_name': 'if_name2'},
portbindings.HOST_ID: 'host2',
'admin_state_up': False,
'name': 'test_port2'}}
req = self.new_update_request('ports', args, port['port']['id'])
res = self.deserialize(self.fmt, req.get_response(self.api))
self.assertDictSupersetOf(keys, res['port'])