本文整理汇总了Python中neutron.plugins.nec.db.api.del_portinfo函数的典型用法代码示例。如果您正苦于以下问题:Python del_portinfo函数的具体用法?Python del_portinfo怎么用?Python del_portinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了del_portinfo函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _process_portbindings_portinfo_update
def _process_portbindings_portinfo_update(self, context, port_data, port):
"""Update portinfo according to bindings:profile in update_port().
:param context: neutron api request context
:param port_data: port attributes passed in PUT request
:param port: port attributes to be returned
:returns: 'ADD', 'MOD', 'DEL' or None
"""
if portbindings.PROFILE not in port_data:
return
profile = port_data.get(portbindings.PROFILE)
# If binding:profile is None or an empty dict,
# it means binding:.profile needs to be cleared.
# TODO(amotoki): Allow Make None in binding:profile in
# the API layer. See LP bug #1220011.
profile_set = attrs.is_attr_set(profile) and profile
cur_portinfo = ndb.get_portinfo(context.session, port['id'])
if profile_set:
portinfo = self._validate_portinfo(profile)
portinfo_changed = 'ADD'
if cur_portinfo:
if (portinfo['datapath_id'] == cur_portinfo.datapath_id and
portinfo['port_no'] == cur_portinfo.port_no):
return
ndb.del_portinfo(context.session, port['id'])
portinfo_changed = 'MOD'
portinfo['mac'] = port['mac_address']
ndb.add_portinfo(context.session, port['id'], **portinfo)
elif cur_portinfo:
portinfo_changed = 'DEL'
portinfo = None
ndb.del_portinfo(context.session, port['id'])
self._extend_port_dict_binding_portinfo(port, portinfo)
return portinfo_changed
开发者ID:fyafighter,项目名称:neutron,代码行数:34,代码来源:nec_plugin.py
示例2: update_ports
def update_ports(self, rpc_context, **kwargs):
"""Update ports' information and activate/deavtivate them.
Expected input format is:
{'topic': 'q-agent-notifier',
'agent_id': 'nec-q-agent.' + <hostname>,
'datapath_id': <datapath_id of br-int on remote host>,
'port_added': [<new PortInfo>,...],
'port_removed': [<removed Port ID>,...]}
"""
LOG.debug(_("NECPluginV2RPCCallbacks.update_ports() called, " "kwargs=%s ."), kwargs)
datapath_id = kwargs["datapath_id"]
session = rpc_context.session
for p in kwargs.get("port_added", []):
id = p["id"]
portinfo = ndb.get_portinfo(session, id)
if portinfo:
if necutils.cmp_dpid(portinfo.datapath_id, datapath_id) and portinfo.port_no == p["port_no"]:
LOG.debug(_("update_ports(): ignore unchanged portinfo in " "port_added message (port_id=%s)."), id)
continue
ndb.del_portinfo(session, id)
port = self._get_port(rpc_context, id)
if port:
ndb.add_portinfo(session, id, datapath_id, p["port_no"], mac=p.get("mac", ""))
# NOTE: Make sure that packet filters on this port exist while
# the port is active to avoid unexpected packet transfer.
if portinfo:
self.plugin.deactivate_port(rpc_context, port)
self.plugin.deactivate_packet_filters_by_port(rpc_context, id)
self.plugin.activate_packet_filters_by_port(rpc_context, id)
self.plugin.activate_port_if_ready(rpc_context, port)
for id in kwargs.get("port_removed", []):
portinfo = ndb.get_portinfo(session, id)
if not portinfo:
LOG.debug(
_(
"update_ports(): ignore port_removed message "
"due to portinfo for port_id=%s was not "
"registered"
),
id,
)
continue
if not necutils.cmp_dpid(portinfo.datapath_id, datapath_id):
LOG.debug(
_(
"update_ports(): ignore port_removed message "
"received from different host "
"(registered_datapath_id=%(registered)s, "
"received_datapath_id=%(received)s)."
),
{"registered": portinfo.datapath_id, "received": datapath_id},
)
continue
ndb.del_portinfo(session, id)
port = self._get_port(rpc_context, id)
if port:
self.plugin.deactivate_port(rpc_context, port)
self.plugin.deactivate_packet_filters_by_port(rpc_context, id)
开发者ID:raceli,项目名称:neutron,代码行数:59,代码来源:nec_plugin.py
示例3: testf_del_portinfo
def testf_del_portinfo(self):
"""test delete portinfo."""
i, d, p, v, m, n = self.get_portinfo_random_params()
ndb.add_portinfo(self.session, i, d, p, v, m)
portinfo = ndb.get_portinfo(self.session, i)
self.assertEqual(portinfo.id, i)
ndb.del_portinfo(self.session, i)
portinfo_none = ndb.get_portinfo(self.session, i)
self.assertEqual(None, portinfo_none)
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:9,代码来源:test_db.py
示例4: testf_del_portinfo
def testf_del_portinfo(self):
"""test delete portinfo."""
with self.portinfo_random_params() as params:
self._add_portinfo(self.session, params)
portinfo = ndb.get_portinfo(self.session, params['port_id'])
self.assertEqual(portinfo.id, params['port_id'])
ndb.del_portinfo(self.session, params['port_id'])
portinfo_none = ndb.get_portinfo(self.session, params['port_id'])
self.assertIsNone(portinfo_none)
开发者ID:CiscoSystems,项目名称:neutron,代码行数:9,代码来源:test_db.py
示例5: update_ports
def update_ports(self, rpc_context, **kwargs):
"""Update ports' information and activate/deavtivate them.
Expected input format is:
{'topic': 'q-agent-notifier',
'agent_id': 'nec-q-agent.' + <hostname>,
'datapath_id': <datapath_id of br-int on remote host>,
'port_added': [<new PortInfo>,...],
'port_removed': [<removed Port ID>,...]}
"""
LOG.debug(_("NECPluginV2RPCCallbacks.update_ports() called, "
"kwargs=%s ."), kwargs)
datapath_id = kwargs['datapath_id']
session = rpc_context.session
for p in kwargs.get('port_added', []):
id = p['id']
portinfo = ndb.get_portinfo(session, id)
if portinfo:
ndb.del_portinfo(session, id)
ndb.add_portinfo(session, id, datapath_id, p['port_no'],
mac=p.get('mac', ''))
port = self._get_port(rpc_context, id)
if port:
if portinfo:
self.plugin.deactivate_port(rpc_context, port)
self.plugin.activate_port_if_ready(rpc_context, port)
for id in kwargs.get('port_removed', []):
portinfo = ndb.get_portinfo(session, id)
if not portinfo:
LOG.debug(_("update_ports(): ignore port_removed message "
"due to portinfo for port_id=%s was not "
"registered"), id)
continue
if portinfo.datapath_id != datapath_id:
LOG.debug(_("update_ports(): ignore port_removed message "
"received from different host "
"(registered_datapath_id=%(registered)s, "
"received_datapath_id=%(received)s)."),
{'registered': portinfo.datapath_id,
'received': datapath_id})
continue
ndb.del_portinfo(session, id)
port = self._get_port(rpc_context, id)
if port:
self.plugin.deactivate_port(rpc_context, port)
开发者ID:matrohon,项目名称:quantum,代码行数:45,代码来源:nec_plugin.py
注:本文中的neutron.plugins.nec.db.api.del_portinfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论