本文整理汇总了Python中neutron.plugins.ml2.db.get_segment_by_id函数的典型用法代码示例。如果您正苦于以下问题:Python get_segment_by_id函数的具体用法?Python get_segment_by_id怎么用?Python get_segment_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_segment_by_id函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_segment_by_id
def test_get_segment_by_id(self):
segment = {api.NETWORK_TYPE: "vlan", api.PHYSICAL_NETWORK: "physnet1", api.SEGMENTATION_ID: 1}
net_segment = self._create_segments([segment])[0]
segment_uuid = net_segment[api.ID]
net_segment = ml2_db.get_segment_by_id(self.ctx.session, segment_uuid)
self.assertEqual(segment, net_segment)
示例2: test_delete_network_segment
def test_delete_network_segment(self):
segment = {api.NETWORK_TYPE: "vlan", api.PHYSICAL_NETWORK: "physnet1", api.SEGMENTATION_ID: 1}
net_segment = self._create_segments([segment])[0]
segment_uuid = net_segment[api.ID]
ml2_db.delete_network_segment(self.ctx.session, segment_uuid)
# Get segment and verify its empty
net_segment = ml2_db.get_segment_by_id(self.ctx.session, segment_uuid)
self.assertIsNone(net_segment)
示例3: release_dynamic_segment
def release_dynamic_segment(self, session, segment_id):
"""Delete a dynamic segment."""
segment = db.get_segment_by_id(session, segment_id)
if segment:
driver = self.drivers.get(segment.get(api.NETWORK_TYPE))
if driver:
driver.obj.release_segment(session, segment)
db.delete_network_segment(session, segment_id)
else:
LOG.error(_LE("Failed to release segment '%s' because " "network type is not supported."), segment)
else:
LOG.debug("No segment found with id %(segment_id)s", segment_id)
示例4: test_get_segment_by_id_result_not_found
def test_get_segment_by_id_result_not_found(self):
segment_uuid = uuidutils.generate_uuid()
net_segment = ml2_db.get_segment_by_id(self.ctx.session, segment_uuid)
self.assertIsNone(net_segment)
示例5: _expand_segment
def _expand_segment(self, segment_id):
segment = db.get_segment_by_id(self._plugin_context.session,
segment_id)
if not segment:
LOG.warning(_LW("Could not expand segment %s"), segment_id)
return segment