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


Python KaresansuiVirtConnection.get_nodeinfo方法代码示例

本文整理汇总了Python中karesansui.lib.virt.virt.KaresansuiVirtConnection.get_nodeinfo方法的典型用法代码示例。如果您正苦于以下问题:Python KaresansuiVirtConnection.get_nodeinfo方法的具体用法?Python KaresansuiVirtConnection.get_nodeinfo怎么用?Python KaresansuiVirtConnection.get_nodeinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在karesansui.lib.virt.virt.KaresansuiVirtConnection的用法示例。


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

示例1: process

# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
 def process(self):
     conn = KaresansuiVirtConnection()
     try:
         guests = conn.search_guests()
 
         nodeinfo = conn.get_nodeinfo()
         
         infos = []
         for guest in guests:
             id = guest.ID()
             if id > -1:
                 name = guest.name()
                 print name
                 info = guest.info()
                 maxMem = info[1]
                 memory = info[2]
                 
                 pcentCurrMem = memory * 100.0 / (nodeinfo["memory"]*1024)
                 pcentMaxMem  = maxMem * 100.0 / (nodeinfo["memory"]*1024)
                 
                 print "%.3f%%" % pcentCurrMem
                 #print pcentMaxMem
                 
         return True
     
     finally:
         conn.close()
开发者ID:AdUser,项目名称:karesansui,代码行数:29,代码来源:get_memory_usage.py

示例2: _PUT

# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
    def _PUT(self, *param, **params):
        """<comment-ja>
        Japanese Comment
        </comment-ja>
        <comment-en>
        TODO: English Comment
        </comment-en>
        """
        (host_id, guest_id) = self.chk_guestby1(param)
        if guest_id is None:
            return web.notfound()

        if is_param(self.input, "memory"):
            memory = int(self.input.memory)
        else:
            memory = None
        max_memory = int(self.input.max_memory)

        model = findbyguest1(self.orm, guest_id)

        # virt
        kvc = KaresansuiVirtConnection()
        try:
            domname = kvc.uuid_to_domname(model.uniq_key)
            if not domname:
                return web.conflict(web.ctx.path)
            virt = kvc.search_kvg_guests(domname)[0]
            info = virt.get_info()
            # maxMem = info["maxMem"]
            now_memory = info["memory"]
            mem_info = kvc.get_mem_info()
            nodeinfo = kvc.get_nodeinfo()
        finally:
            kvc.close()

        # valid
        # if (mem_info["host_free_mem"] + (now_memory / 1024)) < memory:
        #    return web.badrequest("Memory value is greater than the maximum memory value. - memory=%s" % self.input.memory)

        options = {}
        options["name"] = domname
        options["maxmem"] = max_memory
        if memory is None:
            options["memory"] = max_memory
        else:
            options["memory"] = memory
        _cmd = dict2command("%s/%s" % (karesansui.config["application.bin.dir"], VIRT_COMMAND_SET_MEMORY), options)
        cmdname = "Set memory"
        _jobgroup = JobGroup(cmdname, karesansui.sheconf["env.uniqkey"])
        _jobgroup.jobs.append(Job("%s command" % cmdname, 0, _cmd))
        _machine2jobgroup = m2j_new(
            machine=model,
            jobgroup_id=-1,
            uniq_key=karesansui.sheconf["env.uniqkey"],
            created_user=self.me,
            modified_user=self.me,
        )
        save_job_collaboration(self.orm, self.pysilhouette.orm, _machine2jobgroup, _jobgroup)
        return web.accepted(url=web.ctx.path)
开发者ID:goura,项目名称:karesansui,代码行数:61,代码来源:guestby1memory.py

示例3: _GET

# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
    def _GET(self, *param, **params):
        (host_id, guest_id) = self.chk_guestby1(param)
        if guest_id is None: return web.notfound()
        
        model = findbyguest1(self.orm, guest_id)

        # virt
        kvc = KaresansuiVirtConnection()

        try:
            domname = kvc.uuid_to_domname(model.uniq_key)
            if not domname: return web.notfound()
            virt = kvc.search_kvg_guests(domname)[0]
            self.view.info = virt.get_info()
            #self.view.mem_info = kvc.get_mem_info()
            self.view.nodeinfo = kvc.get_nodeinfo()
            self.view.guest = model
            self.view.hypervisor = self.view.info['hypervisor']
        finally:
            kvc.close()
            
        return True
开发者ID:AdUser,项目名称:karesansui,代码行数:24,代码来源:guestby1memory.py


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