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


Python jbox_util.JBoxCfg类代码示例

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


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

示例1: configure

 def configure():
     JBoxLoopbackVol.DISK_LIMIT = JBoxCfg.get('disk_limit')
     JBoxLoopbackVol.FS_LOC = os.path.expanduser(JBoxCfg.get('mnt_location'))
     JBoxLoopbackVol.MAX_DISKS = JBoxCfg.get('numdisksmax')
     JBoxLoopbackVol.DISK_RESERVE_SECS = JBoxCfg.get('disk_reserve_secs', 180)
     JBoxLoopbackVol.LOCK = threading.Lock()
     JBoxLoopbackVol.refresh_disk_use_status()
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:7,代码来源:loopback.py

示例2: chk_and_launch_docker

    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,代码行数:32,代码来源:main.py

示例3: configure

    def configure():
        CompEC2.SCALE_UP_AT_LOAD = JBoxCfg.get('cloud_host.scale_up_at_load', 80)
        CompEC2.SCALE_UP_POLICY = JBoxCfg.get('cloud_host.scale_up_policy', None)
        CompEC2.AUTOSCALE_GROUP = JBoxCfg.get('cloud_host.autoscale_group', None)

        CompEC2.INSTALL_ID = JBoxCfg.get('cloud_host.install_id', 'JuliaBox')
        CompEC2.REGION = JBoxCfg.get('cloud_host.region', 'us-east-1')
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:7,代码来源:impl_ec2.py

示例4: 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

示例5: configure

    def configure():
        num_disks_max = JBoxCfg.get('numdisksmax')
        JBoxEBSVol.DISK_LIMIT = 10
        JBoxEBSVol.MAX_DISKS = num_disks_max
        JBoxEBSVol.DISK_TEMPLATE_SNAPSHOT = JBoxCfg.get('cloud_host.ebs_template')

        JBoxEBSVol.DEVICES = JBoxEBSVol._guess_configured_devices('xvd', num_disks_max)
        JBoxEBSVol.log_debug("Assuming %d EBS volumes configured in range xvdba..xvdcz", len(JBoxEBSVol.DEVICES))

        JBoxEBSVol.LOCK = threading.Lock()
        JBoxEBSVol.refresh_disk_use_status()
开发者ID:JuliaLang,项目名称:JuliaBox,代码行数:11,代码来源:ebs.py

示例6: configure

    def configure():
        BaseContainer.DCKR = JBoxCfg.dckr
        SessContainer.DCKR_IMAGE = JBoxCfg.get('interactive.docker_image')
        SessContainer.MEM_LIMIT = JBoxCfg.get('interactive.mem_limit')

        SessContainer.ULIMITS = []
        limits = JBoxCfg.get('interactive.ulimits')
        for (n, v) in limits.iteritems():
            SessContainer.ULIMITS.append(Ulimit(name=n, soft=v, hard=v))

        SessContainer.CPU_LIMIT = JBoxCfg.get('interactive.cpu_limit')
        SessContainer.MAX_CONTAINERS = JBoxCfg.get('interactive.numlocalmax')
开发者ID:nkottary,项目名称:JuliaBox,代码行数:12,代码来源:sess_container.py

示例7: post

    def post(self):
        self.log_debug("User management 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.send_error()
            return

        user = JBoxUserV2(user_id)
        is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
        self.log_info("User manager. user_id[%s] is_admin[%r]", user_id, is_admin)

        if not is_admin:
            self.send_error(status_code=403)
            return

        if self.handle_get_user(user_id, is_admin):
            return
        if self.handle_update_user(user_id, is_admin):
            return

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

示例8: configure

 def configure():
     mail_data = JBoxCfg.get('user_activation')
     JBoxd.SENDER_PASSWORD = mail_data['sender_password']
     JBoxd.SMTP_URL = mail_data['smtp_url']
     JBoxd.SMTP_PORT_NO = mail_data['smtp_port_no']
     JBoxd.MAX_24HRS = mail_data['max_24hrs']
     JBoxd.MAX_RATE_PER_SEC = mail_data['max_rate_per_sec']
开发者ID:bryongloden,项目名称:JuliaBox,代码行数:7,代码来源:impl_smtp.py

示例9: post

    def post(self):
        self.log_debug("API management 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.send_error()
            return

        user = JBoxUserV2(user_id)
        is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
        self.log_info("API manager. user_id[%s] is_admin[%r]", user_id, is_admin)

        if user.has_resource_profile(JBoxUserV2.RES_PROF_API_PUBLISHER):
            if self.handle_get_api_info(user_id, is_admin):
                return
            if self.handle_create_api(user_id, is_admin):
                return
            if self.handle_delete_api(user_id, is_admin):
                return
        else:
            if self.handle_enable_api(user_id, is_admin):
                return

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

示例10: get_user_id

    def get_user_id(self, validate=True):
        if (self._user_id is None) or (validate and (not self._valid_user)):
            try:
                jbox_cookie = self.get_cookie(JBoxCookies.COOKIE_AUTH)
                if jbox_cookie is None:
                    return None
                jbox_cookie = json.loads(base64.b64decode(jbox_cookie))
                if validate:
                    sign = signstr(jbox_cookie['u'] + jbox_cookie['t'], JBoxCfg.get('sesskey'))
                    if sign != jbox_cookie['x']:
                        self.log_info("signature mismatch for " + jbox_cookie['u'])
                        return None

                    d = isodate.parse_datetime(jbox_cookie['t'])
                    age = (datetime.datetime.now(pytz.utc) - d).total_seconds()
                    if age > JBoxCookies.AUTH_VALID_SECS:
                        self.log_info("cookie older than allowed days: " + jbox_cookie['t'])
                        return None
                    self._valid_user = True
                self._user_id = jbox_cookie['u']
            except:
                self.log_error("exception while reading auth cookie")
                traceback.print_exc()
                return None
        return self._user_id
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:25,代码来源:handler_base.py

示例11: configure

    def configure():
        pkg_location = os.path.expanduser(JBoxCfg.get('pkg_location'))
        make_sure_path_exists(pkg_location)

        JBoxDefaultPackagesVol.FS_LOC = pkg_location
        JBoxDefaultPackagesVol.LOCK = threading.Lock()
        JBoxDefaultPackagesVol.refresh_disk_use_status()
开发者ID:EricForgy,项目名称:JuliaBox,代码行数:7,代码来源:defpkg.py

示例12: 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

示例13: get

    def get(self):
        self.log_debug("APIInfo handler got GET request")
        key = self.get_argument("key", None)
        sign = self.get_argument("sign", None)

        if key is None or sign is None:
            self.send_error()
            return
        sign2 = signstr(key, JBoxCfg.get('sesskey'))

        if sign != sign2:
            self.log_info("signature mismatch. key:%r sign:%r expected:%r", key, sign, sign2)
            self.send_error()
            return

        api_status = APIContainer.get_cluster_api_status()
        self.log_info("cluster api status: %r", api_status)

        # filter out instances that should not accept more load
        filtered_api_status = {k: v for (k, v) in api_status.iteritems() if v['accept']}
        preferred_instances = filtered_api_status.keys()

        # flip the dict
        per_api_instances = dict()
        for (inst, status) in filtered_api_status.iteritems():
            api_names = status['api_status'].keys()
            for api_name in api_names:
                v = per_api_instances.get(api_name, [])
                v.append(inst)

        per_api_instances[" preferred "] = preferred_instances
        self.log_info("per api instances: %r", per_api_instances)
        self.write(per_api_instances)
        return
开发者ID:NHDaly,项目名称:JuliaBox,代码行数:34,代码来源:api_info.py

示例14: configure

    def configure():
        polsar_location = os.path.expanduser(JBoxCfg.get("polsar_location"))

        make_sure_path_exists(polsar_location)

        JBoxPolsarDiskVol.FS_LOC = polsar_location
        JBoxPolsarDiskVol.refresh_disk_use_status()
开发者ID:gsd-ufal,项目名称:Juliabox,代码行数:7,代码来源:polsardisk.py

示例15: configure

 def configure():
     dbconf = JBoxCfg.get("db")
     JBoxCloudSQL.log_debug("db_conf: %r", dbconf)
     if dbconf is not None:
         JBoxCloudSQL.USER = dbconf['user']
         JBoxCloudSQL.PASSWD = dbconf['passwd']
         JBoxCloudSQL.UNIX_SOCKET = dbconf['unix_socket']
         JBoxCloudSQL.DB = dbconf['db']
开发者ID:nkottary,项目名称:JuliaBox,代码行数:8,代码来源:impl_cloudsql.py


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