当前位置: 首页>>代码示例>>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;未经允许,请勿转载。