• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xend.XendDomain类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: op_receive

 def op_receive(self, name, _):
     if self.transport:
         self.send_reply(["ready", name])
         XendDomain.instance().domain_restore_fd(
             self.transport.sock.fileno())
     else:
         log.error(name + ": no transport")
         raise XendError(name + ": no transport")
开发者ID:andreiw,项目名称:xen3-arm-tegra,代码行数:8,代码来源:relocate.py


示例2: getVBDs

 def getVBDs(self):
     from xen.xend import XendDomain
     vbd_refs = [d.get_vbds() for d in XendDomain.instance().list('all')]
     vbd_refs = reduce(lambda x, y: x + y, vbd_refs)
     vbds = []
     for vbd_ref in vbd_refs:
         vdi = XendDomain.instance().get_dev_property_by_uuid('vbd', vbd_ref, 'VDI')
         if vdi == self.uuid:
             vbds.append(vbd_ref)
     return vbds
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:10,代码来源:XendVDI.py


示例3: destroyDeviceModel

 def destroyDeviceModel(self):
     if self.device_model is None:
         return
     self.sentinel_lock.acquire()
     try:
         stubdomid = self.vm.getStubdomDomid()
         if stubdomid is not None :
             from xen.xend import XendDomain
             XendDomain.instance().domain_destroy(stubdomid)
         elif self.pid:
             try:
                 os.kill(self.pid, signal.SIGHUP)
             except OSError, exn:
                 log.exception(exn)
             # Try to reap the child every 100ms for 10s. Then SIGKILL it.
             for i in xrange(100):
                 try:
                     (p, rv) = os.waitpid(self.pid, os.WNOHANG)
                     if p == self.pid:
                         break
                 except OSError:
                     # This is expected if Xend has been restarted within
                     # the life of this domain.  In this case, we can kill
                     # the process, but we can't wait for it because it's
                     # not our child. We continue this loop, and after it is
                     # terminated make really sure the process is going away
                     # (SIGKILL).
                     pass
                 time.sleep(0.1)
             else:
                 log.warning("DeviceModel %d took more than 10s "
                             "to terminate: sending SIGKILL" % self.pid)
                 try:
                     os.kill(self.pid, signal.SIGKILL)
                     os.waitpid(self.pid, 0)
                 except OSError:
                     # This happens if the process doesn't exist.
                     pass
     finally:
         self.pid = None
         self.sentinel_lock.release()
         
     state = xstransact.Remove("/local/domain/0/device-model/%i"
                               % self.vm.getDomid())
     try:
         os.unlink('/var/run/tap/qemu-read-%d' % self.vm.getDomid())
         os.unlink('/var/run/tap/qemu-write-%d' % self.vm.getDomid())
     except:
         pass
     try:
         del sentinel_fifos_inuse[self.sentinel_path_fifo]
         os.unlink(self.sentinel_path_fifo)
     except:
         pass
开发者ID:Hearen,项目名称:OnceServer,代码行数:54,代码来源:image.py


示例4: op_receive

 def op_receive(self, name, _):
     if self.transport:
         self.send_reply(["ready", name])
         try:
             XendDomain.instance().domain_restore_fd(
                 self.transport.sock.fileno(), relocating=True)
         except:
             self.send_error()
             self.close()
     else:
         log.error(name + ": no transport")
         raise XendError(name + ": no transport")
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:12,代码来源:relocate.py


示例5: domains_with_state

def domains_with_state(detail, state, full):
    if detail:
        domains = XendDomain.instance().list_sorted(state)
        ret = []
        for dom in domains:
            try:
                ret.append(fixup_sxpr(dom.sxpr(not full)))
            except:
                log.warn("Failed to query SXPR for domain %s" % str(dom))
                pass
        return ret
    else:
        return XendDomain.instance().list_names(state)
开发者ID:changliwei,项目名称:suse_xen,代码行数:13,代码来源:XMLRPCServer.py


示例6: wait_devs

    def wait_devs(dominfo):
        from xen.xend import XendDomain

        lock = True;
        try:
            XendDomain.instance().domains_lock.release()
        except:
            lock = False;

        try:
            dominfo.waitForDevices() # Wait for backends to set up
        except Exception, exn:
            log.exception(exn)
            if lock:
                XendDomain.instance().domains_lock.acquire()
            raise
开发者ID:changliwei,项目名称:suse_xen,代码行数:16,代码来源:XendCheckpoint.py


示例7: check_status

 def check_status(self):
     try:
         global status_list
         global status_last
         global dest_ip
         status_changed=False
         status_list_copy=status_list
         while True:
             if status_list_copy[:5].count(1)==5:
                 status_now=True
             elif status_list_copy[:5].count(0)==5 or status_list_copy.count(0)==10:
                 status_now=False
             if status_now!=status_last:
                 status_changed=True
             else:
                 status_changed=False
             status_last=status_now
             if status_changed==True:
                 if status_now==False:
                     xendom = XendDomain.instance()
                     doms = xendom.list('all')
                     for dom in doms:
                         vm_uuid = dom.get_uuid()
                         if cmp(vm_uuid, DOM0_UUID) == 0:
                             continue
                         self.hard_shutdown_and_delete(vm_uuid)
     #                print dest_ip,"status to Down"
     #            elif status_now==True:
     #                print dest_ip,"status to Up"
             #print 'now status is: ', status_now
             time.sleep(0.3)
     except BaseException,e:
         log.debug(e)     
开发者ID:cxxly,项目名称:once-xend-core,代码行数:33,代码来源:PingNFS.py


示例8: activate_xspolicy

 def activate_xspolicy(self, xspol, flags):
     from xen.xend import XendDomain
     domains = XendDomain.instance()
     try:
         domains.domains_lock.acquire()
         return self.__activate_xspolicy(xspol, flags)
     finally:
         domains.domains_lock.release()
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:8,代码来源:XendXSPolicyAdmin.py


示例9: op_sslreceive

 def op_sslreceive(self, name, _):
     if self.transport:
         self.send_reply(["ready", name])
         p2cread, p2cwrite = os.pipe()
         threading.Thread(target=connection.SSLSocketServerConnection.recv2fd,
                          args=(self.transport.sock, p2cwrite)).start()
         try:
             XendDomain.instance().domain_restore_fd(p2cread,
                                                     relocating=True)
         except:
             os.close(p2cread)
             os.close(p2cwrite)
             self.send_error()
             self.close()
     else:
         log.error(name + ": no transport")
         raise XendError(name + ": no transport")
开发者ID:jeffchao,项目名称:xen-3.3-tcg,代码行数:17,代码来源:relocate.py


示例10: getDeviceDetails

    def getDeviceDetails(self, config):
        (devid, back, front) = BlkifController.getDeviceDetails(self, config)

        phantomDevid = 0
        wrapped = False

        try:
            imagetype = self.vm.info['image']['type']
        except:
            imagetype = ""

        if imagetype == 'hvm':
            tdevname = back['dev']
            index = ['c', 'd', 'e', 'f', 'g', 'h', 'i', \
                     'j', 'l', 'm', 'n', 'o', 'p']
            while True:
                global phantomDev
                global phantomId
                import os, stat

                phantomId = phantomId + 1
                if phantomId == 16:
                    if index[phantomDev] == index[-1]:
                        if wrapped:
                            raise VmError(" No loopback block \
                                       devices are available. ")
                        wrapped = True
                        phantomDev = 0
                    else:
                        phantomDev = phantomDev + 1
                    phantomId = 1
                devname = 'xvd%s%d' % (index[phantomDev], phantomId)
                try:
                    info = os.stat('/dev/%s' % devname)
                except:
                    break

            vbd = { 'mode': 'w', 'device': devname }
            fn = 'tap:%s' % back['params']

            # recurse ... by creating the vbd, then fallthrough
            # and finish creating the original device

            from xen.xend import XendDomain
            dom0 = XendDomain.instance().privilegedDomain()
            phantomDevid = dom0.create_phantom_vbd_with_vdi(vbd, fn)
            # we need to wait for this device at a higher level
            # the vbd that gets created will have a link to us
            # and will let them do it there

        # add a hook to point to the phantom device,
        # root path is always the same (dom0 tap)
        if phantomDevid != 0:
            front['phantom_vbd'] = '/local/domain/0/backend/tap/0/%s' \
                                   % str(phantomDevid)

        return (devid, back, front)
开发者ID:CPFL,项目名称:gxen,代码行数:57,代码来源:BlktapController.py


示例11: get_VM_ssidref

 def get_VM_ssidref(self, vm_ref):
     dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
     if not dom:
         raise InvalidHandleError("VM", vm_ref)
     if dom._stateGet() not in [ XEN_API_VM_POWER_STATE_RUNNING, \
                                 XEN_API_VM_POWER_STATE_PAUSED ]:
         raise VMBadState("Domain is not running or paused.")
     ssid = security.get_ssid(dom.getDomid())
     if not ssid:
         raise SecurityError(-xsconstants.XSERR_GENERAL_FAILURE)
     return ssid[3]
开发者ID:a2k2,项目名称:xen-unstable,代码行数:11,代码来源:XendXSPolicy.py


示例12: get_memory_free

    def get_memory_free(self):
        xendom = XendDomain.instance()
        doms = xendom.list()
        doms_mem_total = 0
        for dom in doms:
            if cmp(dom.get_uuid(), DOM0_UUID) == 0:
                continue
            dominfo = xendom.get_vm_by_uuid(dom.get_uuid())
            doms_mem_total += dominfo.get_memory_dynamic_max()
        

        return (self.host_instance.xc.physinfo()['total_memory'] * 1024 - doms_mem_total)/1024
开发者ID:Hearen,项目名称:OnceServer,代码行数:12,代码来源:P_DataCollect.py


示例13: reset_acmpolicy

 def reset_acmpolicy(self):
     """
        Attempt to reset the system's policy by udating it with
        the DEFAULT policy.
     """
     from xen.xend import XendDomain
     domains = XendDomain.instance()
     try:
         domains.domains_lock.acquire()
         xml = ACMPolicy.get_reset_policy_xml()
         flags = xsconstants.XS_INST_BOOT | xsconstants.XS_INST_LOAD
         return self.__add_acmpolicy_to_system(xml, flags, True)
     finally:
         domains.domains_lock.release()
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:14,代码来源:XendXSPolicyAdmin.py


示例14: hard_shutdown_and_delete

 def hard_shutdown_and_delete(self, vm_ref):
     xendom = XendDomain.instance()
     dominfo = xendom.get_vm_by_uuid(vm_ref)
     if not dominfo:
         return
     domid = dominfo.getDomid()
     if domid and cmp (int(domid), -1) > 0:
         xendom.domain_destroy(vm_ref)
     i = 0    
     time_out = 30
     while True:
         i += 1
 #                ps_new = self.VM_get_power_state(session, vm_ref)['Value']
         domid = dominfo.getDomid()
 #                log.debug(ps_new)
         if not domid or cmp (int(domid), -1) == 0:
             break
         elif cmp(i, time_out) > 0:
             break
         else:
             time.sleep(0.5)
             continue 
开发者ID:cxxly,项目名称:once-xend-core,代码行数:22,代码来源:PingNFS.py


示例15: run

    def run(self):
        if self.use_tcp:
            # bind to something fixed for now as we may eliminate
            # tcp support completely.
            self.server = TCPXMLRPCServer(("localhost", 8005), logRequests=False)
        else:
            self.server = UnixXMLRPCServer(XML_RPC_SOCKET, False)

        # Functions in XendDomainInfo
        for name in methods:
            fn = eval("lambda domid, *args: dispatch(domid, '%s', args)"%name)
            self.server.register_function(fn, "xend.domain.%s" % name)

        # Functions in XendDomain
        inst = XendDomain.instance()
        for name in dir(inst):
            fn = getattr(inst, name)
            if name.startswith("domain_") and callable(fn):
                if name not in exclude:
                    self.server.register_function(fn, "xend.domain.%s" % name[7:])

        # Functions in XendNode and XendDmesg
        for type, lst, n in [(XendNode, ['info', 'cpu_bvt_slice_set'], 'node'),
                             (XendDmesg, ['info', 'clear'], 'node.dmesg')]:
            inst = type.instance()
            for name in lst:
                self.server.register_function(getattr(inst, name),
                                              "xend.%s.%s" % (n, name))

        # A few special cases
        self.server.register_function(domain, 'xend.domain')
        self.server.register_function(domains, 'xend.domains')
        self.server.register_function(get_log, 'xend.node.log')
        self.server.register_function(domain_create, 'xend.domain.create')
        self.server.register_function(domain_restore, 'xend.domain.restore')

        self.server.register_introspection_functions()
        self.ready = True
        self.server.serve_forever()
开发者ID:andreiw,项目名称:xen3-arm-tegra,代码行数:39,代码来源:XMLRPCServer.py


示例16: getVMRecords

    def getVMRecords(self):
#         self.login()
#         vmRecords = self.proxy.VM.get_record_lite(self.session, '').get('Value', [])
#         return vmRecords
#         #host = self.proxy.VM.get_all().val ---
        vms = self._VM_get_all()
        retv = []
        if vms:
            for vm_ref in vms:
                xendom = XendDomain.instance()
                xeninfo = xendom.get_vm_by_uuid(vm_ref)
        #        xennode = XendNode.instance()
                if not xeninfo:
                    return retv
         
        #        domid = xeninfo.getDomid()
                dom_uuid = xeninfo.get_uuid()
                record_lite = {'uuid' : dom_uuid,
                               'power_state' : xeninfo.get_power_state(),
                               }  
    #            log.debug(record_lite)
                retv.append(record_lite)
        return retv
开发者ID:cxxly,项目名称:once-xend-core,代码行数:23,代码来源:RecordCollector.py


示例17: add_acmpolicy_to_system

 def add_acmpolicy_to_system(self, xmltext, flags, overwrite):
     """ Add an ACM policy's xml representation to the system. The
         policy will automatically be compiled
      flags:
       XS_INST_BOOT : make policy the one to boot the system with
                      by default; if there's a policy already installed,
                      refuse to install this policy unless its one with
                      the same name
       XS_INST_LOAD : load the policy immediately; if this does not work
                      refuse to install this policy
      overwrite:
       If any policy is installed and this is False, refuse to install
       this policy
       If flags is True, then any existing policy will be removed from
       the system and the new one will be installed
     """
     from xen.xend import XendDomain
     domains = XendDomain.instance()
     try:
         domains.domains_lock.acquire()
         return self.__add_acmpolicy_to_system(xmltext, flags, overwrite)
     finally:
         domains.domains_lock.release()
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:23,代码来源:XendXSPolicyAdmin.py


示例18: __init__

 def __init__(self, dom):
     SrvDir.__init__(self)
     self.dom = dom
     self.xd = XendDomain.instance()
开发者ID:ryos36,项目名称:xen-arm,代码行数:4,代码来源:SrvDomain.py


示例19:


        os.read(fd, 1)           # Wait for source to close connection
        
        dominfo.completeRestore(handler.store_mfn, handler.console_mfn)

        #
        # We shouldn't hold the domains_lock over a waitForDevices
        # As this function sometime gets called holding this lock,
        # we must release it and re-acquire it appropriately
        #
        from xen.xend import XendDomain

        lock = True;
        try:
            XendDomain.instance().domains_lock.release()
        except:
            lock = False;

        try:
            dominfo.waitForDevices() # Wait for backends to set up
        except Exception, exn:
            log.exception(exn)

        if lock:
            XendDomain.instance().domains_lock.acquire()

        if not paused:
            dominfo.unpause()

        return dominfo
开发者ID:a2k2,项目名称:xen-unstable,代码行数:29,代码来源:XendCheckpoint.py


示例20: createDeviceModel

    def createDeviceModel(self, restore = False):
        if self.device_model is None:
            return
        if self.pid:
            return
        # Execute device model.
        #todo: Error handling
        args = self.getDeviceModelArgs(restore)
        env = dict(os.environ)
        if self.display:
            env['DISPLAY'] = self.display
        if self.xauthority:
            env['XAUTHORITY'] = self.xauthority
        unique_id = "%i-%i" % (self.vm.getDomid(), time.time())
        sentinel_path = sentinel_path_prefix + unique_id
        sentinel_path_fifo = sentinel_path + '.fifo'
        os.mkfifo(sentinel_path_fifo, 0600)
        sentinel_write = file(sentinel_path_fifo, 'r+')
        self._openSentinel(sentinel_path_fifo)
        self.vm.storeDom("image/device-model-fifo", sentinel_path_fifo)
        xstransact.Mkdir("/local/domain/0/device-model/%i" % self.vm.getDomid())
        xstransact.SetPermissions("/local/domain/0/device-model/%i" % self.vm.getDomid(),
                        { 'dom': self.vm.getDomid(), 'read': True, 'write': True })
        log.info("spawning device models: %s %s", self.device_model, args)
        # keep track of pid and spawned options to kill it later

        self.logfile = "/var/log/xen/qemu-dm-%s.log" %  str(self.vm.info['name_label'])

        # rotate log
        logfile_mode = os.O_WRONLY|os.O_CREAT|os.O_APPEND
        logrotate_count = XendOptions.instance().get_qemu_dm_logrotate_count()
        if logrotate_count > 0:
            logfile_mode |= os.O_TRUNC
            if os.path.exists("%s.%d" % (self.logfile, logrotate_count)):
                os.unlink("%s.%d" % (self.logfile, logrotate_count))
            for n in range(logrotate_count - 1, 0, -1):
                if os.path.exists("%s.%d" % (self.logfile, n)):
                    os.rename("%s.%d" % (self.logfile, n),
                              "%s.%d" % (self.logfile, (n + 1)))
            if os.path.exists(self.logfile):
                os.rename(self.logfile, self.logfile + ".1")

        null = os.open("/dev/null", os.O_RDONLY)
        logfd = os.open(self.logfile, logfile_mode, 0666)
        
        sys.stderr.flush()
        contract = osdep.prefork("%s:%d" %
                                 (self.vm.getName(), self.vm.getDomid()))
        pid = os.fork()
        if pid == 0: #child
            try:
                osdep.postfork(contract)
                os.dup2(null, 0)
                os.dup2(logfd, 1)
                os.dup2(logfd, 2)
                oshelp.close_fds((sentinel_write.fileno(),))
                try:
                    os.execve(self.device_model, args, env)
                except Exception, e:
                    print >>sys.stderr, (
                        'failed to set up fds or execute dm %s: %s' %
                        (self.device_model, utils.exception_string(e)))
                    os._exit(126)
            except:
                os._exit(127)
        else:
            osdep.postfork(contract, abandon=True)
            self.pid = pid
            os.close(null)
            os.close(logfd)
        sentinel_write.close()
        self.vm.storeDom("image/device-model-pid", self.pid)
        log.info("device model pid: %d", self.pid)
        # we would very much prefer not to have a thread here and instead
        #  have a callback but sadly we don't have Twisted in xend
        self.sentinel_thread = thread.start_new_thread(self._sentinel_watch,())
        if self.device_model.find('stubdom-dm') > -1 :
            from xen.xend import XendDomain
            domains = XendDomain.instance()
            domains.domains_lock.release()

            count = 0
            while True:
                orig_state = xstransact.Read("/local/domain/0/device-model/%i/state"
                                    % self.vm.getDomid())
                # This can occur right after start-up
                if orig_state != None:
                    break

                log.debug('createDeviceModel %i: orig_state is None, retrying' % self.vm.getDomid())

                time.sleep(0.1)
                count += 1
                if count > 100:
                    break

            domains.domains_lock.acquire()
开发者ID:Hearen,项目名称:OnceServer,代码行数:97,代码来源:image.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python XendBase.XendBase类代码示例发布时间:2022-05-26
下一篇:
Python xend.XendAPIStore类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap