本文整理汇总了Python中cloud.Compute.get_instance_id方法的典型用法代码示例。如果您正苦于以下问题:Python Compute.get_instance_id方法的具体用法?Python Compute.get_instance_id怎么用?Python Compute.get_instance_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.Compute
的用法示例。
在下文中一共展示了Compute.get_instance_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: backup_and_cleanup
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def backup_and_cleanup(dockid):
cont = SessContainer(dockid)
cont.stop()
cont.delete(backup=True)
JBoxSessionProps.detach_instance(Compute.get_install_id(), cont.get_name(), Compute.get_instance_id())
JBoxd.publish_perf_counters()
JBoxd.publish_anticipated_load()
示例2: publish_sessions
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def publish_sessions():
iid = Compute.get_instance_id()
for c in SessContainer.session_containers(allcontainers=True):
if ("Names" in c) and (c["Names"] is not None):
sessname = SessContainer(c["Id"]).get_name()
if sessname:
JBoxSessionProps.attach_instance(Compute.get_install_id(), sessname, iid, c["Status"])
示例3: publish_anticipated_load
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def publish_anticipated_load(session_name=None):
iid = Compute.get_instance_id()
if session_name is None:
nactive = BaseContainer.num_active(BaseContainer.SFX_INT)
else:
JBoxSessionProps.attach_instance(Compute.get_install_id(), session_name, iid, "Preparing")
nactive = BaseContainer.num_active(BaseContainer.SFX_INT) + 1
cont_load_pct = min(100, max(0, nactive * 100 / SessContainer.MAX_CONTAINERS))
self_load = max(Compute.get_instance_stats(iid, 'Load'), cont_load_pct)
Compute.publish_stats("Load", "Percent", self_load)
accept = Compute.should_accept_session(is_proposed_cluster_leader())
JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept)
示例4: get_api_status
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def get_api_status():
api_status = dict()
for c in BaseContainer.api_containers(allcontainers=True):
name = c["Names"][0] if (("Names" in c) and (c["Names"] is not None)) else c["Id"][0:12]
api_name = APIContainer.get_api_name_from_container_name(name)
if api_name is None:
continue
cnt = api_status.get(api_name, 0)
api_status[api_name] = cnt + 1
self_load = Compute.get_instance_stats(Compute.get_instance_id(), 'Load')
accept = Compute.should_accept_session(is_proposed_cluster_leader())
return {'load': self_load, 'accept': accept, 'api_status': api_status}
示例5: publish_instance_state
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def publish_instance_state():
iid = Compute.get_instance_id()
api_status = dict()
for c in BaseContainer.api_containers(allcontainers=True):
name = c["Names"][0] if (("Names" in c) and (c["Names"] is not None)) else c["Id"][0:12]
api_name = APIContainer.get_api_name_from_container_name(name)
if api_name is None:
continue
cnt = api_status.get(api_name, 0)
api_status[api_name] = cnt + 1
self_load = Compute.get_instance_stats(iid, 'Load')
accept = Compute.should_accept_session(is_proposed_cluster_leader())
JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept, api_status=api_status)
示例6: publish_sessions
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import get_instance_id [as 别名]
def publish_sessions():
iid = Compute.get_instance_id()
for c in SessContainer.session_containers(allcontainers=True):
if ('Names' in c) and (c['Names'] is not None):
JBoxSessionProps.attach_instance(Compute.get_install_id(), SessContainer(c['Id']).get_name(), iid,
c["Status"])