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


Python Pdsh.WorkerPdsh类代码示例

本文整理汇总了Python中ClusterShell.Worker.Pdsh.WorkerPdsh的典型用法代码示例。如果您正苦于以下问题:Python WorkerPdsh类的具体用法?Python WorkerPdsh怎么用?Python WorkerPdsh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testWorkerPdshBuffers

    def testWorkerPdshBuffers(self):
        """test buffers at pdsh worker level"""
        task = task_self()
        self.assert_(task != None)

        worker = WorkerPdsh("localhost", command="printf 'foo\nbar\nxxx\n'",
                            handler=None, timeout=None)
        task.schedule(worker)
        task.resume()

        cnt = 2
        for buf, nodes in worker.iter_buffers():
            cnt -= 1
            if buf == "foo\nbar\nxxx\n":
                self.assertEqual(len(nodes), 1)
                self.assertEqual(str(nodes), "localhost")
        self.assertEqual(cnt, 1)
        # new check in 1.7 to ensure match_keys is not a string
        testgen = worker.iter_buffers("localhost")
        # cast to list to effectively iterate
        self.assertRaises(TypeError, list, testgen)
        # and also fixed an issue when match_keys was an empty list
        for buf, nodes in worker.iter_buffers([]):
            self.assertFalse("Found buffer with empty match_keys?!")
        for buf, nodes in worker.iter_buffers(["localhost"]):
            cnt -= 1
            if buf == "foo\nbar\nxxx\n":
                self.assertEqual(len(nodes), 1)
                self.assertEqual(str(nodes), "localhost")
        self.assertEqual(cnt, 0)
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:30,代码来源:TaskDistantPdshTest.py

示例2: testWorkerPdshRetcodes

    def testWorkerPdshRetcodes(self):
        # test retcodes on distant pdsh workers
        worker = WorkerPdsh(HOSTNAME, command="/bin/sh -c 'exit 3'",
                            handler=None, timeout=None)
        self._task.schedule(worker)
        self._task.resume()

        cnt = 2
        for rc, keys in worker.iter_retcodes():
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assertEqual(keys[0], HOSTNAME)

        self.assertEqual(cnt, 1)

        for rc, keys in worker.iter_retcodes(HOSTNAME):
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(len(keys), 1)
            self.assertEqual(keys[0], HOSTNAME)

        self.assertEqual(cnt, 0)

        # test node_retcode
        self.assertEqual(worker.node_retcode(HOSTNAME), 3)   # 1.2.91+
        self.assertEqual(worker.node_rc(HOSTNAME), 3)

        # test node_retcode failure
        self.assertRaises(KeyError, worker.node_retcode, "dummy")

        # test max retcode API
        self.assertEqual(self._task.max_retcode(), 3)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:33,代码来源:TaskDistantPdshMixin.py

示例3: testWorkerAbortSanity

 def testWorkerAbortSanity(self):
     """test WorkerPdsh abort() (sanity)"""
     task = task_self()
     # test noop abort() on unscheduled worker
     worker = WorkerPdsh("localhost", command="sleep 1", handler=None,
                         timeout=None)
     worker.abort()
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:7,代码来源:TaskDistantPdshTest.py

示例4: testExplicitPdshWorker

 def testExplicitPdshWorker(self):
     # test simple localhost command with explicit pdsh worker
     # init worker
     worker = WorkerPdsh(HOSTNAME, command="echo alright", handler=None)
     self._task.schedule(worker)
     # run task
     self._task.resume()
     # test output
     self.assertEqual(worker.node_buffer(HOSTNAME), b"alright")
开发者ID:cea-hpc,项目名称:clustershell,代码行数:9,代码来源:TaskDistantPdshMixin.py

示例5: testEscapePdsh2

 def testEscapePdsh2(self):
     # test distant worker (pdsh) cmd with non-escaped variable
     cmd = r"export CSTEST=foobar; /bin/echo $CSTEST | sed 's/\ foo/bar/'"
     worker = WorkerPdsh(HOSTNAME, command=cmd, handler=None, timeout=None)
     self._task.schedule(worker)
     # execute
     self._task.resume()
     # read result
     self.assertEqual(worker.node_buffer(HOSTNAME), b"foobar")
开发者ID:cea-hpc,项目名称:clustershell,代码行数:9,代码来源:TaskDistantPdshMixin.py

示例6: testEscapePdsh2

 def testEscapePdsh2(self):
     """test distant worker (pdsh) cmd with non-escaped variable"""
     worker = WorkerPdsh("localhost", command="export CSTEST=foobar; /bin/echo $CSTEST | sed 's/\ foo/bar/'",
             handler=None, timeout=None)
     self._task.schedule(worker)
     # execute
     self._task.resume()
     # read result
     self.assertEqual(worker.node_buffer("localhost"), "foobar")
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:9,代码来源:TaskDistantPdshTest.py

示例7: testExplicitPdshWorker

 def testExplicitPdshWorker(self):
     """test simple localhost command with explicit pdsh worker"""
     # init worker
     worker = WorkerPdsh("localhost", command="echo alright", handler=None, timeout=5)
     self.assert_(worker != None)
     self._task.schedule(worker)
     # run task
     self._task.resume()
     # test output
     self.assertEqual(worker.node_buffer("localhost"), "alright")
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:10,代码来源:TaskDistantPdshTest.py

示例8: testEscapePdsh

 def testEscapePdsh(self):
     # test distant worker (pdsh) cmd with escaped variable
     worker = WorkerPdsh(HOSTNAME, command="export CSTEST=foobar; /bin/echo \$CSTEST | sed 's/\ foo/bar/'",
             handler=None, timeout=None)
     #task.set_info("debug", True)
     self._task.schedule(worker)
     # execute
     self._task.resume()
     # read result
     self.assertEqual(worker.node_buffer(HOSTNAME), "$CSTEST")
开发者ID:brianpkelly,项目名称:clustershell,代码行数:10,代码来源:TaskDistantPdshMixin.py

示例9: testExplicitPdshWorkerWithOptions

 def testExplicitPdshWorkerWithOptions(self):
     self._task.set_info("pdsh_path", "/usr/bin/pdsh -S")
     worker = WorkerPdsh(HOSTNAME, command="echo alright", handler=None)
     self._task.schedule(worker)
     # run task
     self._task.resume()
     # test output
     self.assertEqual(worker.node_buffer(HOSTNAME), b"alright")
     # clear options after test
     task_cleanup()
     self.assertEqual(task_self().info("pdsh_path"), None)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:11,代码来源:TaskDistantPdshMixin.py

示例10: testShellPdshEventsNoReadNoTimeout

 def testShellPdshEventsNoReadNoTimeout(self):
     # test triggered events (no read, no timeout) with explicit pdsh worker
     test_eh = self.__class__.TEventHandlerChecker(self)
     worker = WorkerPdsh(HOSTNAME, command="sleep 2", handler=test_eh,
                         timeout=None)
     self._task.schedule(worker)
     # run task
     self._task.resume()
     # test events received: start, close
     self.assertEqual(test_eh.flags, EV_START | EV_PICKUP | EV_HUP | EV_CLOSE)
     self.assertEqual(worker.node_buffer(HOSTNAME), None)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:11,代码来源:TaskDistantPdshMixin.py

示例11: testExplicitWorkerPdshShellEventsWithTimeout

 def testExplicitWorkerPdshShellEventsWithTimeout(self):
     # test triggered events (with timeout) with explicit pdsh worker
     test_eh = self.__class__.TEventHandlerChecker(self)
     worker = WorkerPdsh(HOSTNAME, command="echo alright && sleep 10",
                         handler=test_eh, timeout=2)
     self._task.schedule(worker)
     # run task
     self._task.resume()
     # test events received: start, read, timeout, close
     self.assertEqual(test_eh.flags, EV_START | EV_PICKUP | EV_READ | EV_TIMEOUT | EV_CLOSE)
     self.assertEqual(worker.node_buffer(HOSTNAME), b"alright")
开发者ID:cea-hpc,项目名称:clustershell,代码行数:11,代码来源:TaskDistantPdshMixin.py

示例12: testWorkerPdshNodeErrors

    def testWorkerPdshNodeErrors(self):
        # test iter_node_errors on distant pdsh workers
        worker = WorkerPdsh(HOSTNAME, command="/usr/bin/printf 'foo\nbar\nxxx\n' 1>&2",
                            handler=None, timeout=None, stderr=True)
        self._task.schedule(worker)
        self._task.resume()

        cnt = 1
        for node, buf in worker.iter_node_errors():
            cnt -= 1
            if buf == b"foo\nbar\nxxx\n":
                self.assertEqual(node, HOSTNAME)
        self.assertEqual(cnt, 0)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:13,代码来源:TaskDistantPdshMixin.py

示例13: testShellPdshStderrWithHandler

    def testShellPdshStderrWithHandler(self):
        """test reading stderr of distant pdsh worker on event handler"""
        class StdErrHandler(EventHandler):
            def ev_error(self, worker):
                assert worker.last_error() == "something wrong"

        worker = WorkerPdsh("localhost", command="echo something wrong 1>&2",
                handler=StdErrHandler(), timeout=None)
        self._task.schedule(worker)
        self._task.resume()
        for buf, nodes in worker.iter_errors():
            self.assertEqual(buf, "something wrong")
        for buf, nodes in worker.iter_errors(['localhost']):
            self.assertEqual(buf, "something wrong")
开发者ID:ChristianKniep,项目名称:clustershell,代码行数:14,代码来源:TaskDistantPdshTest.py

示例14: testWorkerNodeRetcodes

    def testWorkerNodeRetcodes(self):
        # test iter_node_retcodes on distant pdsh workers
        worker = WorkerPdsh(HOSTNAME, command="/bin/sh -c 'exit 3'",
                            handler=None, timeout=None)
        self._task.schedule(worker)
        self._task.resume()

        cnt = 1
        for node, rc in worker.iter_node_retcodes():
            cnt -= 1
            self.assertEqual(rc, 3)
            self.assertEqual(node, HOSTNAME)

        self.assertEqual(cnt, 0)
开发者ID:cea-hpc,项目名称:clustershell,代码行数:14,代码来源:TaskDistantPdshMixin.py

示例15: testWorkerPdshGetCommand

 def testWorkerPdshGetCommand(self):
     # test worker.command with WorkerPdsh
     worker1 = WorkerPdsh(HOSTNAME, command="/bin/echo foo bar fuu",
                          handler=None, timeout=5)
     self._task.schedule(worker1)
     worker2 = WorkerPdsh(HOSTNAME, command="/bin/echo blah blah foo",
                          handler=None, timeout=5)
     self._task.schedule(worker2)
     # run task
     self._task.resume()
     # test output
     self.assertEqual(worker1.node_buffer(HOSTNAME), b"foo bar fuu")
     self.assertEqual(worker1.command, "/bin/echo foo bar fuu")
     self.assertEqual(worker2.node_buffer(HOSTNAME), b"blah blah foo")
     self.assertEqual(worker2.command, "/bin/echo blah blah foo")
开发者ID:cea-hpc,项目名称:clustershell,代码行数:15,代码来源:TaskDistantPdshMixin.py


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