本文整理汇总了Python中neutron.plugins.mlnx.db.mlnx_db_v2.get_network_binding函数的典型用法代码示例。如果您正苦于以下问题:Python get_network_binding函数的具体用法?Python get_network_binding怎么用?Python get_network_binding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_network_binding函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_network_binding
def test_add_network_binding(self):
with self.network() as network:
TEST_NETWORK_ID = network["network"]["id"]
self.assertIsNone(mlnx_db.get_network_binding(self.session, TEST_NETWORK_ID))
mlnx_db.add_network_binding(self.session, TEST_NETWORK_ID, NET_TYPE, PHYS_NET, 1234)
binding = mlnx_db.get_network_binding(self.session, TEST_NETWORK_ID)
self.assertIsNotNone(binding)
self.assertEqual(binding.network_id, TEST_NETWORK_ID)
self.assertEqual(binding.network_type, NET_TYPE)
self.assertEqual(binding.physical_network, PHYS_NET)
self.assertEqual(binding.segmentation_id, 1234)
示例2: get_device_details
def get_device_details(self, rpc_context, **kwargs):
"""Agent requests device details."""
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
LOG.debug("Device %(device)s details requested from %(agent_id)s",
{'device': device, 'agent_id': agent_id})
plugin = manager.NeutronManager.get_plugin()
port = plugin.get_port_from_device(device)
if port:
binding = db.get_network_binding(db_api.get_session(),
port['network_id'])
entry = {'device': device,
'physical_network': binding.physical_network,
'network_type': binding.network_type,
'segmentation_id': binding.segmentation_id,
'network_id': port['network_id'],
'port_mac': port['mac_address'],
'port_id': port['id'],
'admin_state_up': port['admin_state_up']}
if cfg.CONF.AGENT.rpc_support_old_agents:
entry['vlan_id'] = binding.segmentation_id
new_status = (q_const.PORT_STATUS_ACTIVE if port['admin_state_up']
else q_const.PORT_STATUS_DOWN)
if port['status'] != new_status:
db.set_port_status(port['id'], new_status)
else:
entry = {'device': device}
LOG.debug("%s can not be found in database", device)
return entry
示例3: get_device_details
def get_device_details(self, rpc_context, **kwargs):
"""Agent requests device details."""
agent_id = kwargs.get("agent_id")
device = kwargs.get("device")
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), {"device": device, "agent_id": agent_id})
port = self.get_port_from_device(device)
if port:
binding = db.get_network_binding(db_api.get_session(), port["network_id"])
entry = {
"device": device,
"physical_network": binding.physical_network,
"network_type": binding.network_type,
"segmentation_id": binding.segmentation_id,
"network_id": port["network_id"],
"port_mac": port["mac_address"],
"port_id": port["id"],
"admin_state_up": port["admin_state_up"],
}
if cfg.CONF.AGENT.rpc_support_old_agents:
entry["vlan_id"] = binding.segmentation_id
new_status = q_const.PORT_STATUS_ACTIVE if port["admin_state_up"] else q_const.PORT_STATUS_DOWN
if port["status"] != new_status:
db.set_port_status(port["id"], new_status)
else:
entry = {"device": device}
LOG.debug("%s can not be found in database", device)
return entry
示例4: _extend_port_dict_binding
def _extend_port_dict_binding(self, context, port):
port_binding = db.get_port_profile_binding(context.session,
port['id'])
if port_binding:
port[portbindings.VIF_TYPE] = port_binding.vnic_type
port[portbindings.CAPABILITIES] = {
portbindings.CAP_PORT_FILTER:
'security-group' in self.supported_extension_aliases}
binding = db.get_network_binding(context.session,
port['network_id'])
fabric = binding.physical_network
port[portbindings.PROFILE] = {'physical_network': fabric}
return port
示例5: update_port
def update_port(self, context, port_id, port):
original_port = super(MellanoxEswitchPlugin, self).get_port(context,
port_id)
session = context.session
with session.begin(subtransactions=True):
port = super(MellanoxEswitchPlugin, self).update_port(context,
port_id,
port)
if original_port['admin_state_up'] != port['admin_state_up']:
binding = db.get_network_binding(context.session,
port['network_id'])
self.notifier.port_update(context, port,
binding.physical_network,
binding.network_type,
binding.segmentation_id)
return self._extend_port_dict_binding(context, port)
示例6: get_device_details
def get_device_details(self, rpc_context, **kwargs):
"""Agent requests device details."""
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
LOG.debug("Device %s details requested from %s", device, agent_id)
port = self.get_port_from_device(device)
if port:
binding = db.get_network_binding(db_api.get_session(),
port['network_id'])
entry = {'device': device,
'physical_network': binding.physical_network,
'network_type': binding.network_type,
'vlan_id': binding.segmentation_id,
'network_id': port['network_id'],
'port_mac': port['mac_address'],
'port_id': port['id'],
'admin_state_up': port['admin_state_up']}
# Set the port status to UP
db.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE)
else:
entry = {'device': device}
LOG.debug("%s can not be found in database", device)
return entry