本文整理匯總了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