当前位置: 首页>>代码示例>>Python>>正文


Python Compute.get_instance_id方法代码示例

本文整理汇总了Python中juliabox.cloud.Compute.get_instance_id方法的典型用法代码示例。如果您正苦于以下问题:Python Compute.get_instance_id方法的具体用法?Python Compute.get_instance_id怎么用?Python Compute.get_instance_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在juliabox.cloud.Compute的用法示例。


在下文中一共展示了Compute.get_instance_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_cluster_leader

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_id [as 别名]
def is_cluster_leader():
    self_id = Compute.get_instance_id()
    cluster = Compute.get_install_id()
    instances = Compute.get_all_instances()
    leader = JBoxDynConfig.get_cluster_leader(cluster)
    img_recentness = Compute.get_image_recentness()
    JBoxDB.log_debug("cluster: %s. instances: %s. leader: %s. image recentness: %d",
                     cluster, repr(instances), repr(leader), img_recentness)

    # if none set, or set instance is dead elect self as leader, but wait till next cycle to prevent conflicts
    if (leader is None) or (leader not in instances) and (img_recentness >= 0):
        JBoxDB.log_info("setting self (%s) as cluster leader", self_id)
        try:
            JBoxDynConfig.set_cluster_leader(cluster, self_id)
        except:
            JBoxDB.log_info("error setting self (%s) as cluster leader, will retry", self_id)
        return False

    is_leader = (leader == self_id)

    # if running an older ami, step down from cluster leader
    if (img_recentness < 0) and is_leader:
        JBoxDB.log_info("unmarking self (%s) as cluster leader", self_id)
        JBoxDynConfig.unset_cluster_leader(cluster)
        return False

    return is_leader
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:29,代码来源:__init__.py

示例2: redirect_to_logged_in_instance

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_id [as 别名]
 def redirect_to_logged_in_instance(self, user_id):
     loggedin_instance = self.find_logged_in_instance(user_id)
     if loggedin_instance is not None \
             and loggedin_instance != Compute.get_instance_id() \
             and loggedin_instance != 'localhost':
         # redirect to the instance that has the user's session
         self.log_info("Already logged in to %s. Redirecting", loggedin_instance)
         redirect_ip = Compute.get_instance_local_ip(loggedin_instance)
         self.set_redirect_instance_id(redirect_ip)
         self.redirect('/')
         return True
     self.log_info("Logged in %s", "nowhere" if loggedin_instance is None else "here already")
     return False
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:15,代码来源:handler_base.py

示例3: try_launch_container

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_id [as 别名]
    def try_launch_container(cls, user_id, max_hop=False):
        sessname = unique_sessname(user_id)
        cont = SessContainer.get_by_name(sessname)
        cls.log_debug("have existing container for %s: %r", sessname, None != cont)
        if cont is not None:
            cls.log_debug("container running: %r", cont.is_running())

        if max_hop:
            self_load = Compute.get_instance_stats(Compute.get_instance_id(), 'Load')
            if self_load < 100:
                SessContainer.invalidate_container(sessname)
                JBoxAsyncJob.async_launch_by_name(sessname, user_id, True)
                return True

        is_leader = is_proposed_cluster_leader()
        if ((cont is None) or (not cont.is_running())) and (not Compute.should_accept_session(is_leader)):
            if cont is not None:
                SessContainer.invalidate_container(cont.get_name())
                JBoxAsyncJob.async_backup_and_cleanup(cont.dockid)
            return False

        SessContainer.invalidate_container(sessname)
        JBoxAsyncJob.async_launch_by_name(sessname, user_id, True)
        return True
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:26,代码来源:handler_base.py

示例4: is_proposed_cluster_leader

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_id [as 别名]
def is_proposed_cluster_leader():
    cluster = Compute.get_install_id()
    leader = JBoxDynConfig.get_cluster_leader(cluster)
    return leader == Compute.get_instance_id()
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:6,代码来源:__init__.py


注:本文中的juliabox.cloud.Compute.get_instance_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。