本文整理汇总了Python中cloud.Compute.get_all_instances方法的典型用法代码示例。如果您正苦于以下问题:Python Compute.get_all_instances方法的具体用法?Python Compute.get_all_instances怎么用?Python Compute.get_all_instances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.Compute
的用法示例。
在下文中一共展示了Compute.get_all_instances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_juliabox_status
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_all_instances [as 别名]
def update_juliabox_status():
instances = Compute.get_all_instances()
in_error = 0
HTML = "<html><body><center><pre>\nJuliaBox is Up.\n\nLast updated: " + datetime.datetime.now().isoformat() + " UTC\n\nLoads: "
for inst in instances:
try:
status = JBoxAsyncJob.sync_api_status(inst)['data']
HTML += (str(status['load']) + '% ')
except:
in_error += 1
pass
HTML += ("\n\nErrors: " + str(in_error) + "\n\nAWS Status: <a href='http://status.aws.amazon.com/'>status.aws.amazon.com</a></pre></center></body></html>")
plugin = JBPluginCloud.jbox_get_plugin(JBPluginCloud.JBP_BUCKETSTORE)
bkt = JBoxCfg.get("cloud_host.status_bucket")
if plugin is not None and bkt is not None:
try:
f = open("/tmp/index.html", "w")
f.write(HTML)
f.close()
plugin.push(bkt, "/tmp/index.html")
finally:
os.remove("/tmp/index.html")
else:
JBox.log_debug("Status: %s", HTML)
return None