当前位置: 首页>>代码示例>>Python>>正文


Python ResourceAgentClient.get_agent_process_id方法代码示例

本文整理汇总了Python中pyon.agent.agent.ResourceAgentClient.get_agent_process_id方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceAgentClient.get_agent_process_id方法的具体用法?Python ResourceAgentClient.get_agent_process_id怎么用?Python ResourceAgentClient.get_agent_process_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.agent.agent.ResourceAgentClient的用法示例。


在下文中一共展示了ResourceAgentClient.get_agent_process_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_agent_registration

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import get_agent_process_id [as 别名]
    def test_agent_registration(self):
        self._start_container()

        idev = IonObject("TestInstrument", name="any_resource")
        idev_id, _ = self.container.resource_registry.create(idev)

        config = dict(agent=dict(resource_id=idev_id))
        pid1 = self.container.spawn_process('agent1', 'pyon.agent.test.test_agent', 'SampleAgent', config)

        rac = ResourceAgentClient(idev_id)
        rac_pid = rac.get_agent_process_id()
        rac_de = rac.get_agent_directory_entry()
        self.assertEquals(rac_pid, pid1)

        # Now fake a second agent directory entry that wasn't cleaned up
        self.container.directory.register("/Agents", "fake_pid",
            **dict(name="agent1",
                container=self.container.id,
                resource_id=idev_id,
                agent_id="fake"))

        entries = self.container.directory.find_by_value('/Agents', 'resource_id', idev_id)
        self.assertEquals(len(entries), 2)

        rac = ResourceAgentClient(idev_id)
        rac_pid1 = rac.get_agent_process_id()
        self.assertEquals(rac_pid1, "fake_pid")

        # Check cleanup side effect of agent client
        entries = self.container.directory.find_by_value('/Agents', 'resource_id', idev_id)
        self.assertEquals(len(entries), 1)

        # Now restore the original process id
        self.container.directory.register("/Agents", pid1,
            **dict(name="agent1",
                container=self.container.id,
                resource_id=idev_id,
                agent_id=rac_de.attributes["agent_id"]))

        rac = ResourceAgentClient(idev_id)
        rac_pid1 = rac.get_agent_process_id()
        self.assertEquals(rac_pid1, pid1)

        # Check cleanup side effect of agent client
        entries = self.container.directory.find_by_value('/Agents', 'resource_id', idev_id)
        self.assertEquals(len(entries), 1)

        self.container.terminate_process(pid1)
开发者ID:scion-network,项目名称:scioncc,代码行数:50,代码来源:test_agent.py


注:本文中的pyon.agent.agent.ResourceAgentClient.get_agent_process_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。