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


Python libvirt.VIR_DOMAIN_SHUTOFF屬性代碼示例

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


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

示例1: domain

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def domain(request, libvirt_con):
    dom = libvirt_con.lookupByName(request.param)
    if dom.isActive():
        dom.destroy()
    # Xen cannot restore to a libvirt snapshot
    # revert VM to 'Base' snapshot
    # snap = dom.snapshotLookupByName(BASE_SNAPSHOT)
    # dom.revertToSnapshot(snap)
    # start domain
    dom.create()
    # wait for winrm service to be available
    dom_ip = wait_for_ip(dom)
    wait_service(dom_ip, WINRM_PORT)
    yield dom
    # teardown
    # shutdown domain
    dom.shutdown()
    while dom.state()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
        time.sleep(1) 
開發者ID:libvmi,項目名稱:python,代碼行數:21,代碼來源:conftest.py

示例2: create_xml_with_files_clean

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def create_xml_with_files_clean(params):
    logger = params['logger']
    guestname = params['guestname']

    for i in range(len(files)):
        ret = utils.del_file("/tmp/libvirt-test-api-create-file-%d" % i, logger)
    ret = utils.del_file("/tmp/libvirt_passfile_check", logger)

    conn = libvirt.open("lxc:///")
    dom = conn.lookupByName(guestname)
    guest_state = dom.info()[0]
    if guest_state == libvirt.VIR_DOMAIN_RUNNING:
        logger.debug("destroy guest: %s." % guestname)
        time.sleep(5)
        dom.destroyFlags()
        define_list = conn.listDefinedDomains()
        if guestname in define_list:
            time.sleep(3)
            dom.undefine()
            time.sleep(3)
    elif guest_state == libvirt.VIR_DOMAIN_SHUTOFF:
        time.sleep(5)
        dom.undefine()
        time.sleep(3) 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:26,代碼來源:create_xml_with_files.py

示例3: create_with_files_clean

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def create_with_files_clean(params):
    logger = params['logger']
    for i in range(len(files)):
        ret = utils.del_file("/tmp/libvirt-test-api-create-file-%d" % i, logger)
    ret = utils.del_file("/tmp/libvirt_passfile_check", logger)

    conn = libvirt.open("lxc:///")
    dom = conn.lookupByName(guestname)
    guest_state = dom.info()[0]
    if guest_state == libvirt.VIR_DOMAIN_RUNNING:
        logger.debug("destroy guest: %s." % guestname)
        time.sleep(5)
        dom.destroyFlags()
        define_list = conn.listDefinedDomains()
        if guestname in define_list:
            time.sleep(3)
            dom.undefine()
            time.sleep(3)
    elif guest_state == libvirt.VIR_DOMAIN_SHUTOFF:
        time.sleep(5)
        dom.undefine()
        time.sleep(3) 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:24,代碼來源:create_with_files.py

示例4: get_state

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def get_state(state):
    dom_state = ''
    if state == libvirt.VIR_DOMAIN_NOSTATE:
        dom_state = 'nostate'
    elif state == libvirt.VIR_DOMAIN_RUNNING:
        dom_state = 'running'
    elif state == libvirt.VIR_DOMAIN_BLOCKED:
        dom_state = 'blocked'
    elif state == libvirt.VIR_DOMAIN_PAUSED:
        dom_state = 'paused'
    elif state == libvirt.VIR_DOMAIN_SHUTDOWN:
        dom_state = 'shutdown'
    elif state == libvirt.VIR_DOMAIN_SHUTOFF:
        dom_state = 'shutoff'
    elif state == libvirt.VIR_DOMAIN_CRASHED:
        dom_state = 'crashed'
    else:
        dom_state = 'no sure'
    return dom_state 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:21,代碼來源:migrate.py

示例5: check_domain_state

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_domain_state(vmstate, flags, logger):
    """
       check domain state after doing coredump
    """
    if libvirt.VIR_DUMP_CRASH == libvirt.VIR_DUMP_CRASH & flags:
        if vmstate == [libvirt.VIR_DOMAIN_SHUTOFF,
                       libvirt.VIR_DOMAIN_SHUTOFF_CRASHED]:
            logger.info("domain status is %s,shut off (crashed): Pass"
                        % vmstate)
            return True
        else:
            logger.info("domain status is %s: Fail" % vmstate)
            return False
    else:
        if vmstate == [libvirt.VIR_DOMAIN_RUNNING,
                       libvirt.VIR_DOMAIN_RUNNING_UNPAUSED]:
            logger.info("domain status is %s,running (unpaused): Pass"
                        % vmstate)
            return True
        else:
            logger.info("domain status is %s: Fail" % vmstate)
            return False 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:24,代碼來源:coredump_with_format.py

示例6: guest_power_off

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def guest_power_off(domobj, domname):
    """ power off guest virtual machine"""

    state = domobj.info()[0]
    logger.debug("current guest status: %s" % state)
    try:
        domobj.destroy()
    except libvirtError as e:
        logger.error("API error message: %s, error code is %s"
                     % (e.get_error_message(), e.get_error_code()))
        logger.error("fail to power off guest %s" % domname)
        return 1

    time.sleep(1)
    state = domobj.info()[0]
    if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
        logger.info("the guest is power off already.")
    else:
        logger.error("failed to power off the domain %s" % domname)
        return 1

    return 0 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:24,代碼來源:balloon_memory.py

示例7: setUp

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def setUp(self):
        super().setUp()
        self.test_base_dir = '/tmp/qubes-test-dir'
        self.base_dir_patch = unittest.mock.patch.dict(qubes.config.system_path,
            {'qubes_base_dir': self.test_base_dir})
        self.base_dir_patch2 = unittest.mock.patch(
            'qubes.config.qubes_base_dir', self.test_base_dir)
        self.base_dir_patch3 = unittest.mock.patch.dict(
            qubes.config.defaults['pool_configs']['varlibqubes'],
            {'dir_path': self.test_base_dir})
        self.base_dir_patch.start()
        self.base_dir_patch2.start()
        self.base_dir_patch3.start()
        app = qubes.Qubes('/tmp/qubes-test.xml', load=False)
        app.vmm = unittest.mock.Mock(spec=qubes.app.VMMConnection)
        app.load_initial_values()
        self.loop.run_until_complete(app.setup_pools())
        app.default_kernel = '1.0'
        app.default_netvm = None
        self.template = app.add_new_vm('TemplateVM', label='black',
            name='test-template')
        app.default_template = 'test-template'
        with qubes.tests.substitute_entry_points('qubes.storage',
                'qubes.tests.storage'):
            self.loop.run_until_complete(
                app.add_pool('test', driver='test'))
        app.default_pool = 'varlibqubes'
        app.save = unittest.mock.Mock()
        self.vm = app.add_new_vm('AppVM', label='red', name='test-vm1',
            template='test-template')
        self.app = app
        libvirt_attrs = {
            'libvirt_conn.lookupByUUID.return_value.isActive.return_value':
                False,
            'libvirt_conn.lookupByUUID.return_value.state.return_value':
                [libvirt.VIR_DOMAIN_SHUTOFF],
        }
        app.vmm.configure_mock(**libvirt_attrs)

        self.emitter = qubes.tests.TestEmitter()
        self.app.domains[0].fire_event = self.emitter.fire_event 
開發者ID:QubesOS,項目名稱:qubes-core-admin,代碼行數:43,代碼來源:api_admin.py

示例8: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(*args):
    """Check guest current status"""
    (domobj, logger) = args
    state = domobj.info()[0]
    logger.debug("current guest status: %s" % state)

    if state == libvirt.VIR_DOMAIN_SHUTOFF or \
       state == libvirt.VIR_DOMAIN_SHUTDOWN or \
       state == libvirt.VIR_DOMAIN_BLOCKED:
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:14,代碼來源:managedsave.py

示例9: domain_nfs_start_clean

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def domain_nfs_start_clean(params):
    """clean testing environment"""
    logger = params['logger']
    guestname = params['guestname']

    # Connect to local hypervisor connection URI
    conn = utils.get_conn()
    domobj = conn.lookupByName(guestname)

    if domobj.info()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
        domobj.destroy()

    dom_xml = domobj.XMLDesc(0)
    disk_file = utils.get_disk_path(dom_xml)
    img_dir = os.path.dirname(disk_file)
    file_name = os.path.basename(disk_file)
    temp_file = "/tmp/%s" % file_name

    if os.path.ismount(img_dir):
        umount_cmd = "umount -f %s" % img_dir
        ret, out = utils.exec_cmd(umount_cmd, shell=True)
        if ret:
            logger.error("failed to umount %s" % img_dir)

    if os.path.exists(temp_file):
        os.remove(temp_file)

    clean_nfs_conf = "sed -i '$d' /etc/exports"
    utils.exec_cmd(clean_nfs_conf, shell=True)

    clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF
    utils.exec_cmd(clean_qemu_conf, shell=True)

    cmd = "service libvirtd restart"
    utils.exec_cmd(cmd, shell=True)

    return 0 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:39,代碼來源:domain_nfs_start.py

示例10: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(domobj):
    """ check guest current status
    """
    state = domobj.info()[0]
    if state == libvirt.VIR_DOMAIN_SHUTOFF or \
            state == libvirt.VIR_DOMAIN_SHUTDOWN:
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:11,代碼來源:set_guest_time.py

示例11: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(domobj, logger):
    """Check guest current status"""
    state = domobj.info()[0]
    logger.info("current guest status: %s" % state)
    if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:10,代碼來源:dump.py

示例12: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(domobj):
    """Check guest current status"""
    state = domobj.info()[0]
    if state == libvirt.VIR_DOMAIN_SHUTOFF or \
            state == libvirt.VIR_DOMAIN_SHUTDOWN:
        # add check function
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:11,代碼來源:block_iotune.py

示例13: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(*args):
    """Check guest current status"""
    (domobj, logger) = args

    state = domobj.info()[0]
    logger.debug("current guest status: %s" % state)

    if state == libvirt.VIR_DOMAIN_SHUTOFF or \
       state == libvirt.VIR_DOMAIN_SHUTDOWN or \
       state == libvirt.VIR_DOMAIN_BLOCKED:
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:15,代碼來源:save.py

示例14: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(*args):
    """Check guest current status"""
    (domobj, logger) = args

    state = domobj.info()[0]
    logger.debug("current guest status: %s" % state)

    if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:13,代碼來源:restore.py

示例15: check_guest_status

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_SHUTOFF [as 別名]
def check_guest_status(domobj):
    """Check guest current status"""
    state = domobj.info()[0]
    if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
        # add check function
        return False
    else:
        return True 
開發者ID:libvirt,項目名稱:libvirt-test-API,代碼行數:10,代碼來源:ifstats.py


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