本文整理匯總了Python中db.VirtualNetworkDM.get方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualNetworkDM.get方法的具體用法?Python VirtualNetworkDM.get怎麽用?Python VirtualNetworkDM.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.VirtualNetworkDM
的用法示例。
在下文中一共展示了VirtualNetworkDM.get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_vn_li_map
# 需要導入模塊: from db import VirtualNetworkDM [as 別名]
# 或者: from db.VirtualNetworkDM import get [as 別名]
def get_vn_li_map(self):
pr = self.physical_router
vn_dict = {}
for vn_id in pr.virtual_networks:
vn_dict[vn_id] = []
vn = VirtualNetworkDM.get(vn_id)
if vn and vn.router_external:
vn_list = vn.get_connected_private_networks()
for pvn in vn_list or []:
vn_dict[pvn] = []
li_set = pr.logical_interfaces
for pi_uuid in pr.physical_interfaces:
pi = PhysicalInterfaceDM.get(pi_uuid)
if pi is None:
continue
li_set |= pi.logical_interfaces
for li_uuid in li_set:
li = LogicalInterfaceDM.get(li_uuid)
if li is None:
continue
vmi_id = li.virtual_machine_interface
vmi = VirtualMachineInterfaceDM.get(vmi_id)
if vmi is None:
continue
vn_id = vmi.virtual_network
vn_dict.setdefault(vn_id, []).append(
JunosInterface(li.name, li.li_type, li.vlan_tag, li_uuid=li.uuid))
return vn_dict
示例2: _vnc_subscribe_callback
# 需要導入模塊: from db import VirtualNetworkDM [as 別名]
# 或者: from db.VirtualNetworkDM import get [as 別名]
def _vnc_subscribe_callback(self, oper_info):
self._db_resync_done.wait()
dependency_tracker = None
try:
msg = "Notification Message: %s" % (pformat(oper_info))
self.config_log(msg, level=SandeshLevel.SYS_DEBUG)
obj_type = oper_info['type'].replace('-', '_')
obj_class = DBBaseDM.get_obj_type_map().get(obj_type)
if obj_class is None:
return
if oper_info['oper'] == 'CREATE':
obj_dict = oper_info['obj_dict']
obj_id = obj_dict['uuid']
obj = obj_class.locate(obj_id, obj_dict)
dependency_tracker = DependencyTracker(
DBBaseDM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
elif oper_info['oper'] == 'UPDATE':
obj_id = oper_info['uuid']
obj = obj_class.get(obj_id)
old_dt = None
if obj is not None:
old_dt = DependencyTracker(
DBBaseDM.get_obj_type_map(), self._REACTION_MAP)
old_dt.evaluate(obj_type, obj)
else:
obj = obj_class.locate(obj_id)
obj.update()
dependency_tracker = DependencyTracker(
DBBaseDM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
if old_dt:
for resource, ids in old_dt.resources.items():
if resource not in dependency_tracker.resources:
dependency_tracker.resources[resource] = ids
else:
dependency_tracker.resources[resource] = list(
set(dependency_tracker.resources[resource]) |
set(ids))
elif oper_info['oper'] == 'DELETE':
obj_id = oper_info['uuid']
obj = obj_class.get(obj_id)
if obj is None:
return
dependency_tracker = DependencyTracker(
DBBaseDM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
obj_class.delete(obj_id)
else:
# unknown operation
self.config_log('Unknown operation %s' % oper_info['oper'],
level=SandeshLevel.SYS_ERR)
return
if obj is None:
self.config_log('Error while accessing %s uuid %s' % (
obj_type, obj_id))
return
except Exception:
string_buf = cStringIO.StringIO()
cgitb.Hook(file=string_buf, format="text").handle(sys.exc_info())
self.config_log(string_buf.getvalue(), level=SandeshLevel.SYS_ERR)
if not dependency_tracker:
return
for vn_id in dependency_tracker.resources.get('virtual_network', []):
vn = VirtualNetworkDM.get(vn_id)
if vn is not None:
vn.update_instance_ip_map()
for pr_id in dependency_tracker.resources.get('physical_router', []):
pr = PhysicalRouterDM.get(pr_id)
if pr is not None:
pr.set_config_state()