本文整理汇总了Python中ClusterShell.Worker.Pdsh.WorkerPdsh.node_rc方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerPdsh.node_rc方法的具体用法?Python WorkerPdsh.node_rc怎么用?Python WorkerPdsh.node_rc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.Worker.Pdsh.WorkerPdsh
的用法示例。
在下文中一共展示了WorkerPdsh.node_rc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testWorkerPdshRetcodes
# 需要导入模块: from ClusterShell.Worker.Pdsh import WorkerPdsh [as 别名]
# 或者: from ClusterShell.Worker.Pdsh.WorkerPdsh import node_rc [as 别名]
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)
示例2: testWorkerPdshRetcodes
# 需要导入模块: from ClusterShell.Worker.Pdsh import WorkerPdsh [as 别名]
# 或者: from ClusterShell.Worker.Pdsh.WorkerPdsh import node_rc [as 别名]
def testWorkerPdshRetcodes(self):
"""test retcodes on distant pdsh workers"""
task = task_self()
self.assert_(task != None)
worker = WorkerPdsh("localhost", command="/bin/sh -c 'exit 3'",
handler=None, timeout=None)
task.schedule(worker)
task.resume()
cnt = 2
for rc, keys in worker.iter_retcodes():
cnt -= 1
self.assertEqual(rc, 3)
self.assertEqual(len(keys), 1)
self.assert_(keys[0] == "localhost")
self.assertEqual(cnt, 1)
for rc, keys in worker.iter_retcodes("localhost"):
cnt -= 1
self.assertEqual(rc, 3)
self.assertEqual(len(keys), 1)
self.assert_(keys[0] == "localhost")
self.assertEqual(cnt, 0)
# test node_retcode
self.assertEqual(worker.node_retcode("localhost"), 3) # 1.2.91+
self.assertEqual(worker.node_rc("localhost"), 3)
# test node_retcode failure
self.assertRaises(KeyError, worker.node_retcode, "dummy")
# test max retcode API
self.assertEqual(task.max_retcode(), 3)