本文整理汇总了Python中ClusterShell.NodeSet.update方法的典型用法代码示例。如果您正苦于以下问题:Python NodeSet.update方法的具体用法?Python NodeSet.update怎么用?Python NodeSet.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.NodeSet
的用法示例。
在下文中一共展示了NodeSet.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGroupGroups
# 需要导入模块: from ClusterShell import NodeSet [as 别名]
# 或者: from ClusterShell.NodeSet import update [as 别名]
def testGroupGroups(self):
"""test NodeSet.groups()"""
nodeset = NodeSet("montana[32-37,42-55]")
self.assertEqual(sorted(nodeset.groups().keys()), ['@all', '@chassis1', '@chassis10', '@chassis11', '@chassis12', '@chassis2', '@chassis3', '@chassis6', '@chassis7', '@chassis8', '@chassis9', '@compute'])
testns = NodeSet()
for gnodes, inodes in nodeset.groups().itervalues():
testns.update(inodes)
self.assertEqual(testns, nodeset)
示例2: testGroupResolverND
# 需要导入模块: from ClusterShell import NodeSet [as 别名]
# 或者: from ClusterShell.NodeSet import update [as 别名]
def testGroupResolverND(self):
"""test NodeSet with simple custom GroupResolver (nD)"""
test_groups4 = makeTestG4()
source = UpcallGroupSource("simple",
"sed -n 's/^$GROUP:\(.*\)/\\1/p' %s" % test_groups4.name,
"sed -n 's/^all:\(.*\)/\\1/p' %s" % test_groups4.name,
"sed -n 's/^\([0-9A-Za-z_-]*\):.*/\\1/p' %s" % test_groups4.name,
None)
# create custom resolver with default source
res = GroupResolver(source)
self.assertFalse(res.has_node_groups())
self.assertFalse(res.has_node_groups("dummy_namespace"))
nodeset = NodeSet("@rack-x1y2", resolver=res)
self.assertEqual(nodeset, NodeSet("idaho[2-3]z1"))
self.assertEqual(str(nodeset), "idaho[2-3]z1")
nodeset = NodeSet("@rack-y1", resolver=res)
self.assertEqual(str(nodeset), "idaho[1-2,4-5]z1")
nodeset = NodeSet("@rack-all", resolver=res)
self.assertEqual(str(nodeset), "idaho[1-7]z1")
# test NESTED nD groups()
self.assertEqual(sorted(nodeset.groups().keys()),
['@rack-all', '@rack-x1', '@rack-x1y1', '@rack-x1y2',
'@rack-x2', '@rack-x2y1', '@rack-x2y2', '@rack-y1',
'@rack-y2'])
self.assertEqual(sorted(nodeset.groups(groupsource="simple").keys()),
['@simple:rack-all', '@simple:rack-x1',
'@simple:rack-x1y1', '@simple:rack-x1y2',
'@simple:rack-x2', '@simple:rack-x2y1',
'@simple:rack-x2y2', '@simple:rack-y1',
'@simple:rack-y2'])
self.assertEqual(sorted(nodeset.groups(groupsource="simple",
noprefix=True).keys()),
['@rack-all', '@rack-x1', '@rack-x1y1', '@rack-x1y2',
'@rack-x2', '@rack-x2y1', '@rack-x2y2', '@rack-y1',
'@rack-y2'])
testns = NodeSet()
for gnodes, inodes in nodeset.groups().itervalues():
testns.update(inodes)
self.assertEqual(testns, nodeset)
# more tests with nested groups
nodeset = NodeSet("idaho5z1", resolver=res)
self.assertEqual(sorted(nodeset.groups().keys()),
['@rack-all', '@rack-x2', '@rack-x2y1', '@rack-y1'])
nodeset = NodeSet("idaho5z1,idaho4z1", resolver=res)
self.assertEqual(sorted(nodeset.groups().keys()),
['@rack-all', '@rack-x2', '@rack-x2y1', '@rack-y1'])
nodeset = NodeSet("idaho5z1,idaho7z1", resolver=res)
self.assertEqual(sorted(nodeset.groups().keys()),
['@rack-all', '@rack-x2', '@rack-x2y1', '@rack-x2y2',
'@rack-y1', '@rack-y2'])
示例3: testGroupListDefault
# 需要导入模块: from ClusterShell import NodeSet [as 别名]
# 或者: from ClusterShell.NodeSet import update [as 别名]
def testGroupListDefault(self):
"""test NodeSet group listing GroupResolver.grouplist()"""
groups = ClusterShell.NodeSet.RESOLVER_STD_GROUP.grouplist()
self.assertEqual(len(groups), 20)
helper_groups = grouplist()
self.assertEqual(len(helper_groups), 20)
total = 0
nodes = NodeSet()
for group in groups:
ns = NodeSet("@%s" % group)
total += len(ns)
nodes.update(ns)
self.assertEqual(total, 310)
all_nodes = NodeSet.fromall()
self.assertEqual(len(all_nodes), len(nodes))
self.assertEqual(all_nodes, nodes)