本文整理汇总了Python中neutron.plugins.ml2.db.get_port_binding_host函数的典型用法代码示例。如果您正苦于以下问题:Python get_port_binding_host函数的具体用法?Python get_port_binding_host怎么用?Python get_port_binding_host使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_port_binding_host函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dvr_deletens_if_no_port
def dvr_deletens_if_no_port(self, context, port_id):
"""Delete the DVR namespace if no dvr serviced port exists."""
admin_context = context.elevated()
router_ids = self.get_dvr_routers_by_portid(admin_context, port_id)
port_host = ml2_db.get_port_binding_host(port_id)
if not router_ids:
LOG.debug(
"No namespaces available for this DVR port %(port)s " "on host %(host)s",
{"port": port_id, "host": port_host},
)
return []
removed_router_info = []
for router_id in router_ids:
subnet_ids = self.get_subnet_ids_on_router(admin_context, router_id)
port_exists_on_subnet = False
for subnet in subnet_ids:
if self.check_ports_active_on_host_and_subnet(admin_context, port_host, port_id, subnet):
port_exists_on_subnet = True
break
if port_exists_on_subnet:
continue
filter_rtr = {"device_id": [router_id], "device_owner": [q_const.DEVICE_OWNER_DVR_INTERFACE]}
int_ports = self._core_plugin.get_ports(admin_context, filters=filter_rtr)
for prt in int_ports:
dvr_binding = ml2_db.get_dvr_port_binding_by_host(context.session, prt["id"], port_host)
if dvr_binding:
# unbind this port from router
dvr_binding["router_id"] = None
dvr_binding.update(dvr_binding)
agent = self._get_agent_by_type_and_host(context, q_const.AGENT_TYPE_L3, port_host)
info = {"router_id": router_id, "host": port_host, "agent_id": str(agent.id)}
removed_router_info.append(info)
LOG.debug("Router namespace %(router_id)s on host %(host)s " "to be deleted", info)
return removed_router_info
开发者ID:kongseokhwan,项目名称:kulcloud-neutron,代码行数:35,代码来源:l3_dvrscheduler_db.py
示例2: get_dvr_routers_to_remove
def get_dvr_routers_to_remove(self, context, port_id, port_host=None):
"""Returns info about which routers should be removed from <port_host>
In case dvr serviceable port is about to be deleted we need to check
if any dvr routers should be removed from l3 agent on port's host
"""
admin_context = context.elevated()
router_ids = self.get_dvr_routers_by_portid(admin_context, port_id)
if not port_host:
port_host = ml2_db.get_port_binding_host(admin_context.session,
port_id)
if not port_host:
LOG.debug('Host name not found for port %s', port_id)
return []
if not router_ids:
LOG.debug('No DVR routers for this DVR port %(port)s '
'on host %(host)s', {'port': port_id,
'host': port_host})
return []
agent = self._get_agent_by_type_and_host(
context, n_const.AGENT_TYPE_L3, port_host)
removed_router_info = []
for router_id in router_ids:
snat_binding = context.session.query(
l3agent_sch_db.RouterL3AgentBinding).filter_by(
router_id=router_id).filter_by(
l3_agent_id=agent.id).first()
if snat_binding:
# not removing from the agent hosting SNAT for the router
continue
subnet_ids = self.get_subnet_ids_on_router(admin_context,
router_id)
if self.check_dvr_serviceable_ports_on_host(
admin_context, port_host, subnet_ids, except_port=port_id):
continue
filter_rtr = {'device_id': [router_id],
'device_owner':
[n_const.DEVICE_OWNER_DVR_INTERFACE]}
int_ports = self._core_plugin.get_ports(
admin_context, filters=filter_rtr)
for port in int_ports:
dvr_binding = (ml2_db.
get_dvr_port_binding_by_host(context.session,
port['id'],
port_host))
if dvr_binding:
# unbind this port from router
dvr_binding['router_id'] = None
dvr_binding.update(dvr_binding)
info = {'router_id': router_id, 'host': port_host,
'agent_id': str(agent.id)}
removed_router_info.append(info)
LOG.debug('Router %(router_id)s on host %(host)s to be deleted',
info)
return removed_router_info
开发者ID:shooteras,项目名称:neutron,代码行数:57,代码来源:l3_dvrscheduler_db.py
示例3: dvr_deletens_if_no_port
def dvr_deletens_if_no_port(self, context, port_id, port_host=None):
"""Delete the DVR namespace if no dvr serviced port exists."""
admin_context = context.elevated()
router_ids = self.get_dvr_routers_by_portid(admin_context, port_id)
if not port_host:
port_host = ml2_db.get_port_binding_host(admin_context.session,
port_id)
if not port_host:
LOG.debug('Host name not found for port %s', port_id)
return []
if not router_ids:
LOG.debug('No namespaces available for this DVR port %(port)s '
'on host %(host)s', {'port': port_id,
'host': port_host})
return []
removed_router_info = []
for router_id in router_ids:
subnet_ids = self.get_subnet_ids_on_router(admin_context,
router_id)
port_exists_on_subnet = False
for subnet in subnet_ids:
if self.check_ports_on_host_and_subnet(admin_context,
port_host,
port_id,
subnet):
port_exists_on_subnet = True
break
if port_exists_on_subnet:
continue
filter_rtr = {'device_id': [router_id],
'device_owner':
[n_const.DEVICE_OWNER_DVR_INTERFACE]}
int_ports = self._core_plugin.get_ports(
admin_context, filters=filter_rtr)
for port in int_ports:
dvr_binding = (ml2_db.
get_dvr_port_binding_by_host(context.session,
port['id'],
port_host))
if dvr_binding:
# unbind this port from router
dvr_binding['router_id'] = None
dvr_binding.update(dvr_binding)
agent = self._get_agent_by_type_and_host(context,
n_const.AGENT_TYPE_L3,
port_host)
info = {'router_id': router_id, 'host': port_host,
'agent_id': str(agent.id)}
removed_router_info.append(info)
LOG.debug('Router namespace %(router_id)s on host %(host)s '
'to be deleted', info)
return removed_router_info
开发者ID:r0b1n1983liu,项目名称:neutron,代码行数:54,代码来源:l3_dvrscheduler_db.py
示例4: test_get_port_binding_host
def test_get_port_binding_host(self):
network_id = 'foo-network-id'
port_id = 'foo-port-id'
host = 'fake_host'
vif_type = portbindings.VIF_TYPE_UNBOUND
self._setup_neutron_network(network_id)
self._setup_neutron_port(network_id, port_id)
self._setup_neutron_portbinding(port_id, vif_type, host)
port_host = ml2_db.get_port_binding_host(self.ctx.session, port_id)
self.assertEqual(host, port_host)
开发者ID:Blahhhhh,项目名称:neutron,代码行数:11,代码来源:test_db.py
示例5: dvr_deletens_if_no_port
def dvr_deletens_if_no_port(self, context, port_id, port_host=None):
"""Delete the DVR namespace if no dvr serviced port exists."""
admin_context = context.elevated()
router_ids = self.get_dvr_routers_by_portid(admin_context, port_id)
if not port_host:
port_host = ml2_db.get_port_binding_host(admin_context.session,
port_id)
if not port_host:
LOG.debug('Host name not found for port %s', port_id)
return []
if not router_ids:
LOG.debug('No namespaces available for this DVR port %(port)s '
'on host %(host)s', {'port': port_id,
'host': port_host})
return []
agent = self._get_agent_by_type_and_host(
context, n_const.AGENT_TYPE_L3, port_host)
removed_router_info = []
for router_id in router_ids:
snat_binding = context.session.query(
CentralizedSnatL3AgentBinding).filter_by(
router_id=router_id).filter_by(
l3_agent_id=agent.id).first()
if snat_binding:
# not removing from the agent hosting SNAT for the router
continue
subnet_ids = self.get_subnet_ids_on_router(admin_context,
router_id)
if self.check_dvr_serviceable_ports_on_host(
admin_context, port_host, subnet_ids, except_port=port_id):
continue
filter_rtr = {'device_id': [router_id],
'device_owner':
[n_const.DEVICE_OWNER_DVR_INTERFACE]}
int_ports = self._core_plugin.get_ports(
admin_context, filters=filter_rtr)
for port in int_ports:
dvr_binding = (ml2_db.
get_dvr_port_binding_by_host(context.session,
port['id'],
port_host))
if dvr_binding:
# unbind this port from router
dvr_binding['router_id'] = None
dvr_binding.update(dvr_binding)
info = {'router_id': router_id, 'host': port_host,
'agent_id': str(agent.id)}
removed_router_info.append(info)
LOG.debug('Router namespace %(router_id)s on host %(host)s '
'to be deleted', info)
return removed_router_info
开发者ID:RustShen,项目名称:neutron,代码行数:53,代码来源:l3_dvrscheduler_db.py
示例6: test_get_port_binding_host_multiple_results_found
def test_get_port_binding_host_multiple_results_found(self):
network_id = 'foo-network-id'
port_id = 'foo-port-id'
port_id_one = 'foo-port-id-one'
port_id_two = 'foo-port-id-two'
host = 'fake_host'
vif_type = portbindings.VIF_TYPE_UNBOUND
self._setup_neutron_network(network_id)
self._setup_neutron_port(network_id, port_id_one)
self._setup_neutron_portbinding(port_id_one, vif_type, host)
self._setup_neutron_port(network_id, port_id_two)
self._setup_neutron_portbinding(port_id_two, vif_type, host)
port_host = ml2_db.get_port_binding_host(self.ctx.session, port_id)
self.assertIsNone(port_host)
开发者ID:Blahhhhh,项目名称:neutron,代码行数:15,代码来源:test_db.py
示例7: port_bound_to_host
def port_bound_to_host(self, context, port_id, host):
try:
port = self.get_port(context, port_id)
if port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE:
bindings = db.get_dvr_port_bindings(port_id)
for b in bindings:
if b.host == host:
return True
LOG.debug("No Binding exists for port %s", port_id)
return False
else:
port_host = db.get_port_binding_host(port_id)
return (port_host == host)
except exc.PortNotFound:
LOG.debug("Port not found %s", port_id)
return False
开发者ID:rossella,项目名称:neutron-dvr,代码行数:16,代码来源:plugin.py
示例8: dvr_deletens_if_no_vm
def dvr_deletens_if_no_vm(self, context, port_id):
"""Delete the DVR namespace if no VM exists."""
router_ids = self.get_dvr_routers_by_vmportid(context, port_id)
port_host = ml2_db.get_port_binding_host(port_id)
if not router_ids:
LOG.debug('No namespaces available for this DVR port %(port)s '
'on host %(host)s', {'port': port_id,
'host': port_host})
return []
removed_router_info = []
for router_id in router_ids:
subnet_ids = self.get_subnet_ids_on_router(context, router_id)
vm_exists_on_subnet = False
for subnet in subnet_ids:
if self.check_vm_exists_on_subnet(context,
port_host,
port_id,
subnet):
vm_exists_on_subnet = True
break
if vm_exists_on_subnet:
continue
filter_rtr = {'device_id': [router_id],
'device_owner':
[q_const.DEVICE_OWNER_DVR_INTERFACE]}
int_ports = self._core_plugin.get_ports(
context, filters=filter_rtr)
for prt in int_ports:
dvr_binding = (ml2_db.
get_dvr_port_binding_by_host(context.session,
prt['id'],
port_host))
if dvr_binding:
# unbind this port from router
dvr_binding['router_id'] = None
dvr_binding.update(dvr_binding)
self.delete_namespace_on_host(context, port_host, router_id)
info = {'router_id': router_id, 'host': port_host}
removed_router_info.append(info)
LOG.debug('Deleted router namespace %(router_id)s '
'on host %(host)s', info)
return removed_router_info
开发者ID:hichihara,项目名称:neutron,代码行数:43,代码来源:l3_dvrscheduler_db.py
示例9: _get_host_from_qos_id
def _get_host_from_qos_id(self, context, qos_id):
qos = self._get_qos(context, qos_id)
if qos['router_id'] is not None:
plugin = manager.NeutronManager.get_service_plugins().get(
service_constants.L3_ROUTER_NAT)
adminContext = context if context.is_admin else context.elevated()
l3_agents = plugin.get_l3_agents_hosting_routers(
adminContext, [qos['router_id']],
admin_state_up=True, active=True)
return l3_agents[0].host
elif qos['port_id'] is not None:
"""
plugin = manager.NeutronManager.get_plugin()
adminContext = context if context.is_admin else context.elevated()
return plugin.get_port_binding_host(adminContext, qos['port_id'])
"""
return db.get_port_binding_host(qos['port_id'])
else:
return None
开发者ID:chenyanfun,项目名称:neutron-qos,代码行数:19,代码来源:qos_rpc.py
示例10: port_bound_to_host
def port_bound_to_host(self, port_id, host):
port_host = db.get_port_binding_host(port_id)
return (port_host == host)
开发者ID:Doude,项目名称:neutron,代码行数:3,代码来源:plugin.py
示例11: test_get_port_binding_host_result_not_found
def test_get_port_binding_host_result_not_found(self):
port_id = uuidutils.generate_uuid()
port_host = ml2_db.get_port_binding_host(self.ctx.session, port_id)
self.assertIsNone(port_host)
开发者ID:Blahhhhh,项目名称:neutron,代码行数:5,代码来源:test_db.py
示例12: get_bindinghost_by_portid
def get_bindinghost_by_portid(self, port_id):
return db.get_port_binding_host(port_id)
开发者ID:joey5678,项目名称:tricircle,代码行数:2,代码来源:plugin.py
注:本文中的neutron.plugins.ml2.db.get_port_binding_host函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论