本文整理汇总了Python中cfgm_common.dependency_tracker.DependencyTracker类的典型用法代码示例。如果您正苦于以下问题:Python DependencyTracker类的具体用法?Python DependencyTracker怎么用?Python DependencyTracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DependencyTracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_update
def handle_update(self):
obj_id = self.oper_info['uuid']
self.obj = self.obj_class.get_by_uuid(obj_id)
old_dt = None
if self.obj is not None:
old_dt = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
old_dt.evaluate(self.obj_type, self.obj)
else:
self.logger.info('%s id %s not found' % (self.obj_type,
obj_id))
return
try:
self.obj.update()
except NoIdError:
obj_id = self.oper_info['uuid']
self.logger.warning('%s uuid %s update caused NoIdError' %
(self.obj_type, obj_id))
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
if old_dt:
for resource, ids in old_dt.resources.items():
if resource not in self.dependency_tracker.resources:
self.dependency_tracker.resources[resource] = ids
else:
self.dependency_tracker.resources[resource] = list(
set(self.dependency_tracker.resources[resource]) |
set(ids))
示例2: test_basic_dep_track_2
def test_basic_dep_track_2(self):
reaction_map = {
"red": {
'self': [],
},
"blue": {
'self': ['green'],
},
"green": {
'self': [],
'blue': [],
},
"purple": {
'self': [],
},
}
GreenSM._object_db.object_read = self.green_read_with_refs
BlueSM._object_db.object_read = self.blue_read_with_multi_refs
dependency_tracker = DependencyTracker(DBBase._OBJ_TYPE_MAP, reaction_map)
red = RedSM.locate("fake-red-uuid")
blue = BlueSM.locate("fake-blue-uuid")
GreenSM.locate("fake-green-uuid-0")
GreenSM.locate("fake-green-uuid-1")
dependency_tracker.evaluate('blue', blue)
self.assertEqual(len(dependency_tracker.resources), 2)
self.assertTrue("blue" in dependency_tracker.resources)
self.assertTrue("green" in dependency_tracker.resources)
self.assertEqual(dependency_tracker.resources["green"], ["fake-green-uuid-1", "fake-green-uuid-0"])
self.assertEqual(dependency_tracker.resources["blue"], ["fake-blue-uuid"])
RedSM.delete("fake-red-uuid")
GreenSM.delete("fake-green-uuid-0")
GreenSM.delete("fake-green-uuid-1")
BlueSM.delete("fake-blue-uuid")
示例3: test_basic_dep_track
def test_basic_dep_track(self):
reaction_map = {
"red": {
'self': ['blue', 'green'],
},
"blue": {
'self': [],
'red': [],
},
"green": {
'self': [],
'red': [],
},
"purple": {
'self': [],
},
}
dependency_tracker = DependencyTracker(DBBase._OBJ_TYPE_MAP, reaction_map)
red = RedSM.locate("fake-red-uuid")
blue = BlueSM.locate("fake-blue-uuid")
green = GreenSM.locate("fake-green-uuid")
dependency_tracker.evaluate('red', red)
self.assertEqual(len(dependency_tracker.resources), 3)
self.assertTrue("red" in dependency_tracker.resources)
self.assertTrue("blue" in dependency_tracker.resources)
self.assertTrue("green" in dependency_tracker.resources)
self.assertEqual(dependency_tracker.resources["red"], ["fake-red-uuid"])
self.assertEqual(dependency_tracker.resources["blue"], ["fake-blue-uuid"])
self.assertEqual(dependency_tracker.resources["green"], ["fake-green-uuid"])
RedSM.delete("fake-red-uuid")
GreenSM.delete("fake-green-uuid")
BlueSM.delete("fake-blue-uuid")
示例4: test_basic_dep_track_7
def test_basic_dep_track_7(self):
reaction_map = {
"red": {
'self': ['green', 'blue'],
},
"blue": {
'self': ['green'],
'red': [],
'purple': ['green'],
},
"green": {
'self': ['white'],
'blue': ['white'],
'red': [],
},
"white": {
'self': ['purple'],
'green': ['purple'],
},
"purple": {
'self': ['blue'],
'white': ['blue'],
},
}
GreenSM._object_db.object_read = self.green_read_with_refs
WhiteSM._object_db.object_read = self.white_read_with_refs
BlueSM._object_db.object_read = self.purple_read_with_multi_refs
BlueSM._object_db.object_read = self.blue_read_with_multi_refs
dependency_tracker = DependencyTracker(DBBase._OBJ_TYPE_MAP, reaction_map)
red = RedSM.locate("fake-red-uuid")
blue = BlueSM.locate("fake-blue-uuid")
green = GreenSM.locate("fake-green-uuid-0")
GreenSM.locate("fake-green-uuid-1")
white = WhiteSM.locate("fake-white-uuid")
purple = PurpleSM.locate("fake-purple-uuid")
dependency_tracker.evaluate('purple', purple)
self.assertEqual(len(dependency_tracker.resources), 4)
self.assertTrue("blue" in dependency_tracker.resources)
self.assertTrue("green" in dependency_tracker.resources)
self.assertTrue("white" in dependency_tracker.resources)
self.assertTrue("purple" in dependency_tracker.resources)
self.assertEqual(set(dependency_tracker.resources["green"]), set(["fake-green-uuid-1", "fake-green-uuid-0"]))
self.assertEqual(dependency_tracker.resources["blue"], ["fake-blue-uuid"])
self.assertEqual(dependency_tracker.resources["white"], ["fake-white-uuid"])
self.assertEqual(dependency_tracker.resources["purple"], ["fake-purple-uuid"])
RedSM.delete("fake-red-uuid")
GreenSM.delete("fake-green-uuid-0")
GreenSM.delete("fake-green-uuid-1")
BlueSM.delete("fake-blue-uuid")
WhiteSM.delete("fake-white-uuid")
PurpleSM.delete("fake-purple-uuid")
示例5: handle_delete
def handle_delete(self):
obj_id = self.oper_info['uuid']
self.obj = self.obj_class.get_by_uuid(obj_id)
self.db_cls._object_db.cache_uuid_to_fq_name_del(obj_id)
if self.obj is None:
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
obj_key = self.db_cls.get_key_from_dict(self.oper_info['obj_dict'])
self.obj_class.delete(obj_key)
示例6: _vnc_subscribe_callback
def _vnc_subscribe_callback(self, oper_info):
import pdb;pdb.set_trace()
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 = DBBase._OBJ_TYPE_MAP.get(obj_type)
if obj_class is None:
return
if oper_info['oper'] == 'CREATE' or oper_info['oper'] == 'UPDATE':
dependency_tracker = DependencyTracker(DBBase._OBJ_TYPE_MAP, self._REACTION_MAP)
obj_id = oper_info['uuid']
obj = obj_class.get(obj_id)
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(DBBase._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 lb_pool_id in dependency_tracker.resources.get('loadbalancer_pool', []):
lb_pool = LoadbalancerPoolSM.get(lb_pool_id)
if lb_pool is not None:
lb_pool.add()
示例7: handle_update
def handle_update(self):
obj_id = self.oper_info['uuid']
self.obj = self.obj_class.get_by_uuid(obj_id)
old_dt = None
if self.obj is not None:
old_dt = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
old_dt.evaluate(self.obj_type, self.obj)
else:
self.logger.info('%s id %s not found' % (self.obj_type,
obj_id))
return
try:
ret = self.obj.update()
if ret is not None and not ret:
# If update returns None, the function may not support a
# return value, hence treat it as if something might have
# changed. If a value is returned, use its truth value.
# If it True, then some change was detected.
# If no change, then terminate dependency tracker
return
except NoIdError:
obj_id = self.oper_info['uuid']
self.logger.warning('%s uuid %s update caused NoIdError' %
(self.obj_type, obj_id))
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
if old_dt:
for resource, ids in old_dt.resources.items():
if resource not in self.dependency_tracker.resources:
self.dependency_tracker.resources[resource] = ids
else:
self.dependency_tracker.resources[resource] = list(
set(self.dependency_tracker.resources[resource]) |
set(ids))
示例8: handle_create
def handle_create(self):
obj_key = self._get_key_from_oper_info()
obj_id = self.oper_info['uuid']
obj_fq_name = self.oper_info['fq_name']
self.db_cls._object_db.cache_uuid_to_fq_name_add(
obj_id, obj_fq_name, self.obj_type)
self.obj = self.obj_class.locate(obj_key)
if self.obj is None:
self.logger.info('%s id %s fq_name %s not found' % (
self.obj_type, obj_id, obj_fq_name))
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
示例9: _vnc_subscribe_callback
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()
#.........这里部分代码省略.........
示例10: _vnc_subscribe_actions
def _vnc_subscribe_actions(self, oper_info):
try:
msg = "Notification Message: %s" % (pformat(oper_info))
self.logger.log_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' or oper_info['oper'] == 'UPDATE':
dependency_tracker = DependencyTracker(
DBBaseSM.get_obj_type_map(), self._REACTION_MAP)
obj_id = oper_info['uuid']
obj = obj_class.get(obj_id)
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(
DBBaseSM.get_obj_type_map(), self._REACTION_MAP)
dependency_tracker.evaluate(obj_type, obj)
obj_class.delete(obj_id)
else:
# unknown operation
self.logger.log_error('Unknown operation %s' %
oper_info['oper'])
return
if obj is None:
self.logger.log_error('Error while accessing %s uuid %s' % (
obj_type, obj_id))
return
except Exception:
cgitb_error_log(self)
for sas_id in dependency_tracker.resources.get(
'service_appliance_set', []):
sas_obj = ServiceApplianceSetSM.get(sas_id)
if sas_obj is not None:
sas_obj.add()
for lb_pool_id in dependency_tracker.resources.get(
'loadbalancer_pool', []):
lb_pool = LoadbalancerPoolSM.get(lb_pool_id)
if lb_pool is not None:
lb_pool.add()
for si_id in dependency_tracker.resources.get('service_instance', []):
si = ServiceInstanceSM.get(si_id)
if si:
si.state = 'launch'
self._create_service_instance(si)
else:
self.logger.log_info("Deleting SI %s" % si_id)
for vm_id in dependency_tracker.resources.get(
'virtual_machine', []):
vm = VirtualMachineSM.get(vm_id)
self._delete_service_instance(vm)
self.logger.log_info("SI %s deletion succeed" % si_id)
for vn_id in dependency_tracker.resources.get('virtual_network', []):
vn = VirtualNetworkSM.get(vn_id)
if vn:
for si_id in ServiceInstanceSM:
si = ServiceInstanceSM.get(si_id)
intf_list = []
if si.params:
intf_list = si.params.get('interface_list', [])
for intf in intf_list:
if (':').join(vn.fq_name) in intf.values():
self._create_service_instance(si)
for vmi_id in dependency_tracker.resources.get(
'virtual_machine_interface', []):
vmi = VirtualMachineInterfaceSM.get(vmi_id)
if vmi:
for vm_id in dependency_tracker.resources.get(
'virtual_machine', []):
vm = VirtualMachineSM.get(vm_id)
self.port_delete_or_si_link(vm, vmi)
else:
for irt_id in dependency_tracker.resources.get(
'interface_route_table', []):
self._delete_interface_route_table(irt_id)
for fip_id in dependency_tracker.resources.get('floating_ip', []):
fip = FloatingIpSM.get(fip_id)
if fip:
for vmi_id in fip.virtual_machine_interfaces:
vmi = VirtualMachineInterfaceSM.get(vmi_id)
if vmi and vmi.virtual_ip:
self.netns_manager.add_fip_to_vip_vmi(vmi, fip)
#.........这里部分代码省略.........
示例11: _vnc_subscribe_actions
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()
示例12: _vnc_subscribe_callback
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()
示例13: _vnc_subscribe_actions
def _vnc_subscribe_actions(self, oper_info):
try:
msg = "Notification Message: %s" % (pformat(oper_info))
self.config_log(msg, level=SandeshLevel.SYS_DEBUG)
obj_type = oper_info['type'].replace('-', '_')
obj_class = DBBase._OBJ_TYPE_MAP.get(obj_type)
if obj_class is None:
return
if oper_info['oper'] == 'CREATE' or oper_info['oper'] == 'UPDATE':
dependency_tracker = DependencyTracker(DBBase._OBJ_TYPE_MAP,
self._REACTION_MAP)
obj_id = oper_info['uuid']
obj = obj_class.get(obj_id)
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(DBBase._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:
cgitb_error_log(self)
for sas_id in dependency_tracker.resources.get('service_appliance_set', []):
sas_obj = ServiceApplianceSetSM.get(sas_id)
if sas_obj is not None:
sas_obj.add()
for lb_pool_id in dependency_tracker.resources.get('loadbalancer_pool', []):
lb_pool = LoadbalancerPoolSM.get(lb_pool_id)
if lb_pool is not None:
lb_pool.add()
for si_id in dependency_tracker.resources.get('service_instance', []):
si = ServiceInstanceSM.get(si_id)
if si:
self._create_service_instance(si)
else:
for vm_id in dependency_tracker.resources.get(
'virtual_machine', []):
vm = VirtualMachineSM.get(vm_id)
self._delete_service_instance(vm)
for vn_id in dependency_tracker.resources.get('virtual_network', []):
vn = VirtualNetworkSM.get(vn_id)
if vn:
for si_id in ServiceInstanceSM:
si = ServiceInstanceSM.get(si_id)
if (':').join(vn.fq_name) in si.params.values():
self._create_service_instance(si)
for vmi_id in dependency_tracker.resources.get('virtual_machine_interface', []):
vmi = VirtualMachineInterfaceSM.get(vmi_id)
if vmi:
for vm_id in dependency_tracker.resources.get(
'virtual_machine', []):
vm = VirtualMachineSM.get(vm_id)
if vm:
self.check_link_si_to_vm(vm, vmi)
else:
for irt_id in dependency_tracker.resources.get(
'interface_route_table', []):
self._delete_interface_route_table(irt_id)
for fip_id in dependency_tracker.resources.get('floating_ip', []):
fip = FloatingIpSM.get(fip_id)
if fip:
for vmi_id in fip.virtual_machine_interfaces:
vmi = VirtualMachineInterfaceSM.get(vmi_id)
if vmi and vmi.virtual_ip:
self.netns_manager.add_fip_to_vip_vmi(vmi, fip)
示例14: _vnc_subscribe_callback
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()
示例15: VncAmqpHandle
#.........这里部分代码省略.........
return
oper = self.oper_info['oper']
obj_id = self.oper_info['uuid']
self.create_msgbus_trace(self.oper_info.get('request_id'),
oper, obj_id)
if oper == 'CREATE':
self.handle_create()
elif oper == 'UPDATE':
self.handle_update()
elif oper == 'DELETE':
self.handle_delete()
else:
self.handle_unknown()
return
if self.obj is None:
self.logger.error('Error while accessing %s uuid %s' % (
self.obj_type, obj_id))
return
self.evaluate_dependency()
def handle_create(self):
obj_dict = self.oper_info['obj_dict']
obj_key = self.db_cls.get_key_from_dict(obj_dict)
obj_id = self.oper_info['uuid']
obj_fq_name = obj_dict['fq_name']
self.db_cls._object_db.cache_uuid_to_fq_name_add(
obj_id, obj_fq_name, self.obj_type)
self.obj = self.obj_class.locate(obj_key)
if self.obj is None:
self.logger.info('%s id %s fq_name %s not found' % (
self.obj_type, obj_id, obj_fq_name))
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
def handle_update(self):
obj_id = self.oper_info['uuid']
self.obj = self.obj_class.get_by_uuid(obj_id)
old_dt = None
if self.obj is not None:
old_dt = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
old_dt.evaluate(self.obj_type, self.obj)
else:
self.logger.info('%s id %s not found' % (self.obj_type,
obj_id))
return
try:
self.obj.update()
except NoIdError:
obj_id = self.oper_info['uuid']
self.logger.warning('%s uuid %s update caused NoIdError' %
(self.obj_type, obj_id))
return
self.dependency_tracker = DependencyTracker(
self.db_cls.get_obj_type_map(), self.reaction_map)
self.dependency_tracker.evaluate(self.obj_type, self.obj)
if old_dt:
for resource, ids in old_dt.resources.items():
if resource not in self.dependency_tracker.resources:
self.dependency_tracker.resources[resource] = ids
else: