本文整理汇总了Python中virttest.utils_test.libvirt.check_exit_status函数的典型用法代码示例。如果您正苦于以下问题:Python check_exit_status函数的具体用法?Python check_exit_status怎么用?Python check_exit_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_exit_status函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_result
def check_result(result, status_error):
"""
Check virt-v2v command result
"""
libvirt.check_exit_status(result, status_error)
output = result.stdout + result.stderr
if not status_error:
if not utils_v2v.import_vm_to_ovirt(params, address_cache,
timeout=v2v_timeout):
raise exceptions.TestFail('Import VM failed')
# Check guest following the checkpoint document after convertion
logging.info('Checking common checkpoints for v2v')
vmchecker = VMChecker(test, params, env)
params['vmchecker'] = vmchecker
ret = vmchecker.run()
if len(ret) == 0:
logging.info("All common checkpoints passed")
# Check specific checkpoints
if checkpoint == 'cdrom':
virsh_session = utils_sasl.VirshSessionSASL(params)
virsh_session_id = virsh_session.get_id()
check_device_exist('cdrom', virsh_session_id)
# Merge 2 error lists
error_list.extend(vmchecker.errors)
if len(error_list):
raise exceptions.TestFail('%d checkpoints failed: %s' %
len(error_list), error_list)
开发者ID:chloerh,项目名称:tp-libvirt,代码行数:27,代码来源:function_test_esx.py
示例2: check_disk_save_restore
def check_disk_save_restore(save_file, device_targets,
startup_policy):
"""
Check domain save and restore operation.
"""
# Save the domain.
ret = virsh.save(vm_name, save_file,
**virsh_dargs)
libvirt.check_exit_status(ret)
# Restore the domain.
restore_error = False
# Check disk startup policy option
if "optional" in startup_policy:
os.remove(disks[0]["source"])
restore_error = True
ret = virsh.restore(save_file, **virsh_dargs)
libvirt.check_exit_status(ret, restore_error)
if restore_error:
return
# Connect to the domain and check disk.
try:
session = vm.wait_for_login()
cmd = ("ls /dev/%s && mkfs.ext3 -F /dev/%s && mount /dev/%s"
" /mnt && ls /mnt && touch /mnt/test && umount /mnt"
% (device_targets[0], device_targets[0], device_targets[0]))
s, o = session.cmd_status_output(cmd)
if s:
session.close()
raise error.TestError("Failed to read/write disk in VM:"
" %s" % o)
session.close()
except (remote.LoginError, virt_vm.VMError, aexpect.ShellError), e:
raise error.TestError(str(e))
开发者ID:nertpinx,项目名称:tp-libvirt,代码行数:35,代码来源:virtual_disks_multidisks.py
示例3: test_pmsuspend
def test_pmsuspend(vm_name):
"""
Test pmsuspend command.
"""
if vm.is_dead():
vm.start()
vm.wait_for_login()
# Create swap partition if nessesary.
if not vm.has_swap():
swap_path = os.path.join(test.tmpdir, 'swap.img')
vm.create_swap_partition(swap_path)
ret = virsh.dompmsuspend(vm_name, "disk", **virsh_dargs)
libvirt.check_exit_status(ret)
# wait for vm to shutdown
if not utils_misc.wait_for(lambda: vm.state() == "shut off", 60):
test.fail("vm is still alive after S4 operation")
# Wait for vm and qemu-ga service to start
vm.start()
# Prepare guest agent and start guest
try:
vm.prepare_guest_agent()
except (remote.LoginError, virt_vm.VMError), detail:
test.fail("failed to prepare agent:\n%s" % detail)
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:25,代码来源:virtual_disks_gluster.py
示例4: check_event_value
def check_event_value(vm_name, perf_option, event):
"""
Check domstats output and if the event has a value as expect
1. if perf_option == --disable, there isn't a value/line
2. if perf_option == --enable, there is a value/line
:param vm_name: Domain name,id
:param perf_option: --enable or --disable
:param vent: perf event name
"""
logging.debug("check_event_value: vm_name= %s, perf_option=%s, event=%s",
vm_name, perf_option, event)
ret = False
result = virsh.domstats(vm_name, "--perf", ignore_status=True,
debug=True)
libvirt.check_exit_status(result)
output = result.stdout.strip()
logging.debug("domstats output is %s", output)
if perf_option == '--enable':
for line in output.split('\n'):
if '.' in line and event == (line.split('.')[1]).split('=')[0]:
ret = True
else:
ret = True
for line in output.split('\n'):
if '.' in line and event == (line.split('.')[1]).split('=')[0]:
ret = False
return ret
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:29,代码来源:virsh_perf.py
示例5: check_result
def check_result(result, status_error):
"""
Check virt-v2v command result
"""
libvirt.check_exit_status(result, status_error)
output = result.stdout + result.stderr
if skip_check:
logging.info('Skip checking vm after conversion')
elif not status_error:
if output_mode == 'rhev':
if not utils_v2v.import_vm_to_ovirt(params, address_cache,
timeout=v2v_timeout):
test.fail('Import VM failed')
if output_mode == 'libvirt':
try:
virsh.start(vm_name, debug=True, ignore_status=False)
except Exception, e:
test.fail('Start vm failed: %s' % str(e))
# Check guest following the checkpoint document after convertion
vmchecker = VMChecker(test, params, env)
params['vmchecker'] = vmchecker
if params.get('skip_vm_check') != 'yes':
if checkpoint != 'win2008r2_ostk':
ret = vmchecker.run()
if len(ret) == 0:
logging.info("All common checkpoints passed")
if checkpoint == 'win2008r2_ostk':
check_BSOD()
# Merge 2 error lists
error_list.extend(vmchecker.errors)
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:30,代码来源:convert_from_file.py
示例6: storagevol_validate
def storagevol_validate(pool_name, file=None, **virsh_dargs):
"""
Test for schema storagevol
"""
if pool_name is None:
raise error.TestNAError("None pool is specified.")
# Confirm the storagepool exists.
found = False
result = virsh.pool_list(ignore_status=True)
output = re.findall(r"(\S+)\ +(\S+)\ +(\S+)[\ +\n]", str(result.stdout))
for item in output[1:]:
if pool_name == item[0]:
found = True
break
if not found:
raise error.TestNAError("Make sure the storagepool %s exists!" % pool_name)
# Get volume name
cmd_result = virsh.vol_list(pool_name, **virsh_dargs)
libvirt.check_exit_status(cmd_result)
try:
vol_name = re.findall(r"(\S+)\ +(\S+)[\ +\n]", str(cmd_result.stdout))[1][0]
except IndexError:
raise error.TestError("Fail to get volume name")
if vol_name is not None:
cmd_result = virsh.vol_dumpxml(vol_name, pool_name, to_file=file)
libvirt.check_exit_status(cmd_result)
开发者ID:noxdafox,项目名称:tp-libvirt,代码行数:29,代码来源:virt_xml_validate.py
示例7: create_luks_secret
def create_luks_secret(vol_path, password, test):
"""
Create secret for luks encryption
:param vol_path: volume path.
:return: secret id if create successfully.
"""
sec_xml = secret_xml.SecretXML("no", "yes")
sec_xml.description = "volume secret"
sec_xml.usage = 'volume'
sec_xml.volume = vol_path
sec_xml.xmltreefile.write()
ret = virsh.secret_define(sec_xml.xml)
utlv.check_exit_status(ret)
try:
encryption_uuid = re.findall(r".+\S+(\ +\S+)\ +.+\S+",
ret.stdout.strip())[0].lstrip()
except IndexError:
test.error("Fail to get newly created secret uuid")
logging.debug("Secret uuid %s", encryption_uuid)
# Set secret value.
encoding = locale.getpreferredencoding()
secret_string = base64.b64encode(password.encode(encoding)).decode(encoding)
ret = virsh.secret_set_value(encryption_uuid, secret_string)
utlv.check_exit_status(ret)
return encryption_uuid
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:27,代码来源:virsh_vol_clone_wipe.py
示例8: make_relative_path_backing_files
def make_relative_path_backing_files():
"""
Create backing chain files of relative path.
:return: absolute path of top active file
"""
first_disk_source = get_first_disk_source()
basename = os.path.basename(first_disk_source)
root_dir = os.path.dirname(first_disk_source)
cmd = "mkdir -p %s" % os.path.join(root_dir, '{b..d}')
ret = process.run(cmd, shell=True)
libvirt.check_exit_status(ret)
# Make three external relative path backing files.
backing_file_dict = collections.OrderedDict()
backing_file_dict["b"] = "../%s" % basename
backing_file_dict["c"] = "../b/b.img"
backing_file_dict["d"] = "../c/c.img"
for key, value in list(backing_file_dict.items()):
backing_file_path = os.path.join(root_dir, key)
cmd = ("cd %s && qemu-img create -f qcow2 -o backing_file=%s,backing_fmt=qcow2 %s.img"
% (backing_file_path, value, key))
ret = process.run(cmd, shell=True)
libvirt.check_exit_status(ret)
return os.path.join(backing_file_path, "d.img")
开发者ID:yalzhang,项目名称:tp-libvirt,代码行数:25,代码来源:virsh_blockpull.py
示例9: secret_validate
def secret_validate(file=None, **virsh_dargs):
"""
Test for schema secret
"""
tmp_dir = data_dir.get_tmp_dir()
volume_path = os.path.join(tmp_dir, "secret_volume")
ephemeral = "no"
private = "no"
secret_xml_obj = SecretXML(ephemeral, private)
status, uuid = commands.getstatusoutput("uuidgen")
if status:
raise error.TestNAError("Failed to generate valid uuid")
secret_xml_obj.uuid = uuid
secret_xml_obj.volume = volume_path
secret_xml_obj.usage = "volume"
secret_obj_xmlfile = os.path.join(SECRET_DIR, uuid + ".xml")
cmd_result = virsh.secret_define(secret_xml_obj.xml, debug=True)
cmd_result = virsh.secret_list(**virsh_dargs)
libvirt.check_exit_status(cmd_result)
try:
uuid = re.findall(r"(\S+)\ +(\S+)[\ +\n]", str(cmd_result.stdout))[1][0]
except IndexError:
raise error.TestError("Fail to get secret uuid")
if uuid:
try:
virsh.secret_dumpxml(uuid, to_file=file, **virsh_dargs)
except error.CmdError, e:
raise error.TestError(str(e))
开发者ID:uni-peter-zheng,项目名称:tp-libvirt,代码行数:33,代码来源:virt_xml_validate.py
示例10: check_pool_list
def check_pool_list(pool_name, option="--all", expect_error=False):
"""
Check pool by running pool-list command with given option.
:param pool_name: Name of the pool
:param option: option for pool-list command
:param expect_error: Boolean value, expect command success or fail
"""
found = False
# Get the list stored in a variable
if list_dumpxml_acl:
result = virsh.pool_list(option, **acl_dargs)
else:
result = virsh.pool_list(option, ignore_status=True)
libvirt.check_exit_status(result, False)
output = re.findall(r"(\S+)\ +(\S+)\ +(\S+)[\ +\n]",
str(result.stdout))
for item in output:
if pool_name in item[0]:
found = True
break
if found:
logging.debug("Find pool '%s' in pool list.", pool_name)
else:
logging.debug("Not find pool %s in pool list.", pool_name)
if expect_error and found:
raise error.TestFail("Unexpect pool '%s' exist." % pool_name)
if not expect_error and not found:
raise error.TestFail("Expect pool '%s' doesn't exist." % pool_name)
开发者ID:crazyAxe,项目名称:tp-libvirt,代码行数:29,代码来源:virsh_pool_acl.py
示例11: make_snapshot
def make_snapshot():
"""
make external snapshots.
:return external snapshot path list
"""
logging.info("Making snapshot...")
first_disk_source = vm.get_first_disk_devices()['source']
snapshot_path_list = []
snapshot2_file = os.path.join(data_dir.get_tmp_dir(), "mem.s2")
snapshot3_file = os.path.join(data_dir.get_tmp_dir(), "mem.s3")
snapshot4_file = os.path.join(data_dir.get_tmp_dir(), "mem.s4")
snapshot4_disk_file = os.path.join(data_dir.get_tmp_dir(), "disk.s4")
snapshot5_file = os.path.join(data_dir.get_tmp_dir(), "mem.s5")
snapshot5_disk_file = os.path.join(data_dir.get_tmp_dir(), "disk.s5")
# Attempt to take different types of snapshots.
snapshots_param_dict = {"s1": "s1 --disk-only --no-metadata",
"s2": "s2 --memspec %s --no-metadata" % snapshot2_file,
"s3": "s3 --memspec %s --no-metadata --live" % snapshot3_file,
"s4": "s4 --memspec %s --diskspec vda,file=%s --no-metadata" % (snapshot4_file, snapshot4_disk_file),
"s5": "s5 --memspec %s --diskspec vda,file=%s --live --no-metadata" % (snapshot5_file, snapshot5_disk_file)}
for snapshot_name in sorted(snapshots_param_dict.keys()):
ret = virsh.snapshot_create_as(vm_name, snapshots_param_dict[snapshot_name],
**virsh_dargs)
libvirt.check_exit_status(ret)
if snapshot_name != 's4' and snapshot_name != 's5':
snapshot_path_list.append(first_disk_source.replace('qcow2', snapshot_name))
return snapshot_path_list
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:29,代码来源:virtual_disks_ceph.py
示例12: trigger_hpt_resize
def trigger_hpt_resize(session):
"""
Check the HPT order file and dmesg
:param session: the session to guest
:raise: test.fail if required message is not found
"""
hpt_order_path = "/sys/kernel/debug/powerpc/hpt_order"
hpt_order = session.cmd_output('cat %s' % hpt_order_path).strip()
hpt_order = int(hpt_order)
logging.info('Current hpt_order is %d', hpt_order)
hpt_order += 1
cmd = 'echo %d > %s' % (hpt_order, hpt_order_path)
cmd_result = session.cmd_status_output(cmd)
result = process.CmdResult(stderr=cmd_result[1],
stdout=cmd_result[1],
exit_status=cmd_result[0])
libvirt.check_exit_status(result)
dmesg = session.cmd('dmesg')
dmesg_content = params.get('dmesg_content').split('|')
for content in dmesg_content:
if content % hpt_order not in dmesg:
test.fail("'%s' is missing in dmesg" % (content % hpt_order))
else:
logging.info("'%s' is found in dmesg", content % hpt_order)
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:26,代码来源:migrate_options_shared.py
示例13: check_state
def check_state(expected_state):
result = virsh.domstate(vm_name, uri=uri)
utlv.check_exit_status(result)
vm_state = result.stdout.strip()
if vm_state == expected_state:
logging.info("Get expected state: %s", vm_state)
else:
raise TestFail("Get unexpected state: %s", vm_state)
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:8,代码来源:lxc_life_cycle.py
示例14: check_snapshot
def check_snapshot(bgjob=None):
"""
Do snapshot operation and check the results
"""
snapshot_name1 = "snap.s1"
snapshot_name2 = "snap.s2"
if not snapshot_vm_running:
vm.destroy(gracefully=False)
ret = virsh.snapshot_create_as(vm_name, snapshot_name1)
libvirt.check_exit_status(ret)
snap_lists = virsh.snapshot_list(vm_name)
if snapshot_name not in snap_lists:
test.fail("Snapshot %s doesn't exist"
% snapshot_name)
if snapshot_vm_running:
options = "--force"
else:
options = ""
ret = virsh.snapshot_revert(
vm_name, ("%s %s" % (snapshot_name, options)))
libvirt.check_exit_status(ret)
ret = virsh.dumpxml(vm_name)
if ret.stdout.count("<rng model="):
test.fail("Found rng device in xml")
if snapshot_with_rng:
if vm.is_alive():
vm.destroy(gracefully=False)
if bgjob:
bgjob.kill_func()
modify_rng_xml(params, False)
# Start the domain before disk-only snapshot
if vm.is_dead():
# Add random server
if params.get("backend_type") == "tcp":
cmd = "cat /dev/random | nc -4 -l localhost 1024"
bgjob = utils.AsyncJob(cmd)
vm.start()
vm.wait_for_login().close()
err_msgs = ("live disk snapshot not supported"
" with this QEMU binary")
ret = virsh.snapshot_create_as(vm_name,
"%s --disk-only"
% snapshot_name2)
if ret.exit_status:
if ret.stderr.count(err_msgs):
test.skip(err_msgs)
else:
test.fail("Failed to create external snapshot")
snap_lists = virsh.snapshot_list(vm_name)
if snapshot_name2 not in snap_lists:
test.fail("Failed to check snapshot list")
ret = virsh.domblklist(vm_name)
if not ret.stdout.count(snapshot_name2):
test.fail("Failed to find snapshot disk")
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:58,代码来源:libvirt_rng.py
示例15: run
def run(test, params, env):
"""
Test svirt in virt-clone.
"""
VIRT_CLONE = None
try:
VIRT_CLONE = utils_path.find_command("virt-clone")
except utils_path.CmdNotFoundError:
raise error.TestNAError("No virt-clone command found.")
# Get general variables.
status_error = ('yes' == params.get("status_error", 'no'))
host_sestatus = params.get("svirt_virt_clone_host_selinux", "enforcing")
# Get variables about seclabel for VM.
sec_type = params.get("svirt_virt_clone_vm_sec_type", "dynamic")
sec_model = params.get("svirt_virt_clone_vm_sec_model", "selinux")
sec_label = params.get("svirt_virt_clone_vm_sec_label", None)
sec_relabel = params.get("svirt_virt_clone_vm_sec_relabel", "yes")
sec_dict = {'type': sec_type, 'model': sec_model, 'label': sec_label,
'relabel': sec_relabel}
# Get variables about VM and get a VM object and VMXML instance.
vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
vmxml = VMXML.new_from_inactive_dumpxml(vm_name)
backup_xml = vmxml.copy()
# Get varialbles about image.
img_label = params.get('svirt_virt_clone_disk_label')
# Label the disks of VM with img_label.
disks = vm.get_disk_devices()
backup_labels_of_disks = {}
for disk in disks.values():
disk_path = disk['source']
backup_labels_of_disks[disk_path] = utils_selinux.get_context_of_file(
filename=disk_path)
utils_selinux.set_context_of_file(filename=disk_path,
context=img_label)
# Set selinux of host.
backup_sestatus = utils_selinux.get_status()
utils_selinux.set_status(host_sestatus)
# Set the context of the VM.
vmxml.set_seclabel([sec_dict])
vmxml.sync()
clone_name = ("%s-clone" % vm.name)
try:
cmd = ("%s --original %s --name %s --auto-clone" %
(VIRT_CLONE, vm.name, clone_name))
cmd_result = utils.run(cmd, ignore_status=True)
utils_libvirt.check_exit_status(cmd_result, status_error)
finally:
# clean up
for path, label in backup_labels_of_disks.items():
utils_selinux.set_context_of_file(filename=path, context=label)
backup_xml.sync()
utils_selinux.set_status(backup_sestatus)
if not virsh.domstate(clone_name).exit_status:
libvirt_vm.VM(clone_name, params, None, None).remove_with_storage()
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:58,代码来源:svirt_virt_clone.py
示例16: run
def run(test, params, env):
"""
Test domiftune tuning
1) Positive testing
1.1) get the current domiftune parameters for a running guest
1.2) set the current domiftune parameters for a running guest
2) Negative testing
2.1) get domiftune parameters
2.2) set domiftune parameters
"""
# Run test case
vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
status_error = params.get("status_error", "no")
start_vm = params.get("start_vm", "yes")
change_parameters = params.get("change_parameters", "no")
interface_ref = params.get("interface_ref", "name")
interface = []
if vm and not vm.is_alive():
vm.start()
if vm and vm.is_alive():
virt_xml_obj = vm_xml.VMXML(virsh_instance=virsh)
interface = virt_xml_obj.get_iface_dev(vm_name)
if_mac = interface[0]
# Get interface name
vmxml = virt_xml_obj.new_from_dumpxml(vm_name)
if_node = vmxml.get_iface_all().get(if_mac)
if_name = if_node.find('target').get('dev')
if interface_ref == "name":
interface = if_name
if interface_ref == "mac":
interface = if_mac
logging.debug("the interface is %s", interface)
test_dict = dict(params)
test_dict['vm'] = vm
if interface:
test_dict['iface_dev'] = interface
if start_vm == "no" and vm and vm.is_alive():
vm.destroy()
# positive and negative testing #########
if change_parameters == "no":
get_domiftune_parameter(test_dict, test)
else:
set_domiftune_parameter(test_dict, test)
ret = virsh.domiftune(vm_name, interface, 'current', '0', '0')
libvirt.check_exit_status(ret)
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:57,代码来源:virsh_domiftune.py
示例17: run
def run(test, params, env):
"""
Test the command virsh domcapabilities
"""
target_uri = params.get("target_uri", "default")
if target_uri.count("EXAMPLE.COM"):
raise error.TestNAError("Please replace '%s' with valid uri" %
target_uri)
connect_uri = libvirt_vm.normalize_connect_uri(target_uri)
virsh_options = params.get("virsh_options", "")
virttype = params.get("virttype_value", "")
emulatorbin = params.get("emulatorbin_value", "")
arch = params.get("arch_value", "")
machine = params.get("machine_value", "")
option_dict = {'arch': arch, 'virttype': virttype,
'emulatorbin': emulatorbin, 'machine': machine}
options_list = [option_dict]
extra_option = params.get("extra_option", "")
# Get --virttype, --emulatorbin, --arch and --machine values from
# virsh capabilities output, then assemble option for testing
# This will ignore the virttype, emulatorbin, arch and machine values
if virsh_options == "AUTO":
options_list = []
capa_xml = capability_xml.CapabilityXML()
guest_capa = capa_xml.get_guest_capabilities()
for arch_prop in guest_capa.values():
for arch in arch_prop.keys():
machine_list = arch_prop[arch]['machine']
virttype_list = []
emulatorbin_list = [arch_prop[arch]['emulator']]
for key in arch_prop[arch].keys():
if key.startswith("domain_"):
virttype_list.append(key[7:])
if arch_prop[arch][key].values():
emulatorbin_list.append(arch_prop[arch][key]['emulator'])
for virttype in virttype_list:
for emulatorbin in emulatorbin_list:
for machine in machine_list:
option_dict = {'arch': arch,
'virttype': virttype,
'emulatorbin': emulatorbin,
'machine': machine}
options_list.append(option_dict)
# Run test cases
for option in options_list:
result = virsh.domcapabilities(virttype=option['virttype'],
emulatorbin=option['emulatorbin'],
arch=option['arch'],
machine=option['machine'],
options=extra_option,
uri=connect_uri,
ignore_status=True,
debug=True)
# Check status_error
status_error = "yes" == params.get("status_error", "no")
utlv.check_exit_status(result, status_error)
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:57,代码来源:virsh_domcapabilities.py
示例18: dump_nodedev_xml
def dump_nodedev_xml(dev_name, dev_opt="", **dargs):
"""
Do dumpxml and check the result.
step1.execute nodedev-dumpxml command.
step1.compare info in xml with info in sysfs.
:param dev_name: name of device.
:param dev_opt: command extra options
:param dargs: extra dict args
"""
result = virsh.nodedev_dumpxml(dev_name, options=dev_opt, **dargs)
libvirt.check_exit_status(result)
logging.debug('Executing "virsh nodedev-dumpxml %s" finished.', dev_name)
# Compare info in xml with info in sysfs.
nodedevice_xml = nodedev_xml.NodedevXML.new_from_dumpxml(dev_name)
if not nodedevice_xml.validates:
test.error("nodedvxml of %s is not validated." % (dev_name))
# Get the dict of key to value in xml.
# nodedev_dict_xml contain the all keys and values in xml need checking.
nodedev_dict_xml = nodedevice_xml.get_key2value_dict()
# Get the dict of key to path in sysfs.
# nodedev_syspath_dict contain the all keys and the path of file which contain
# information for each key.
nodedev_syspath_dict = nodedevice_xml.get_key2syspath_dict()
# Get the values contained in files.
# nodedev_dict_sys contain the all keys and values in sysfs.
nodedev_dict_sys = {}
for key, filepath in list(nodedev_syspath_dict.items()):
with open(filepath, 'r') as f:
value = f.readline().rstrip('\n')
nodedev_dict_sys[key] = value
# Compare the value in xml and in syspath.
for key in nodedev_dict_xml:
xml_value = nodedev_dict_xml.get(key)
sys_value = nodedev_dict_sys.get(key)
if not xml_value == sys_value:
if (key == 'numa_node' and not
libvirt_version.version_compare(1, 2, 5)):
logging.warning("key: %s in xml is not supported yet" % key)
else:
test.error("key: %s in xml is %s,"
"but in sysfs is %s." %
(key, xml_value, sys_value))
else:
continue
logging.debug("Compare info in xml and info in sysfs finished"
"for device %s.", dev_name)
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:54,代码来源:virsh_nodedev_dumpxml.py
示例19: set_secret_value
def set_secret_value(password, encryption_uuid):
"""
Generate secret string and set secret value.
:param password: password for encryption
:param encryption_uuid: uuid of secret
"""
encoding = locale.getpreferredencoding()
secret_string = base64.b64encode(password.encode(encoding)).decode(encoding)
ret = virsh.secret_set_value(encryption_uuid, secret_string)
libvirt.check_exit_status(ret)
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:11,代码来源:virsh_vol_resize.py
示例20: check_save_restore
def check_save_restore(save_file):
"""
Test domain save and restore.
"""
# Save the domain.
ret = virsh.save(vm_name, save_file, **virsh_dargs)
libvirt.check_exit_status(ret)
# Restore the domain.
ret = virsh.restore(save_file, **virsh_dargs)
libvirt.check_exit_status(ret)
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:11,代码来源:virtual_disks_iscsi.py
注:本文中的virttest.utils_test.libvirt.check_exit_status函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论