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


Python Compute.get_instance_local_ip方法代码示例

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


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

示例1: chk_and_launch_docker

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_local_ip [as 别名]
    def chk_and_launch_docker(self, user_id):
        if self.redirect_to_logged_in_instance(user_id):
            return

        nhops = int(self.get_argument('h', 0))
        numhopmax = JBoxCfg.get('numhopmax', 0)
        max_hop = nhops > numhopmax
        launched = self.try_launch_container(user_id, max_hop=max_hop)

        if launched:
            self.set_container_initialized(Compute.get_instance_local_ip(), user_id)
            self.rendertpl("loading.tpl",
                           user_id=user_id,
                           cfg=JBoxCfg.nv,
                           js_includes=JBPluginHandler.PLUGIN_JAVASCRIPTS)
            return

        self.unset_affinity()
        self.log_debug("at hop %d for user %s", nhops, user_id)
        if max_hop:
            if JBoxCfg.get('cloud_host.scale_down'):
                msg = "JuliaBox is experiencing a sudden surge. Please try in a few minutes while we increase our capacity."
            else:
                msg = "JuliaBox servers are fully loaded. Please try after sometime."
            self.log_error("Server maxed out. Can't launch container at hop %d for user %s", nhops, user_id)
            self.rendertpl("index.tpl", cfg=JBoxCfg.nv, state=self.state(error=msg, success=''))
        else:
            redirect_instance = Compute.get_redirect_instance_id()
            if redirect_instance is not None:
                redirect_ip = Compute.get_instance_local_ip(redirect_instance)
                self.set_redirect_instance_id(redirect_ip)
            self.redirect('/?h=' + str(nhops + 1))
开发者ID:nkottary,项目名称:JuliaBox,代码行数:34,代码来源:main.py

示例2: post_auth_launch_container

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_local_ip [as 别名]
    def post_auth_launch_container(self, user_id):
        for plugin in JBPluginHandler.jbox_get_plugins(JBPluginHandler.JBP_HANDLER_POST_AUTH):
            self.log_info("Passing user %r to post auth plugin %r", user_id, plugin)
            pass_allowed = plugin.process_user_id(self, user_id)
            if not pass_allowed:
                self.log_info('Login restricted for user %r by plugin %r', user_id, plugin)
                return

        jbuser = JBoxUserV2(user_id, create=True)

        if not JBPluginHandler.is_user_activated(jbuser):
            self.redirect('/?pending_activation=' + user_id)
            return

        self.set_authenticated(user_id)
        if jbuser.is_new:
            jbuser.save()

        if self.redirect_to_logged_in_instance(user_id):
            return

        # check if the current instance is appropriate for launching this
        if self.try_launch_container(user_id, max_hop=False):
            self.set_container_initialized(Compute.get_instance_local_ip(), user_id)
        else:
            # redirect to an appropriate instance
            redirect_instance = Compute.get_redirect_instance_id()
            if redirect_instance is not None:
                redirect_ip = Compute.get_instance_local_ip(redirect_instance)
                self.set_redirect_instance_id(redirect_ip)
        self.redirect('/')
开发者ID:kleopatra999,项目名称:JuliaBox,代码行数:33,代码来源:handler_base.py

示例3: redirect_to_logged_in_instance

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_local_ip [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

示例4: post_auth_launch_container

# 需要导入模块: from juliabox.cloud import Compute [as 别名]
# 或者: from juliabox.cloud.Compute import get_instance_local_ip [as 别名]
    def post_auth_launch_container(self, user_id):
        jbuser = JBoxUserV2(user_id, create=True)
        if not JBPluginHandler.is_user_activated(jbuser):
            self.redirect('/?pending_activation=' + user_id)
            return

        self.set_authenticated(user_id)
        if jbuser.is_new:
            jbuser.save()

        if self.redirect_to_logged_in_instance(user_id):
            return

        # check if the current instance is appropriate for launching this
        if self.try_launch_container(user_id, max_hop=False):
            self.set_container_initialized(Compute.get_instance_local_ip(), user_id)
        else:
            # redirect to an appropriate instance
            redirect_instance = Compute.get_redirect_instance_id()
            if redirect_instance is not None:
                redirect_ip = Compute.get_instance_local_ip(redirect_instance)
                self.set_redirect_instance_id(redirect_ip)
        self.redirect('/')
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:25,代码来源:handler_base.py


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