本文整理汇总了Python中ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient.has_cached_resource方法的典型用法代码示例。如果您正苦于以下问题:Python EnhancedResourceRegistryClient.has_cached_resource方法的具体用法?Python EnhancedResourceRegistryClient.has_cached_resource怎么用?Python EnhancedResourceRegistryClient.has_cached_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient
的用法示例。
在下文中一共展示了EnhancedResourceRegistryClient.has_cached_resource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AgentConfigurationBuilder
# 需要导入模块: from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient [as 别名]
# 或者: from ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient import has_cached_resource [as 别名]
#.........这里部分代码省略.........
#check_keys([PRED.hasAgentInstance, PRED.hasModel, PRED.hasAgentDefinition])
check_keys([PRED.hasAgentInstance, PRED.hasAgentDefinition])
assert RT.ProcessDefinition in self.associated_objects
def set_agent_instance_object(self, agent_instance_obj):
"""
Set the agent instance object that we'll be interacting with
it may be necessary to set this several times, such as if external operations update the object
"""
assert agent_instance_obj._id
if self.last_id != agent_instance_obj._id:
self.associated_objects = None
self.agent_instance_obj = agent_instance_obj
self.last_id = agent_instance_obj._id
self.generated_config = False
def prepare(self, will_launch=True):
"""
Prepare (validate) an agent for launch, fetching all associated resources
@param will_launch - whether the running status should be checked -- set false if just generating config
"""
assert self.agent_instance_obj
# fetch caches just in time
if any([not self.RR2.has_cached_predicate(x) for x in self._predicates_to_cache()]):
self._update_cached_predicates()
if any([not self.RR2.has_cached_resource(x) for x in self._resources_to_cache()]):
self._update_cached_resources()
# validate the associations, then pick things up
self._collect_agent_instance_associations()
if will_launch:
# if there is an agent pid then assume that a drive is already started
agent_process_id = ResourceAgentClient._get_agent_process_id(self._get_device()._id)
if agent_process_id:
raise BadRequest("Agent Instance already running for this device pid: %s" %
str(agent_process_id))
self.will_launch = will_launch
config = self.generate_config()
return config
def _generate_org_governance_name(self):
log.debug("_generate_org_governance_name for %s", self.agent_instance_obj.name)
log.debug("retrieve the Org governance name to which this agent instance belongs")
try:
org_obj = self.RR2.find_subject(RT.Org, PRED.hasResource, self.agent_instance_obj._id, id_only=False)
return org_obj.org_governance_name
except NotFound:
return ''
except:
raise
def _generate_device_type(self):
log.debug("_generate_device_type for %s", self.agent_instance_obj.name)
return type(self._get_device()).__name__
示例2: AgentConfigurationBuilder
# 需要导入模块: from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient [as 别名]
# 或者: from ion.util.enhanced_resource_registry_client.EnhancedResourceRegistryClient import has_cached_resource [as 别名]
#.........这里部分代码省略.........
def set_agent_instance_object(self, agent_instance_obj):
"""
Set the agent instance object that we'll be interacting with
it may be necessary to set this several times, such as if external operations update the object
"""
assert agent_instance_obj._id
if self.last_id != agent_instance_obj._id:
self.associated_objects = None
self.agent_instance_obj = agent_instance_obj
self.last_id = agent_instance_obj._id
self.generated_config = False
def prepare(self, will_launch=True):
"""
Prepare (validate) an agent for launch, fetching all associated resources
@param will_launch - whether the running status should be checked -- set false if just generating config
"""
assert self.agent_instance_obj
if will_launch:
#if there is an agent pid then assume that a drive is already started
if self.agent_instance_obj.agent_process_id:
raise BadRequest("Agent Instance already running for this device pid: %s" %
str(self.agent_instance_obj.agent_process_id))
# fetch caches just in time
if any([not self.RR2.has_cached_predicate(x) for x in self._predicates_to_cache()]):
self._update_cached_predicates()
if any([not self.RR2.has_cached_resource(x) for x in self._resources_to_cache()]):
self._update_cached_resources()
# validate the associations, then pick things up
self._collect_agent_instance_associations()
self.will_launch = will_launch
return self.generate_config()
def _generate_org_governance_name(self):
log.debug("_generate_org_governance_name for %s", self.agent_instance_obj.name)
log.debug("retrieve the Org governance name to which this agent instance belongs")
try:
org_obj = self.RR2.find_subject(RT.Org, PRED.hasResource, self.agent_instance_obj._id, id_only=False)
return org_obj.org_governance_name
except NotFound:
return ''
except:
raise
def _generate_device_type(self):
log.debug("_generate_device_type for %s", self.agent_instance_obj.name)
return type(self._get_device()).__name__
def _generate_driver_config(self):
log.debug("_generate_driver_config for %s", self.agent_instance_obj.name)
# get default config
driver_config = self.agent_instance_obj.driver_config
agent_obj = self._get_agent()
# Create driver config.
add_driver_config = {