本文整理汇总了Python中cfgm_common.dependency_tracker.DependencyTracker.resources[resource]方法的典型用法代码示例。如果您正苦于以下问题:Python DependencyTracker.resources[resource]方法的具体用法?Python DependencyTracker.resources[resource]怎么用?Python DependencyTracker.resources[resource]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cfgm_common.dependency_tracker.DependencyTracker
的用法示例。
在下文中一共展示了DependencyTracker.resources[resource]方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _vnc_subscribe_callback
# 需要导入模块: from cfgm_common.dependency_tracker import DependencyTracker [as 别名]
# 或者: from cfgm_common.dependency_tracker.DependencyTracker import resources[resource] [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 = DBBaseST.get_obj_type_map().get(obj_type)
if obj_class is None:
return
oper = oper_info['oper']
obj_id = oper_info['uuid']
notify_trace = MessageBusNotifyTrace(
request_id=oper_info.get('request_id'),
operation=oper, uuid=obj_id)
if oper == 'CREATE':
obj_dict = oper_info['obj_dict']
obj_fq_name = ':'.join(obj_dict['fq_name'])
obj = obj_class.locate(obj_fq_name)
if obj is None:
self.config_log('%s id %s fq_name %s not found' % (
obj_type, obj_id, obj_fq_name),
level=SandeshLevel.SYS_INFO)
return
dependency_tracker = DependencyTracker(
DBBaseST.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
elif oper == 'UPDATE':
obj = obj_class.get_by_uuid(obj_id)
old_dt = None
if obj is not None:
old_dt = DependencyTracker(
DBBaseST.get_obj_type_map(), self._REACTION_MAP)
old_dt.evaluate(obj_type, obj)
else:
self.config_log('%s id %s not found' % (obj_type, obj_id),
level=SandeshLevel.SYS_INFO)
return
try:
obj.update()
except NoIdError:
self.config_log('%s id %s update caused NoIdError' % (obj_type, obj_id),
level=SandeshLevel.SYS_INFO)
return
dependency_tracker = DependencyTracker(
DBBaseST.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 == 'DELETE':
obj = obj_class.get_by_uuid(obj_id)
if obj is None:
return
dependency_tracker = DependencyTracker(
DBBaseST.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
obj_class.delete(obj.name)
else:
# unknown operation
self.config_log('Unknown operation %s' % oper,
level=SandeshLevel.SYS_ERR)
return
if obj is None:
self.config_log('Error while accessing %s uuid %s' % (
obj_type, obj_id))
return
notify_trace.fq_name = obj.name
if not dependency_tracker:
return
notify_trace.dependency_tracker_resources = []
for res_type, res_id_list in dependency_tracker.resources.items():
if not res_id_list:
continue
dtr = DependencyTrackerResource(obj_type=res_type, obj_keys=res_id_list)
notify_trace.dependency_tracker_resources.append(dtr)
cls = DBBaseST.get_obj_type_map().get(res_type)
if cls is None:
continue
for res_id in res_id_list:
res_obj = cls.get(res_id)
if res_obj is not None:
res_obj.evaluate()
for vn_id in dependency_tracker.resources.get('virtual_network', []):
vn = VirtualNetworkST.get(vn_id)
if vn is not None:
vn.uve_send()
# end for vn_id
except Exception as e:
string_buf = cStringIO.StringIO()
#.........这里部分代码省略.........
示例2: _vnc_subscribe_actions
# 需要导入模块: from cfgm_common.dependency_tracker import DependencyTracker [as 别名]
# 或者: from cfgm_common.dependency_tracker.DependencyTracker import resources[resource] [as 别名]
def _vnc_subscribe_actions(self, oper_info):
msg = "Notification Message: %s" % (pformat(oper_info))
self.logger.debug(msg)
obj_type = oper_info['type'].replace('-', '_')
obj_class = DBBaseSM.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 = oper_info['uuid']
obj = obj_class.locate(obj_id)
dependency_tracker = DependencyTracker(
DBBaseSM.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(
DBBaseSM.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(
DBBaseSM.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(
DBBaseSM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
obj_class.delete(obj_id)
else:
# unknown operation
self.logger.error('Unknown operation %s' % oper_info['oper'])
return
if obj is None:
self.logger.error('Error while accessing %s uuid %s' % (
obj_type, obj_id))
return
for res_type, res_id_list in dependency_tracker.resources.items():
if not res_id_list:
continue
cls = DBBaseSM.get_obj_type_map().get(res_type)
if cls is None:
continue
for res_id in res_id_list:
res_obj = cls.get(res_id)
if res_obj is not None:
res_obj.evaluate()
示例3: _vnc_subscribe_callback
# 需要导入模块: from cfgm_common.dependency_tracker import DependencyTracker [as 别名]
# 或者: from cfgm_common.dependency_tracker.DependencyTracker import resources[resource] [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()
示例4: _vnc_subscribe_actions
# 需要导入模块: from cfgm_common.dependency_tracker import DependencyTracker [as 别名]
# 或者: from cfgm_common.dependency_tracker.DependencyTracker import resources[resource] [as 别名]
def _vnc_subscribe_actions(self, oper_info):
msg = "Notification Message: %s" % (pformat(oper_info))
self.logger.debug(msg)
obj_type = oper_info["type"].replace("-", "_")
obj_class = DBBaseSM.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 = oper_info["uuid"]
obj = obj_class.locate(obj_id)
if obj is not None:
dependency_tracker = DependencyTracker(DBBaseSM.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(DBBaseSM.get_obj_type_map(), self._REACTION_MAP)
old_dt.evaluate(obj_type, obj)
else:
obj = obj_class.locate(obj_id)
if obj is not None:
try:
obj.update()
except NoIdError:
self.logger.warning("%s uuid %s has vanished" % (obj_type, obj_id))
return
dependency_tracker = DependencyTracker(DBBaseSM.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(DBBaseSM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
obj_class.delete(obj_id)
else:
# unknown operation
self.logger.error("Unknown operation %s" % oper_info["oper"])
return
if obj is None:
self.logger.warning("%s uuid %s has vanished" % (obj_type, obj_id))
return
for res_type, res_id_list in dependency_tracker.resources.items():
if not res_id_list:
continue
cls = DBBaseSM.get_obj_type_map().get(res_type)
if cls is None:
continue
for res_id in res_id_list:
res_obj = cls.get(res_id)
if res_obj is not None:
res_obj.evaluate()