本文整理汇总了Python中Node.Node.get_all_nodes方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_all_nodes方法的具体用法?Python Node.get_all_nodes怎么用?Python Node.get_all_nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.get_all_nodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_orchestrator
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_all_nodes [as 别名]
def find_orchestrator():
in_nodes = Node.get_all_nodes(check_active=True)
for n in in_nodes:
if "orchestrator" in n.name:
global orchestrator
orchestrator = n
return
示例2: resume_cluster
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_all_nodes [as 别名]
def resume_cluster():
"""
Re-loads the cluster representation based on the VMs pre-existing on the IaaS and the 'save_file'
"""
log.info("Loading info from the IaaS")
global nodes, seeds, stash
if not isfile(save_file):
log.info("No existing created cluster")
return
saved_cluster = loads(open(save_file, 'r').read())
saved_nodes = list(set(saved_cluster['nodes']))
saved_seeds = list(set(saved_cluster['seeds']))
saved_stash = list(set(saved_cluster['stash']))
nodes[:] = []
seeds[:] = []
in_nodes = Node.get_all_nodes(check_active=True)
#check that all saved nodes actually exist
for n in saved_nodes:
if n not in [i.name for i in in_nodes]:
log.error("node %s does actually exist in the cloud, re-create the cluster" % n)
remove(save_file)
exit(-1)
for n in in_nodes:
if n.name not in saved_nodes+saved_seeds:
if n.name in saved_stash:
stash.append(n)
if "orchestrator" in n.name:
global orchestrator
orchestrator = n
continue
else:
if n.type == "seed":
seeds.append(n)
elif n.type == "node": nodes.append(n)
#sort nodes by name
nodes.sort(key=lambda x: x.name)
stash.sort(key=lambda x: x.name)
示例3: resume_cluster
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_all_nodes [as 别名]
def resume_cluster(self):
"""
Re-loads the cluster representation based on the VMs pre-existing on the IaaS and the 'save_file'
"""
self.log.info("Loading info from the IaaS")
if not isfile(self.save_file):
self.log.info("No existing created cluster")
saved_nodes = []
else:
saved_cluster = loads(open(self.save_file, 'r').read())
saved_nodes = saved_cluster['clients']
in_nodes = Node.get_all_nodes(check_active=True)
for n in in_nodes:
if n.name not in saved_nodes:
if "orchestrator" in n.name:
global orchestrator
orchestrator = n
self.log.debug('Found orchestrator %s' % n.name)
continue
else:
self.all_nodes.append(n)
#sort nodes by name
self.all_nodes.sort(key=lambda x: x.name)