本文整理汇总了Python中ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient.find_subjects方法的典型用法代码示例。如果您正苦于以下问题:Python EnhancedResourceRegistryClient.find_subjects方法的具体用法?Python EnhancedResourceRegistryClient.find_subjects怎么用?Python EnhancedResourceRegistryClient.find_subjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient
的用法示例。
在下文中一共展示了EnhancedResourceRegistryClient.find_subjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEnhancedResourceRegistryClient
# 需要导入模块: from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient [as 别名]
# 或者: from ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient import find_subjects [as 别名]
#.........这里部分代码省略.........
raise e
#self.rr.read.assert_called_with("111", "")
self.rr.retire.assert_called_once_with("111")
def test_retire_bad_wrongtype(self):
"""
test resource read (passthru)
"""
# get objects
myret = self.sample_resource()
#configure Mock
self.rr.read.return_value = myret
self.assertRaises(BadRequest, self.RR2.retire, "111", RT.PlatformDevice)
self.rr.read.assert_called_once_with("111")
def test_pluck_delete(self):
"""
test delete
"""
# get objects
myret = self.sample_resource()
#configure Mock
self.rr.read.return_value = myret
self.rr.delete.return_value = None
self.rr.find_resources.return_value = None
self.rr.find_objects.return_value = (["2"], ["2"])
self.rr.find_subjects.return_value = (["3"], ["3"])
self.RR2.pluck_delete("111", RT.InstrumentDevice)
self.rr.delete.assert_called_once_with("111")
def test_advance_lcs(self):
"""
call RR when the transition ISN'T retire
"""
self.RR2.advance_lcs("111", LCE.PLAN)
self.rr.execute_lifecycle_transition.assert_called_once_with(resource_id="111", transition_event=LCE.PLAN)
self.RR2.advance_lcs("222", LCE.RETIRE)
self.rr.retire.assert_called_once_with("222")
def test_delete_association(self):
self.rr.get_association.return_value = "111"
self.RR2.delete_association("a", "b", "c")
self.rr.delete_association.assert_called_once_with("111")
def test_delete_all_object_associations(self):
self.rr.find_associations.return_value = ["111"]
self.RR2.delete_object_associations("x")
self.rr.delete_association.assert_called_once_with("111")
def test_delete_all_subject_associations(self):
self.rr.find_associations.return_value = ["111"]
self.RR2.delete_subject_associations("x")
示例2: RollXBuilder
# 需要导入模块: from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient [as 别名]
# 或者: from ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient import find_subjects [as 别名]
class RollXBuilder(object):
"""
for rollups and rolldowns
"""
def __init__(self, process=None):
"""
the process should be the "self" of a service instance
"""
assert process
self.process = process
self.RR2 = EnhancedResourceRegistryClient(self.process.clients.resource_registry)
def get_toplevel_platformsite(self, site_id):
if not self.RR2.has_cached_predicate(PRED.hasSite):
self.RR2.cache_predicate(PRED.hasSite)
parent_ids = self.RR2.find_platform_site_ids_by_platform_site_using_has_site(site_id)
if 0 == len(parent_ids):
return site_id # assume this to be the top level
return self.get_toplevel_platformsite(parent_ids[0])
def get_parent_network_nodes(self, site_id):
"""
return the parent nodes of this network node, including the given node
"""
if not self.RR2.has_cached_predicate(PRED.hasNetworkParent):
self.RR2.cache_predicate(PRED.hasNetworkParent)
def get_h(acc, some_id):
acc.append(some_id)
parent_ids = self.RR2.find_platform_device_ids_of_platform_device_using_has_network_parent(site_id)
if 0 == len(parent_ids):
return acc
return get_h(acc, parent_ids[0])
return get_h([], site_id)
def get_toplevel_network_node(self, device_id):
if not self.RR2.has_cached_predicate(PRED.hasNetworkParent):
self.RR2.cache_predicate(PRED.hasNetworkParent)
parent_ids = self.RR2.find_platform_device_ids_of_platform_device_using_has_network_parent(device_id)
if 0 == len(parent_ids):
# it can only be the network parent if it has this association
if 0 < len(self.RR2.find_platform_device_ids_by_platform_device_using_has_network_parent(device_id)):
return device_id # assume this to be top level
else:
return None
return self.get_toplevel_network_node(parent_ids[0])
def get_site_hierarchy(self, site_id, site_val_fn):
"""
return (child_sites, site_ancestors)
where child_sites is a dict mapping all child site ids to the value of site_val_fn(child_site_id)
and site_ancestors is a dict mapping all site ids to a list of their hasSite children.
"""
if not self.RR2.has_cached_predicate(PRED.hasSite):
self.RR2.cache_predicate(PRED.hasSite)
full_list = [site_id]
acc = {}
def _get_ancestors_h(s_id):
s_child_ids = self.RR2.find_objects(s_id, PRED.hasSite, id_only=True)
if s_child_ids:
acc[s_id] = s_child_ids
for scid in s_child_ids:
_get_ancestors_h(scid)
full_list.append(scid)
_get_ancestors_h(site_id)
return dict([(s, site_val_fn(s)) for s in full_list]), acc
def get_network_hierarchy(self, device_id, device_val_fn):
"""
return (child_devices, device_ancestors)
where child_devices is a dict mapping all child device ids to the value of device_val_fn(child_device_id)
and device_ancestors is a dict mapping all device ids to a list of their children as per
"""
if not self.RR2.has_cached_predicate(PRED.hasNetworkParent):
self.RR2.cache_predicate(PRED.hasNetworkParent)
full_list = [device_id]
acc = {}
def _get_ancestors_h(d_id):
d_child_ids = self.RR2.find_subjects(d_id, PRED.hasNetworkParent, id_only=True)
if d_child_ids:
acc[d_id] = d_child_ids
for dcid in d_child_ids:
_get_ancestors_h(dcid)
full_list.append(dcid)
#.........这里部分代码省略.........