本文整理汇总了Python中interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient.stop_platform_agent_instance方法的典型用法代码示例。如果您正苦于以下问题:Python InstrumentManagementServiceClient.stop_platform_agent_instance方法的具体用法?Python InstrumentManagementServiceClient.stop_platform_agent_instance怎么用?Python InstrumentManagementServiceClient.stop_platform_agent_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient
的用法示例。
在下文中一共展示了InstrumentManagementServiceClient.stop_platform_agent_instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_cmd_stop_agent
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
def _process_cmd_stop_agent(resource_id, res_obj=None):
agent_type = "instrument"
if res_obj._get_type() == "InstrumentDevice":
iai_ids,_ = Container.instance.resource_registry.find_objects(resource_id, PRED.hasAgentInstance, RT.InstrumentAgentInstance, id_only=True)
if iai_ids:
resource_id = iai_ids[0]
else:
return "InstrumentAgentInstance for InstrumentDevice %s not found" % resource_id
elif res_obj._get_type() == "PlatformDevice":
agent_type = "platform"
pai_ids,_ = Container.instance.resource_registry.find_objects(resource_id, PRED.hasAgentInstance, RT.PlatformAgentInstance, id_only=True)
if pai_ids:
resource_id = pai_ids[0]
else:
return "PlatformAgentInstance for PlatformDevice %s not found" % resource_id
elif res_obj._get_type() == "PlatformAgentInstance":
agent_type = "platform"
from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient
ims_cl = InstrumentManagementServiceClient()
if agent_type == "instrument":
ims_cl.stop_instrument_agent_instance(resource_id)
elif agent_type == "platform":
ims_cl.stop_platform_agent_instance(resource_id)
else:
return "Unknown agent type"
return "OK"
示例2: stop_agent
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
def stop_agent(self, agent_instance_id, resource_id):
res_obj = self.rr.read(resource_id)
if not agent_instance_id or not resource_id:
log.warn("Could not %s agent %s for device %s", self.op, agent_instance_id, resource_id)
return
try:
client = ResourceAgentClient(resource_id, process=self)
except NotFound:
log.warn("Agent for resource %s seems not running", resource_id)
log.info('Stopping agent...')
if res_obj.type_ == RT.ExternalDatasetAgentInstance or res_obj == RT.ExternalDataset:
dams = DataAcquisitionManagementServiceProcessClient(process=self)
try:
dams.stop_external_dataset_agent_instance(agent_instance_id)
except NotFound:
log.warn("Agent for resource %s not found", resource_id)
elif res_obj.type_ == RT.InstrumentDevice:
ims = InstrumentManagementServiceClient()
try:
ims.stop_instrument_agent_instance(agent_instance_id)
except NotFound:
log.warn("Agent for resource %s not found", resource_id)
elif res_obj.type_ == RT.PlatformDevice:
ims = InstrumentManagementServiceClient()
try:
ims.stop_platform_agent_instance(agent_instance_id)
except NotFound:
log.warn("Agent for resource %s not found", resource_id)
else:
BadRequest("Attempt to start unsupported agent type: %s", res_obj.type_)
log.info('Agent stopped!')
示例3: TestOmsLaunch
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
#.........这里部分代码省略.........
# now that most of the topology information is there, add the
# PlatformAgentInstance elements
self._set_platform_agent_instances()
base_platform_config = self.platform_configs[base_platform_id]
log.info("base_platform_id = %r", base_platform_id)
log.info("topology = %s", str(self.topology))
#-------------------------------
# Launch Base Platform AgentInstance, connect to the resource agent client
#-------------------------------
agent_instance_id = base_platform_objs['agent_instance_id']
pid = self.imsclient.start_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
log.debug("start_platform_agent_instance returned pid=%s", pid)
#wait for start
instance_obj = self.imsclient.read_platform_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.processdispatchclient.read_process,
instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The platform agent instance did not spawn in 90 seconds")
agent_instance_obj= self.imsclient.read_instrument_agent_instance(agent_instance_id)
log.debug('test_oms_create_and_launch: Platform agent instance obj: %s', str(agent_instance_obj))
# Start a resource agent client to talk with the instrument agent.
self._pa_client = ResourceAgentClient('paclient', name=agent_instance_obj.agent_process_id, process=FakeProcess())
log.debug(" test_oms_create_and_launch:: got pa client %s", str(self._pa_client))
log.debug("base_platform_config =\n%s", base_platform_config)
# ping_agent can be issued before INITIALIZE
retval = self._pa_client.ping_agent(timeout=TIMEOUT)
log.debug( 'Base Platform ping_agent = %s', str(retval) )
# issue INITIALIZE command to the base platform, which will launch the
# creation of the whole platform hierarchy rooted at base_platform_config['platform_id']
# cmd = AgentCommand(command=PlatformAgentEvent.INITIALIZE, kwargs=dict(plat_config=base_platform_config))
cmd = AgentCommand(command=PlatformAgentEvent.INITIALIZE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform INITIALIZE = %s', str(retval) )
# GO_ACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_ACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_ACTIVE = %s', str(retval) )
# RUN: this command includes the launch of the resource monitoring greenlets
cmd = AgentCommand(command=PlatformAgentEvent.RUN)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RUN = %s', str(retval) )
# START_EVENT_DISPATCH
kwargs = dict(params="TODO set params")
cmd = AgentCommand(command=PlatformAgentEvent.START_EVENT_DISPATCH, kwargs=kwargs)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
self.assertTrue(retval.result is not None)
# wait for data sample
# just wait for at least one -- see consume_data above
log.info("waiting for reception of a data sample...")
self._async_data_result.get(timeout=DATA_TIMEOUT)
self.assertTrue(len(self._samples_received) >= 1)
log.info("waiting a bit more for reception of more data samples...")
sleep(10)
log.info("Got data samples: %d", len(self._samples_received))
# wait for event
# just wait for at least one event -- see consume_event above
log.info("waiting for reception of an event...")
self._async_event_result.get(timeout=EVENT_TIMEOUT)
log.info("Received events: %s", len(self._events_received))
# STOP_EVENT_DISPATCH
cmd = AgentCommand(command=PlatformAgentEvent.STOP_EVENT_DISPATCH)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
self.assertTrue(retval.result is not None)
# GO_INACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_INACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_INACTIVE = %s', str(retval) )
# RESET: Resets the base platform agent, which includes termination of
# its sub-platforms processes:
cmd = AgentCommand(command=PlatformAgentEvent.RESET)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RESET = %s', str(retval) )
#-------------------------------
# Stop Base Platform AgentInstance
#-------------------------------
self.imsclient.stop_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
示例4: BaseIntTestPlatform
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
#.........这里部分代码省略.........
instr_keys[ii],
platform_id)
log.info("%d instruments assigned. Took %.3f secs.",
num_assigns, time.time() - start_time)
return p_root
#################################################################
# start / stop platform
#################################################################
def _start_platform(self, p_obj):
agent_instance_id = p_obj.platform_agent_instance_id
log.debug("about to call start_platform_agent_instance with id=%s", agent_instance_id)
p_obj.pid = self.IMS.start_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
log.debug("start_platform_agent_instance returned pid=%s", p_obj.pid)
#wait for start
agent_instance_obj = self.IMS.read_platform_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.PDC.read_process,
agent_instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The platform agent instance did not spawn in 90 seconds")
# Start a resource agent client to talk with the agent.
self._pa_client = ResourceAgentClient('paclient',
name=agent_instance_obj.agent_process_id,
process=FakeProcess())
log.debug("got platform agent client %s", str(self._pa_client))
def _stop_platform(self, p_obj):
try:
self.IMS.stop_platform_agent_instance(p_obj.platform_agent_instance_id)
except:
if log.isEnabledFor(logging.TRACE):
log.exception(
"platform_id=%r: Exception in IMS.stop_platform_agent_instance with "
"platform_agent_instance_id = %r",
p_obj.platform_id, p_obj.platform_agent_instance_id)
else:
log.warn(
"platform_id=%r: Exception in IMS.stop_platform_agent_instance with "
"platform_agent_instance_id = %r. Perhaps already dead.",
p_obj.platform_id, p_obj.platform_agent_instance_id)
#################################################################
# misc convenience methods
#################################################################
def _create_resource_agent_client(self, resource_id):
client = ResourceAgentClient(resource_id, process=FakeProcess())
return client
def _get_state(self):
state = self._pa_client.get_agent_state()
return state
def _assert_state(self, state):
self.assertEquals(self._get_state(), state)
def _execute_agent(self, cmd):
log.info("_execute_agent: cmd=%r kwargs=%r ...", cmd.command, cmd.kwargs)
time_start = time.time()
#retval = self._pa_client.execute_agent(cmd, timeout=timeout)
retval = self._pa_client.execute_agent(cmd)
示例5: TestPlatformLaunch
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
#.........这里部分代码省略.........
agent_instance_id = self.IMS.create_platform_agent_instance(
platform_agent_instance = agent_instance_obj,
platform_agent_id = agent_id,
platform_device_id = self.device_id)
stream_id = stream_ids[0]
self._start_data_subscriber(agent_instance_id, stream_id)
log.debug("about to call imsclient.start_platform_agent_instance with id=%s", agent_instance_id)
pid = self.IMS.start_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
log.debug("start_platform_agent_instance returned pid=%s", pid)
#wait for start
instance_obj = self.IMS.read_platform_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.PDC.read_process,
instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The platform agent instance did not spawn in 90 seconds")
agent_instance_obj= self.IMS.read_instrument_agent_instance(agent_instance_id)
log.debug('Platform agent instance obj')
# Start a resource agent client to talk with the instrument agent.
self._pa_client = ResourceAgentClient('paclient',
name=agent_instance_obj.agent_process_id,
process=FakeProcess())
log.debug("got platform agent client %s", str(self._pa_client))
# ping_agent can be issued before INITIALIZE
retval = self._pa_client.ping_agent(timeout=TIMEOUT)
log.debug('Base Platform ping_agent = %s', str(retval) )
cmd = AgentCommand(command=PlatformAgentEvent.INITIALIZE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform INITIALIZE = %s', str(retval) )
# GO_ACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_ACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_ACTIVE = %s', str(retval) )
# RUN:
cmd = AgentCommand(command=PlatformAgentEvent.RUN)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RUN = %s', str(retval) )
# START_MONITORING:
cmd = AgentCommand(command=PlatformAgentEvent.START_MONITORING)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform START_MONITORING = %s', str(retval) )
# wait for data sample
# just wait for at least one -- see consume_data above
log.info("waiting for reception of a data sample...")
self._async_data_result.get(timeout=DATA_TIMEOUT)
self.assertTrue(len(self._samples_received) >= 1)
log.info("waiting a bit more for reception of more data samples...")
sleep(15)
log.info("Got data samples: %d", len(self._samples_received))
# wait for event
# just wait for at least one event -- see consume_event above
log.info("waiting for reception of an event...")
self._async_event_result.get(timeout=EVENT_TIMEOUT)
log.info("Received events: %s", len(self._events_received))
#get the extended platfrom which wil include platform aggreate status fields
# extended_platform = self.IMS.get_platform_device_extension(self.device_id)
# log.debug( 'test_single_platform extended_platform: %s', str(extended_platform) )
# log.debug( 'test_single_platform power_status_roll_up: %s', str(extended_platform.computed.power_status_roll_up.value) )
# log.debug( 'test_single_platform comms_status_roll_up: %s', str(extended_platform.computed.communications_status_roll_up.value) )
# STOP_MONITORING:
cmd = AgentCommand(command=PlatformAgentEvent.STOP_MONITORING)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform STOP_MONITORING = %s', str(retval) )
# GO_INACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_INACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_INACTIVE = %s', str(retval) )
# RESET: Resets the base platform agent, which includes termination of
# its sub-platforms processes:
cmd = AgentCommand(command=PlatformAgentEvent.RESET)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RESET = %s', str(retval) )
#-------------------------------
# Stop Base Platform AgentInstance
#-------------------------------
self.IMS.stop_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
示例6: BaseIntTestPlatform
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
#.........这里部分代码省略.........
p_child = self._create_platform('MJ01C', parent_platform_id='Node1D')
p_grandchild = self._create_platform('LJ01D', parent_platform_id='MJ01C')
self._assign_child_to_parent(p_child, p_root)
self._assign_child_to_parent(p_grandchild, p_child)
self._generate_config(p_root.platform_agent_instance_obj, p_root.platform_id, "_final")
return p_root
#################################################################
# start / stop platform
#################################################################
def _start_platform(self, agent_instance_id):
log.debug("about to call start_platform_agent_instance with id=%s", agent_instance_id)
pid = self.IMS.start_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
log.debug("start_platform_agent_instance returned pid=%s", pid)
#wait for start
agent_instance_obj = self.IMS.read_platform_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.PDC.read_process,
agent_instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The platform agent instance did not spawn in 90 seconds")
# Start a resource agent client to talk with the agent.
self._pa_client = ResourceAgentClient('paclient',
name=agent_instance_obj.agent_process_id,
process=FakeProcess())
log.debug("got platform agent client %s", str(self._pa_client))
def _stop_platform(self, agent_instance_id):
self.IMS.stop_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
#################################################################
# start / stop instrument
#################################################################
def _start_instrument(self, agent_instance_id):
log.debug("about to call start_instrument_agent_instance with id=%s", agent_instance_id)
pid = self.IMS.start_instrument_agent_instance(instrument_agent_instance_id=agent_instance_id)
log.debug("start_instrument_agent_instance returned pid=%s", pid)
#wait for start
agent_instance_obj = self.IMS.read_instrument_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.PDC.read_process,
agent_instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The instrument agent instance did not spawn in 90 seconds")
# Start a resource agent client to talk with the agent.
self._ia_client = ResourceAgentClient('paclient',
name=agent_instance_obj.agent_process_id,
process=FakeProcess())
log.debug("got instrument agent client %s", str(self._ia_client))
def _stop_instrument(self, agent_instance_id):
self.IMS.stop_instrument_agent_instance(instrument_agent_instance_id=agent_instance_id)
#################################################################
# misc convenience methods
#################################################################
def _get_state(self):
state = self._pa_client.get_agent_state()
示例7: TestOmsLaunch
# 需要导入模块: from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iinstrument_management_service.InstrumentManagementServiceClient import stop_platform_agent_instance [as 别名]
#.........这里部分代码省略.........
self.dataprocessclient.activate_data_process(platform_data_process_id)
self.addCleanup(self.dataprocessclient.delete_data_process, platform_data_process_id)
#-------------------------------
# Launch Base Platform AgentInstance, connect to the resource agent client
#-------------------------------
agent_instance_id = base_platform_objs['agent_instance_id']
log.debug("about to call imsclient.start_platform_agent_instance with id=%s", agent_instance_id)
pid = self.imsclient.start_platform_agent_instance(platform_agent_instance_id=agent_instance_id)
log.debug("start_platform_agent_instance returned pid=%s", pid)
#wait for start
instance_obj = self.imsclient.read_platform_agent_instance(agent_instance_id)
gate = ProcessStateGate(self.processdispatchclient.read_process,
instance_obj.agent_process_id,
ProcessStateEnum.RUNNING)
self.assertTrue(gate.await(90), "The platform agent instance did not spawn in 90 seconds")
agent_instance_obj= self.imsclient.read_instrument_agent_instance(agent_instance_id)
log.debug('test_oms_create_and_launch: Platform agent instance obj: %s', str(agent_instance_obj))
# Start a resource agent client to talk with the instrument agent.
self._pa_client = ResourceAgentClient('paclient', name=agent_instance_obj.agent_process_id, process=FakeProcess())
log.debug(" test_oms_create_and_launch:: got pa client %s", str(self._pa_client))
log.debug("base_platform_config =\n%s", base_platform_config)
# ping_agent can be issued before INITIALIZE
retval = self._pa_client.ping_agent(timeout=TIMEOUT)
log.debug( 'Base Platform ping_agent = %s', str(retval) )
# issue INITIALIZE command to the base platform, which will launch the
# creation of the whole platform hierarchy rooted at base_platform_config['platform_id']
# cmd = AgentCommand(command=PlatformAgentEvent.INITIALIZE, kwargs=dict(plat_config=base_platform_config))
cmd = AgentCommand(command=PlatformAgentEvent.INITIALIZE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform INITIALIZE = %s', str(retval) )
# GO_ACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_ACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_ACTIVE = %s', str(retval) )
# RUN:
cmd = AgentCommand(command=PlatformAgentEvent.RUN)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RUN = %s', str(retval) )
# START_MONITORING:
cmd = AgentCommand(command=PlatformAgentEvent.START_MONITORING)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform START_MONITORING = %s', str(retval) )
# wait for data sample
# just wait for at least one -- see consume_data above
log.info("waiting for reception of a data sample...")
self._async_data_result.get(timeout=DATA_TIMEOUT)
self.assertTrue(len(self._samples_received) >= 1)
log.info("waiting a bit more for reception of more data samples...")
sleep(15)
log.info("Got data samples: %d", len(self._samples_received))
# wait for event
# just wait for at least one event -- see consume_event above
log.info("waiting for reception of an event...")
self._async_event_result.get(timeout=EVENT_TIMEOUT)
log.info("Received events: %s", len(self._events_received))
#get the extended platfrom which wil include platform aggreate status fields
extended_platform = self.imsclient.get_platform_device_extension(self.device_id)
# log.debug( 'test_single_platform extended_platform: %s', str(extended_platform) )
# log.debug( 'test_single_platform power_status_roll_up: %s', str(extended_platform.computed.power_status_roll_up.value) )
# log.debug( 'test_single_platform comms_status_roll_up: %s', str(extended_platform.computed.communications_status_roll_up.value) )
# STOP_MONITORING:
cmd = AgentCommand(command=PlatformAgentEvent.STOP_MONITORING)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform STOP_MONITORING = %s', str(retval) )
# GO_INACTIVE
cmd = AgentCommand(command=PlatformAgentEvent.GO_INACTIVE)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform GO_INACTIVE = %s', str(retval) )
# RESET: Resets the base platform agent, which includes termination of
# its sub-platforms processes:
cmd = AgentCommand(command=PlatformAgentEvent.RESET)
retval = self._pa_client.execute_agent(cmd, timeout=TIMEOUT)
log.debug( 'Base Platform RESET = %s', str(retval) )
#-------------------------------
# Stop Base Platform AgentInstance
#-------------------------------
self.imsclient.stop_platform_agent_instance(platform_agent_instance_id=agent_instance_id)