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


Python interactive.SessContainer类代码示例

本文整理汇总了Python中juliabox.interactive.SessContainer的典型用法代码示例。如果您正苦于以下问题:Python SessContainer类的具体用法?Python SessContainer怎么用?Python SessContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: do_housekeeping

    def do_housekeeping():
        terminating = False
        server_delete_timeout = JBoxCfg.get('interactive.expire')
        inactive_timeout = JBoxCfg.get('interactive.inactivity_timeout')
        SessContainer.maintain(max_timeout=server_delete_timeout, inactive_timeout=inactive_timeout)
        is_leader = is_cluster_leader()

        if is_leader:
            terminating = False
        else:
            try:
                terminating = JBoxAsyncJob.sync_is_terminating()
                if terminating['code'] == 0:
                    terminating = terminating['data']
                else:
                    JBox.log_error("Error checking if instance is terminating. Assuming False.")
                    terminating = False
            except:
                JBox.log_error("Exception checking if instance is terminating. Assuming False.")
                terminating = False

        if is_leader:
            JBox.log_info("I am the cluster leader")
            JBox.update_juliabox_status()
            JBox.monitor_registrations()
            if not JBoxDynConfig.is_stat_collected_within(Compute.get_install_id(), 1):
                JBoxAsyncJob.async_collect_stats()

        if terminating:
            JBox.log_warn("terminating to scale down")
        else:
            JBox.do_update_user_home_image()
            JBoxAsyncJob.async_plugin_maintenance(is_leader)
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:33,代码来源:srvr_jbox.py

示例2: __init__

    def __init__(self):
        LoggerMixin.configure()
        db.configure()
        Compute.configure()
        SessContainer.configure()
        VolMgr.configure()

        JBoxAsyncJob.configure()
        JBoxAsyncJob.init(JBoxAsyncJob.MODE_PUB)

        self.application = tornado.web.Application(handlers=[
            (r"/", MainHandler),
            (r"/jboxadmin/", AdminHandler),
            (r"/jboxping/", PingHandler),
            (r"/jboxcors/", CorsHandler)
        ])
        JBPluginHandler.add_plugin_handlers(self.application)
        JBPluginUI.create_include_files()

        # cookie_secret = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in xrange(32))
        # use sesskey as cookie secret to be able to span multiple tornado servers
        self.application.settings["cookie_secret"] = JBoxCfg.get('sesskey')
        self.application.settings["plugin_features"] = JBox.get_pluggedin_features()
        self.application.listen(JBoxCfg.get('interactive.manager_port'), address=socket.gethostname())
        self.application.listen(JBoxCfg.get('interactive.manager_port'), address='localhost')

        self.ioloop = tornado.ioloop.IOLoop.instance()

        # run container maintainence every 5 minutes
        run_interval = 5 * 60 * 1000
        self.log_info("Container maintenance every " + str(run_interval / (60 * 1000)) + " minutes")
        self.ct = tornado.ioloop.PeriodicCallback(JBox.do_housekeeping, run_interval, self.ioloop)
        self.sigct = tornado.ioloop.PeriodicCallback(JBox.do_signals, 1000, self.ioloop)
开发者ID:vk1975,项目名称:JuliaBox,代码行数:33,代码来源:srvr_jbox.py

示例3: handle_if_logout

 def handle_if_logout(self, cont):
     logout = self.get_argument('logout', False)
     if logout == 'me':
         SessContainer.invalidate_container(cont.get_name())
         JBoxAsyncJob.async_backup_and_cleanup(cont.dockid)
         response = {'code': 0, 'data': ''}
         self.write(response)
         return True
     return False
开发者ID:Emram,项目名称:JuliaBox,代码行数:9,代码来源:admin.py

示例4: get

 def get(self):
     valid_req = self.is_valid_req()
     sessname = self.get_session_id(validate=False)
     if valid_req:
         SessContainer.record_ping("/" + sessname)
         self.set_status(status_code=204)
         self.finish()
     else:
         self.log_warn("Invalid ping request for " + sessname)
         self.send_error(status_code=403)
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:10,代码来源:ping.py

示例5: post

    def post(self):
        self.log_debug("Homework handler got POST request")
        sessname = self.get_session_id()
        user_id = self.get_user_id()
        if (sessname is None) or (user_id is None):
            self.log_info("Homework handler got invalid sessname[%r] or user_id[%r]", sessname, user_id)
            self.send_error()
            return

        user = JBoxUserV2(user_id)
        is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
        course_owner = is_admin or user.has_role(JBoxUserV2.ROLE_OFFER_COURSES)
        cont = SessContainer.get_by_name(sessname)
        self.log_info("user_id[%r], is_admin[%r], course_owner[%r]", user_id, is_admin, course_owner)

        if cont is None:
            self.log_info("user_id[%r] container not found", user_id)
            self.send_error()
            return

        courses_offered = user.get_courses_offered()

        if self.handle_if_check(user_id):
            return
        if self.handle_create_course(user_id):
            return
        if self.handle_get_metadata(is_admin, courses_offered):
            return
        if self.handle_if_report(user_id, is_admin, courses_offered):
            return

        self.log_error("no handlers found")
        # only AJAX requests responded to
        self.send_error()
开发者ID:Emram,项目名称:JuliaBox,代码行数:34,代码来源:course_homework.py

示例6: publish_sessions

 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"])
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:7,代码来源:srvr_jboxd.py

示例7: __init__

    def __init__(self):
        LoggerMixin.configure()
        db.configure()
        Compute.configure()
        SessContainer.configure()
        APIContainer.configure()
        VolMgr.configure()

        JBoxAsyncJob.configure()
        JBoxAsyncJob.init(JBoxAsyncJob.MODE_SUB)

        self.log_debug("Container manager listening on ports: %s", repr(JBoxCfg.get('container_manager_ports')))
        JBoxd.QUEUE = JBoxAsyncJob.get()

        JBoxd.MAX_ACTIVATIONS_PER_SEC = JBoxCfg.get('user_activation.max_activations_per_sec')
        JBoxd.MAX_AUTO_ACTIVATIONS_PER_RUN = JBoxCfg.get('user_activation.max_activations_per_run')
        JBoxd.ACTIVATION_SUBJECT = JBoxCfg.get('user_activation.mail_subject')
        JBoxd.ACTIVATION_BODY = JBoxCfg.get('user_activation.mail_body')
        JBoxd.ACTIVATION_SENDER = JBoxCfg.get('user_activation.sender')
开发者ID:Emram,项目名称:JuliaBox,代码行数:19,代码来源:srvr_jboxd.py

示例8: get

    def get(self):
        sessname = self.get_session_id()
        user_id = self.get_user_id()
        if (sessname is None) or (user_id is None):
            self.send_error()
            return

        user = JBoxUserV2(user_id)
        is_admin = sessname in JBoxCfg.get("admin_sessnames", [])
        manage_containers = is_admin or user.has_role(JBoxUserV2.ROLE_MANAGE_CONTAINERS)
        show_report = is_admin or user.has_role(JBoxUserV2.ROLE_ACCESS_STATS)
        cont = SessContainer.get_by_name(sessname)

        if cont is None:
            self.send_error()
            return

        if self.handle_if_logout(cont):
            return
        if self.handle_if_stats(is_admin or show_report):
            return
        if self.handle_if_show_cfg(is_admin):
            return
        if self.handle_if_instance_info(is_admin):
            return
        if self.handle_switch_julia_img(user):
            return
        if self.handle_if_open_port(sessname, user_id):
            return

        juliaboxver, _upgrade_available = self.get_upgrade_available(cont)

        jimg_type = 0
        if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP):
            jimg_type = JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP

        expire = JBoxCfg.get('interactive.expire')
        d = dict(
            manage_containers=manage_containers,
            show_report=show_report,
            sessname=sessname,
            user_id=user_id,
            created=isodate.datetime_isoformat(cont.time_created()),
            started=isodate.datetime_isoformat(cont.time_started()),
            allowed_till=isodate.datetime_isoformat((cont.time_started() + timedelta(seconds=expire))),
            mem=cont.get_memory_allocated(),
            cpu=cont.get_cpu_allocated(),
            disk=cont.get_disk_allocated(),
            expire=expire,
            juliaboxver=juliaboxver,
            jimg_type=jimg_type
        )

        self.rendertpl("ipnbadmin.tpl", d=d)
开发者ID:Emram,项目名称:JuliaBox,代码行数:54,代码来源:admin.py

示例9: do_periodic_task

 def do_periodic_task(_mode):
     active_clusters = UserCluster.list_all_groupids()
     ParallelHousekeep.log_info("%d active clusters", len(active_clusters))
     if len(active_clusters) == 0:
         return
     active_sessions = SessContainer.get_active_sessions()
     for cluster_id in active_clusters:
         sess_id = "/" + UserCluster.sessname_for_cluster(cluster_id)
         if sess_id not in active_sessions:
             ParallelHousekeep.log_info("Session (%s) corresponding to cluster (%s) not found. Terminating cluster.",
                                        sess_id, cluster_id)
             ParallelHousekeep.terminate_or_delete_cluster(cluster_id)
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:12,代码来源:parallel_housekeep.py

示例10: backup_and_cleanup

 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()
开发者ID:nkottary,项目名称:JuliaBox,代码行数:7,代码来源:srvr_jboxd.py

示例11: is_valid_req

    def is_valid_req(self):
        sessname = self.get_session_id()
        if sessname is None:
            return False

        ports = self.get_ports()
        container_ports = (ports[JBoxCookies.COOKIE_PORT_SHELL],
                           ports[JBoxCookies.COOKIE_PORT_UPL],
                           ports[JBoxCookies.COOKIE_PORT_IPNB])
        if not SessContainer.is_valid_container("/" + sessname, container_ports):
            self.log_info('not valid req. container deleted or ports not matching')
            return False

        return True
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:14,代码来源:handler_base.py

示例12: refresh_disk_use_status

    def refresh_disk_use_status(container_id_list=None):
        JBoxDefaultPackagesVol.LOCK.acquire()
        bundles = set()
        try:
            if container_id_list is None:
                container_id_list = [cdesc['Id'] for cdesc in SessContainer.session_containers(allcontainers=True)]

            for cid in container_id_list:
                mount_points = JBoxDefaultPackagesVol._get_package_mounts_used(cid)
                bundles.update(mount_points)

            JBoxDefaultPackagesVol.BUNDLES_IN_USE = bundles
            JBoxDefaultPackagesVol.log_info("Packages in use: %r", bundles)
        finally:
            JBoxDefaultPackagesVol.LOCK.release()
开发者ID:EricForgy,项目名称:JuliaBox,代码行数:15,代码来源:defpkg.py

示例13: do_task

    def do_task(plugin_type, data):
        if plugin_type != JBPluginTask.JBP_CMD_ASYNC:
            return
        mode = data["action"]
        user_id = data["user_id"]
        sessname = data["sessname"]

        user = JBoxUserV2(user_id)
        is_allowed = user.has_resource_profile(JBoxUserV2.RES_PROF_DISK_EBS_10G)
        if not is_allowed:
            JBoxEBSVolAsyncTask.log_error("Data volume access not allowed for user")
            return

        cont = SessContainer.get_by_name(sessname)
        if cont is None:
            return

        vol = JBoxEBSVol.get_disk_from_container(sessname)
        disk_state = None
        try:
            disk_state = JBoxDiskState(cluster_id=CompEC2.INSTALL_ID, region_id=CompEC2.REGION, user_id=user_id)
        except:
            pass

        JBoxEBSVolAsyncTask.log_debug("Data volume request %s for %s", mode, cont.debug_str())

        if mode == "attach":
            if vol is None:
                vol = JBoxEBSVol.get_disk_for_user(user_id)
                JBoxEBSVol.mount_host_device(vol.disk_path, cont.dockid, JBoxVol.DATA_MOUNT_POINT)
                disk_state = JBoxDiskState(cluster_id=CompEC2.INSTALL_ID, region_id=CompEC2.REGION, user_id=user_id)
                if disk_state.get_state() != JBoxDiskState.STATE_ATTACHED:
                    disk_state.set_state(JBoxDiskState.STATE_ATTACHED)
                    disk_state.save()
        elif mode == "detach":
            if cont is not None and cont.is_running():
                if vol is not None:
                    # unmount from container first
                    JBoxEBSVol.unmount_host_device(vol.disk_path, cont.dockid)
                elif disk_state is not None:
                    # no volume attached. ensure disk state is updated
                    if disk_state.get_state() != JBoxDiskState.STATE_DETACHED:
                        disk_state.set_state(JBoxDiskState.STATE_DETACHED)
                        disk_state.save()
            if vol is not None:
                vol.release(backup=True)

        JBoxEBSVolAsyncTask.log_debug("Data volume request %s completed for %s", mode, cont.debug_str())
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:48,代码来源:ebs_handler.py

示例14: do_monitor_loading_ajax

    def do_monitor_loading_ajax(self, user_id):
        sessname = unique_sessname(user_id)
        self.log_debug("AJAX monitoring loading of session [%s] user[%s]...", sessname, user_id)
        cont = SessContainer.get_by_name(sessname)
        if (cont is None) or (not cont.is_running()):
            loading_step = int(self.get_loading_state(), 0)
            if loading_step > 60:
                self.log_error("Could not start instance. Session [%s] for user [%s] didn't load.", sessname, user_id)
                self.write({'code': -1})
                return

            loading_step += 1
            self.set_loading_state(loading_step)
            self.write({'code': 0})
        else:
            self.write({'code': 1})
开发者ID:nkottary,项目名称:JuliaBox,代码行数:16,代码来源:main.py

示例15: _launch_session

 def _launch_session(name, email, reuse):
     cont = SessContainer.launch_by_name(name, email, reuse=reuse)
     JBoxd.publish_perf_counters()
     if not JBoxd._wait_for_container_start(cont):
         JBoxd.log_error("did not start: %s", cont.debug_str())
         BaseContainer.DCKR.kill(cont.dockid)
         return False
     # wait for services to start
     for port in cont.get_host_ports():
         if not JBoxd._wait_for_port(port):
             JBoxd.log_error("port %s did not start: %s", port, cont.debug_str())
             BaseContainer.DCKR.kill(cont.dockid)
             return False
         else:
             JBoxd.log_debug("port %s active: %s", port, cont.debug_str())
     JBoxd.log_info("passed connectivity check: %s", cont.debug_str())
     return True
开发者ID:nkottary,项目名称:JuliaBox,代码行数:17,代码来源:srvr_jboxd.py


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