本文整理汇总了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))
示例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('/')
示例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
示例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('/')