當前位置: 首頁>>代碼示例>>Python>>正文


Python Compute.get_install_id方法代碼示例

本文整理匯總了Python中cloud.Compute.get_install_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Compute.get_install_id方法的具體用法?Python Compute.get_install_id怎麽用?Python Compute.get_install_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cloud.Compute的用法示例。


在下文中一共展示了Compute.get_install_id方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: publish_anticipated_load

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
 def publish_anticipated_load(session_name=None):
     iid = Compute.get_instance_id()
     if session_name is None:
         nactive = BaseContainer.num_active(BaseContainer.SFX_INT)
     else:
         JBoxSessionProps.attach_instance(Compute.get_install_id(), session_name, iid, "Preparing")
         nactive = BaseContainer.num_active(BaseContainer.SFX_INT) + 1
     cont_load_pct = min(100, max(0, nactive * 100 / SessContainer.MAX_CONTAINERS))
     self_load = max(Compute.get_instance_stats(iid, 'Load'), cont_load_pct)
     Compute.publish_stats("Load", "Percent", self_load)
     accept = Compute.should_accept_session(is_proposed_cluster_leader())
     JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept)
開發者ID:nkottary,項目名稱:JuliaBox,代碼行數:14,代碼來源:srvr_jboxd.py

示例2: monitor_registrations

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
    def monitor_registrations():
        max_rate = JBoxDynConfig.get_registration_hourly_rate(Compute.get_install_id())
        rate = JBoxUserV2.count_created(1)
        reg_allowed = JBoxDynConfig.get_allow_registration(Compute.get_install_id())
        JBox.log_debug("registration allowed: %r, rate: %d, max allowed: %d", reg_allowed, rate, max_rate)

        if (reg_allowed and (rate > max_rate*1.1)) or ((not reg_allowed) and (rate < max_rate*0.9)):
            reg_allowed = not reg_allowed
            JBox.log_warn("Changing registration allowed to %r", reg_allowed)
            JBoxDynConfig.set_allow_registration(Compute.get_install_id(), reg_allowed)

        if reg_allowed:
            num_pending_activations = JBoxUserV2.count_pending_activations()
            if num_pending_activations > 0:
                JBox.log_info("scheduling activations for %d pending activations", num_pending_activations)
                JBoxAsyncJob.async_schedule_activations()
開發者ID:JuliaLang,項目名稱:JuliaBox,代碼行數:18,代碼來源:srvr_jbox.py

示例3: do_housekeeping

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
    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,代碼行數:35,代碼來源:srvr_jbox.py

示例4: backup_and_cleanup

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
 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,代碼行數:9,代碼來源:srvr_jboxd.py

示例5: publish_sessions

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
 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,代碼行數:9,代碼來源:srvr_jboxd.py

示例6: schedule_housekeeping

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
    def schedule_housekeeping(cmd, is_leader):
        JBoxd.publish_perf_counters()
        JBoxd.publish_sessions()
        JBoxd.publish_instance_state()
        features = [JBPluginTask.JBP_NODE]
        if is_leader is True:
            JBoxInstanceProps.purge_stale_instances(Compute.get_install_id())
            features.append(JBPluginTask.JBP_CLUSTER)

        for feature in features:
            for plugin in JBPluginTask.jbox_get_plugins(feature):
                JBoxd.schedule_thread(cmd, plugin.do_periodic_task, (feature,))
開發者ID:nkottary,項目名稱:JuliaBox,代碼行數:14,代碼來源:srvr_jboxd.py

示例7: publish_instance_state

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
    def publish_instance_state():
        iid = Compute.get_instance_id()
        api_status = dict()
        for c in BaseContainer.api_containers(allcontainers=True):
            name = c["Names"][0] if (("Names" in c) and (c["Names"] is not None)) else c["Id"][0:12]
            api_name = APIContainer.get_api_name_from_container_name(name)
            if api_name is None:
                continue
            cnt = api_status.get(api_name, 0)
            api_status[api_name] = cnt + 1
        self_load = Compute.get_instance_stats(iid, 'Load')
        accept = Compute.should_accept_session(is_proposed_cluster_leader())

        JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept, api_status=api_status)
開發者ID:nkottary,項目名稱:JuliaBox,代碼行數:16,代碼來源:srvr_jboxd.py

示例8: update_juliabox_status

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
    def update_juliabox_status():
        in_error = len(JBoxInstanceProps.get_stale_instances(Compute.get_install_id()))
        instance_status = JBoxInstanceProps.get_instance_status(Compute.get_install_id())

        HTML = "<html><body><center><pre>\nJuliaBox is Up.\n\nLast updated: " + datetime.datetime.now().isoformat() + " UTC\n\nLoads: "
        for iid in instance_status:
            HTML += (str(instance_status[iid]['load']) + '% ')

        HTML += ("\n\nErrors: " + str(in_error) + "\n\nAWS Status: <a href='http://status.aws.amazon.com/'>status.aws.amazon.com</a></pre></center></body></html>")

        plugin = JBPluginCloud.jbox_get_plugin(JBPluginCloud.JBP_BUCKETSTORE)
        bkt = JBoxCfg.get("cloud_host.status_bucket")
        if plugin is not None and bkt is not None:
            try:
                f = open("/tmp/index.html", "w")
                f.write(HTML)
                f.close()
                plugin.push(bkt, "/tmp/index.html")
            finally:
                os.remove("/tmp/index.html")
        else:
            JBox.log_debug("Status: %s", HTML)

        return None
開發者ID:JuliaLang,項目名稱:JuliaBox,代碼行數:26,代碼來源:srvr_jbox.py

示例9: publish_container_stats

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
 def publish_container_stats():
     VolMgr.publish_stats()
     db.publish_stats()
     JBoxDynConfig.set_stat_collected_date(Compute.get_install_id())
開發者ID:Emram,項目名稱:JuliaBox,代碼行數:6,代碼來源:srvr_jboxd.py

示例10: publish_sessions

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import get_install_id [as 別名]
 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):
             JBoxSessionProps.attach_instance(Compute.get_install_id(), SessContainer(c['Id']).get_name(), iid,
                                              c["Status"])
開發者ID:nkottary,項目名稱:JuliaBox,代碼行數:8,代碼來源:srvr_jboxd.py


注:本文中的cloud.Compute.get_install_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。