def launch_session(name, email, reuse=True): try: JBoxd._wait_for_session_backup(name) VolMgr.refresh_disk_use_status() JBoxContainer.launch_by_name(name, email, reuse=reuse) finally: JBoxd.finish_thread()
def chk_and_launch_docker(self, sessname, creds, authtok, user_id): cont = JBoxContainer.get_by_name(sessname) nhops = int(self.get_argument('h', 0)) self.log_debug("got hop " + repr(nhops) + " for session " + repr(sessname)) self.log_debug("have existing container for " + repr(sessname) + ": " + repr(None != cont)) if cont is not None: self.log_debug("container running: " + str(cont.is_running())) if ((None == cont) or (not cont.is_running())) and (not CloudHelper.should_accept_session()): if None != cont: cont.backup() cont.delete() self.clear_container_cookies() self.set_header('Connection', 'close') self.request.connection.no_keep_alive = True if nhops > self.config('numhopmax', 0): self.rendertpl("index.tpl", cfg=self.config(), state=self.state( error="Maximum number of JuliaBox instances active. Please try after sometime.", success='')) else: self.redirect('/?h=' + str(nhops + 1)) else: cont = JBoxContainer.launch_by_name(sessname, user_id, True) (shellport, uplport, ipnbport) = cont.get_host_ports() sign = signstr(sessname + str(shellport) + str(uplport) + str(ipnbport), self.config("sesskey")) self.set_container_cookies({ "sessname": sessname, "hostshell": shellport, "hostupload": uplport, "hostipnb": ipnbport, "sign": sign }) self.set_lb_tracker_cookie() self.rendertpl("ipnbsess.tpl", sessname=sessname, cfg=self.config(), creds=creds, authtok=authtok, user_id=user_id)
def chk_and_launch_docker(self, sessname, creds, authtok, user_id): cont = JBoxContainer.get_by_name(sessname) nhops = int(self.get_argument('h', 0)) self.log_debug("got hop " + repr(nhops) + " for session " + repr(sessname)) self.log_debug("have existing container for " + repr(sessname) + ": " + repr(None != cont)) if cont is not None: self.log_debug("container running: " + str(cont.is_running())) if ((None == cont) or (not cont.is_running())) and ( not CloudHelper.should_accept_session()): if None != cont: cont.backup() cont.delete() self.clear_container_cookies() self.set_header('Connection', 'close') self.request.connection.no_keep_alive = True if nhops > self.config('numhopmax', 0): self.rendertpl( "index.tpl", cfg=self.config(), state=self.state( error= "Maximum number of JuliaBox instances active. Please try after sometime.", success='')) else: self.redirect('/?h=' + str(nhops + 1)) else: cont = JBoxContainer.launch_by_name(sessname, True) (shellport, uplport, ipnbport) = cont.get_host_ports() sign = signstr( sessname + str(shellport) + str(uplport) + str(ipnbport), self.config("sesskey")) self.set_container_cookies({ "sessname": sessname, "hostshell": shellport, "hostupload": uplport, "hostipnb": ipnbport, "sign": sign }) self.set_lb_tracker_cookie() self.rendertpl("ipnbsess.tpl", sessname=sessname, cfg=self.config(), creds=creds, authtok=authtok, user_id=user_id)