本文整理汇总了Python中db.PhysicalRouterDM.get方法的典型用法代码示例。如果您正苦于以下问题:Python PhysicalRouterDM.get方法的具体用法?Python PhysicalRouterDM.get怎么用?Python PhysicalRouterDM.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.PhysicalRouterDM
的用法示例。
在下文中一共展示了PhysicalRouterDM.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _vnc_subscribe_callback
# 需要导入模块: from db import PhysicalRouterDM [as 别名]
# 或者: from db.PhysicalRouterDM import get [as 别名]
def _vnc_subscribe_callback(self, oper_info):
self._db_resync_done.wait()
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._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._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)
dependency_tracker = DependencyTracker(DBBaseDM._OBJ_TYPE_MAP,
self._REACTION_MAP)
if obj is not None:
dependency_tracker.evaluate(obj_type, obj)
else:
obj = obj_class.locate(obj_id)
obj.update()
dependency_tracker.evaluate(obj_type, obj)
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._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)
for pr_id in dependency_tracker.resources.get('physical_router', []):
pr = PhysicalRouterDM.get(pr_id)
if pr is not None:
pr.push_config()
示例2: _vnc_subscribe_callback
# 需要导入模块: from db import PhysicalRouterDM [as 别名]
# 或者: from db.PhysicalRouterDM 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()