本文整理汇总了Python中virttest.compat_52lts.decode_to_text函数的典型用法代码示例。如果您正苦于以下问题:Python decode_to_text函数的具体用法?Python decode_to_text怎么用?Python decode_to_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_to_text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_chap_auth_target
def set_chap_auth_target(self):
"""
set up authentication information for every single initiator,
which provides the capability to define common login information
for all Endpoints in a TPG
"""
auth_cmd = "targetcli /iscsi/%s/tpg1/ " % self.target
attr_cmd = ("set attribute %s %s %s" %
("demo_mode_write_protect=0",
"generate_node_acls=1",
"cache_dynamic_acls=1"))
process.system(auth_cmd + attr_cmd)
# Set userid
userid_cmd = "%s set auth userid=%s" % (auth_cmd, self.chap_user)
output = decode_to_text(process.system_output(userid_cmd))
if self.chap_user not in output:
raise exceptions.TestFail("Failed to set user. (%s)" % output)
# Set password
passwd_cmd = "%s set auth password=%s" % (auth_cmd, self.chap_passwd)
output = decode_to_text(process.system_output(passwd_cmd))
if self.chap_passwd not in output:
raise exceptions.TestFail("Failed to set password. (%s)" % output)
# Save configuration
process.system("targetcli / saveconfig")
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:iscsi.py
示例2: get_target_id
def get_target_id(self):
"""
Get target id from image name.
"""
cmd = "targetcli ls /iscsi 1"
target_info = decode_to_text(process.system_output(cmd))
target = None
for line in re.split("\n", target_info)[1:]:
if re.findall("o-\s\S+\s[\.]+\s\[TPGs:\s\d\]$", line):
# eg: iqn.2015-05.com.example:iscsi.disk
try:
target = re.findall("iqn[\.]\S+:\S+", line)[0]
except IndexError:
logging.info("No found target in %s", line)
continue
else:
continue
cmd = "targetcli ls /iscsi/%s/tpg1/luns" % target
luns_info = decode_to_text(process.system_output(cmd))
for lun_line in re.split("\n", luns_info):
if re.findall("o-\slun\d+", lun_line):
if self.emulated_image in lun_line:
break
else:
target = None
return target
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:iscsi.py
示例3: glusterd_start
def glusterd_start():
"""
Check for glusterd status and start it
"""
cmd = "service glusterd status"
output = decode_to_text(process.system_output(cmd, ignore_status=True))
# The blank before 'active' makes a distinction with 'inactive'
if ' active' not in output or 'running' not in output:
cmd = "service glusterd start"
error_context.context("Starting gluster dameon failed")
output = decode_to_text(process.system_output(cmd))
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:11,代码来源:gluster.py
示例4: info
def info(self, force_share=False, output="human"):
"""
Run qemu-img info command on image file and return its output.
:param output: string of output format(`human`, `json`)
"""
logging.debug("Run qemu-img info command on %s", self.image_filename)
backing_chain = self.params.get("backing_chain")
force_share &= self.cap_force_share
cmd = self.image_cmd
cmd += " info"
if force_share:
cmd += " -U"
if backing_chain == "yes":
if "--backing-chain" in self.help_text:
cmd += " --backing-chain"
else:
logging.warn("'--backing-chain' option is not supported")
if os.path.exists(self.image_filename) or self.is_remote_image():
cmd += " %s --output=%s" % (self.image_filename, output)
output = decode_to_text(process.system_output(cmd, verbose=True))
else:
logging.debug("Image file %s not found", self.image_filename)
output = None
return output
开发者ID:ldoktor,项目名称:avocado-vt,代码行数:25,代码来源:qemu_storage.py
示例5: snapshot_apply
def snapshot_apply(self):
"""
Apply a snapshot image.
:note: params should contain:
snapshot_image_name -- the name of snapshot image file
"""
cmd = self.image_cmd
if self.snapshot_tag:
cmd += " snapshot -a %s %s" % (self.snapshot_image_filename,
self.image_filename)
else:
raise exceptions.TestError("Can not find the snapshot image"
" parameters")
decode_to_text(process.system_output(cmd))
开发者ID:jcfaracco,项目名称:avocado-vt,代码行数:16,代码来源:qemu_storage.py
示例6: gen_lvmap_mpath
def gen_lvmap_mpath(session=None):
"""
Return the name mapping between logical volume and device
mapper multipathed device.
:param session: When session is given, it means VM session
Otherwise default value means it work for host
:return: None or a dict like:
{"lv_name": dm_name}
"""
names_map = None
cmd = ("lvdisplay|awk '/LV Name/{n=$3} "
"/Block device/{d=$3; sub(\".*:\", \"dm-\", d); print n,d;}'")
if session:
output = session.cmd_output(cmd).strip()
else:
output = decode_to_text(process.system_output(cmd, shell=True))
lines = output.splitlines()
if len(lines) >= 1:
names_map = {}
for line in lines:
values = line.split()
lv_name, mpath_name = values[0], values[1]
names_map.update({lv_name: mpath_name})
return names_map
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:25,代码来源:lv_utils.py
示例7: iscsi_logout
def iscsi_logout(target_name=None):
"""
Logout from a target. If the target name is not set then logout all
targets.
:params target_name: Name of the target.
"""
if target_name:
cmd = "iscsiadm --mode node --logout -T %s" % target_name
else:
cmd = "iscsiadm --mode node --logout all"
output = ''
try:
output = decode_to_text(process.system_output(cmd))
except process.CmdError as detail:
# iscsiadm will fail when no matching sessions found
# This failure makes no sense when target name is not specified
stderr = results_stderr_52lts(detail.result)
if not target_name and 'No matching sessions' in stderr:
logging.info("%s: %s", detail, stderr)
else:
raise
target_logout = ""
if "successful" in output:
target_logout = target_name
return target_logout
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:29,代码来源:iscsi.py
示例8: setup_pv
def setup_pv(self, vg):
"""
Setup physical volume device if exists return it directly;
"""
pvs = []
emulate_image_file = self.get_emulate_image_name()
cmd = "losetup -j %s" % emulate_image_file
output = decode_to_text(process.system_output(cmd))
try:
pv_name = re.findall("(/dev/loop\d+)", output, re.M | re.I)[-1]
pv = self.get_vol(pv_name, "pvs")
except IndexError:
pv = None
if pv is None:
img_file = self.make_emulate_image()
pv_name = self.make_volume(img_file)
pv_size = self.params["pv_size"]
pv = PhysicalVolume(pv_name, pv_size)
pv.create()
self.register(pv)
else:
logging.warn("PhysicalVolume(%s) really exists" % pv_name +
"skip to create it")
pv.set_vg(vg)
pvs.append(pv)
return pvs
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:26,代码来源:lvm.py
示例9: snapshot_list
def snapshot_list(self):
"""
List all snapshots in the given image
"""
cmd = self.image_cmd
cmd += " snapshot -l %s" % self.image_filename
return decode_to_text(process.system_output(cmd))
开发者ID:jcfaracco,项目名称:avocado-vt,代码行数:8,代码来源:qemu_storage.py
示例10: get_chap_accounts
def get_chap_accounts(self):
"""
Get all CHAP authentication accounts
"""
cmd = "tgtadm --lld iscsi --op show --mode account"
all_accounts = decode_to_text(process.system_output(cmd))
if all_accounts:
all_accounts = list(map(str.strip, all_accounts.splitlines()[1:]))
return all_accounts
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:9,代码来源:iscsi.py
示例11: snapshot_create
def snapshot_create(self):
"""
Create a snapshot image.
:note: params should contain:
snapshot_image_name -- the name of snapshot image file
"""
cmd = self.image_cmd
if self.snapshot_tag:
cmd += " snapshot -c %s" % self.snapshot_image_filename
else:
raise exceptions.TestError("Can not find the snapshot image"
" parameters")
cmd += " %s" % self.image_filename
decode_to_text(process.system_output(cmd))
return self.snapshot_tag
开发者ID:jcfaracco,项目名称:avocado-vt,代码行数:19,代码来源:qemu_storage.py
示例12: is_gluster_vol_avail
def is_gluster_vol_avail(vol_name):
"""
Check if the volume already available
"""
cmd = "gluster volume info"
error_context.context("Gluster volume info failed")
output = decode_to_text(process.system_output(cmd))
volume_name = re.findall(r'Volume Name: (%s)\n' % vol_name, output)
if volume_name:
return gluster_vol_start(vol_name)
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:10,代码来源:gluster.py
示例13: rbd_image_unmap
def rbd_image_unmap(rbd_pool_name, rbd_image_name):
"""
Unmaps the block device that was mapped via the rbd kernel module
:params rbd_pool_name: The name of rbd pool
:params rbd_image_name: The name of rbd image
"""
cmd = "rbd unmap /dev/rbd/%s/%s" % (rbd_pool_name, rbd_image_name)
output = decode_to_text(process.system_output(cmd, verbose=True))
if os.path.exist(os.path.join("/dev/rbd", rbd_pool_name, rbd_image_name)):
logging.debug("Failed to unmap image from local: %s" % output)
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:10,代码来源:ceph.py
示例14: make_volume
def make_volume(self, img_file, extra_args=""):
"""
Map a file to loop back device;
:param img_file: image file path;
:return: loop back device name;
"""
cmd = "losetup %s --show --find %s" % (extra_args, img_file)
pv_name = decode_to_text(process.system_output(cmd))
self.params["pv_name"] = pv_name.strip()
return pv_name
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:11,代码来源:lvm.py
示例15: check_memory_in_procfs
def check_memory_in_procfs(test, params, vm):
"""
Check memory info in procfs
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param vm: VM object
"""
qemu_pid = vm.get_pid()
policy = params['policy_mem']
if policy == 'preferred':
policy = 'prefer'
for mem_dev in params['mem_devs'].split():
memdev_params = params.object_params(mem_dev)
mem_size = memdev_params['size']
mem_size = int(float(utils_misc.normalize_data_size(mem_size, "K")))
smaps = process.system_output("grep -1 %d /proc/%d/smaps"
% (mem_size, qemu_pid))
smaps = decode_to_text(smaps).strip()
mem_path = memdev_params.get("mem-path")
if mem_path and (mem_path not in smaps):
test.fail("memdev = %s: mem-path '%s' is not in smaps '%s'!"
% (mem_dev, mem_path, smaps))
mem_start = smaps.split('-')[0]
numa_maps = process.system_output("grep %s /proc/%d/numa_maps"
% (mem_start, qemu_pid))
numa_maps = decode_to_text(numa_maps).strip()
if mem_path and (mem_path not in numa_maps):
test.fail("memdev = %s: mem-path '%s' is not in numa_maps '%s'!"
% (mem_dev, mem_path, numa_maps))
policy_numa = numa_maps.split()[1].split(':')
if policy != policy_numa[0]:
test.fail("memdev = %s:"
" 'policy' in numa_maps is '%s', but not '%s'!"
% (mem_dev, policy_numa[0], policy))
elif (policy != 'default'):
host_node = memdev_params['host-nodes']
if (policy_numa[1] != host_node):
test.fail("memdev = %s:"
" 'host-nodes' in numa_maps is '%s', but not '%s'!"
% (mem_dev, policy_numa[1], host_node))
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:41,代码来源:numa_memdev_options.py
示例16: run
def run(test, params, env):
"""
check time jumps in guest (only for Linux guest):
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
2) check current clocksource in guest
3) pin all vcpus to specfic host CPUs
4) verify time jump
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
vm = env.get_vm(params["main_vm"])
session = vm.wait_for_login()
error_context.context("Check the clock source currently used on guest",
logging.info)
cmd = "cat /sys/devices/system/clocksource/"
cmd += "clocksource0/current_clocksource"
logging.info("%s is current clocksource." % session.cmd_output(cmd))
error_context.context("Pin every vcpu to physical cpu", logging.info)
host_cpu_cnt_cmd = params["host_cpu_cnt_cmd"]
host_cpu_num = decode_to_text(process.system_output(host_cpu_cnt_cmd,
shell=True)).strip()
host_cpu_list = (_ for _ in range(int(host_cpu_num)))
if len(vm.vcpu_threads) > int(host_cpu_num):
host_cpu_list = []
for _ in range(len(vm.vcpu_threads)):
host_cpu_list.append(_ % int(host_cpu_num))
cpu_pin_list = list(zip(vm.vcpu_threads, host_cpu_list))
for vcpu, pcpu in cpu_pin_list:
process.system("taskset -p -c %s %s" % (pcpu, vcpu))
check_cmd = params["check_cmd"]
output = str(session.cmd_output(check_cmd)).splitlines()
session.close()
time_pattern = "%y-%m-%d %H:%M:%S"
time_list = []
for str_time in output:
time_struct = time.strptime(str_time, time_pattern)
etime = time.mktime(time_struct)
time_list.append(etime)
for idx, _ in enumerate(time_list):
if idx < len(time_list) - 1:
if _ == time_list[idx+1] or (_ + 1) == time_list[idx+1]:
continue
else:
test.fail("Test fail, time jumps backward or forward on guest")
else:
break
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:53,代码来源:timerdevice_time_jump_check.py
示例17: iscsi_get_nodes
def iscsi_get_nodes():
"""
Get the iscsi nodes
"""
cmd = "iscsiadm --mode node"
output = decode_to_text(process.system_output(cmd, ignore_status=True))
pattern = r"(\d+\.\d+\.\d+\.\d+|\[.+\]):\d+,\d+\s+([\w\.\-:\d]+)"
nodes = []
if "No records found" not in output:
nodes = re.findall(pattern, output)
return nodes
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:12,代码来源:iscsi.py
示例18: delete_target
def delete_target(self):
"""
Delete target from host.
"""
cmd = "tgtadm --lld iscsi --mode target --op show"
output = decode_to_text(process.system_output(cmd))
if re.findall("%s$" % self.target, output, re.M):
if self.emulated_id:
cmd = "tgtadm --lld iscsi --mode target --op delete "
cmd += "--tid %s" % self.emulated_id
process.system(cmd)
if self.restart_tgtd:
restart_tgtd()
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:13,代码来源:iscsi.py
示例19: list_users
def list_users(self, remote=True, sasldb_path="/etc/libvirt/passwd.db"):
"""
List users in sasldb
"""
cmd = "%s -f %s" % (self.sasl_user_cmd, sasldb_path)
try:
if remote:
self.session = self.get_session()
return self.session.cmd_output(cmd)
else:
return decode_to_text(process.system_output(cmd))
except process.CmdError:
logging.error("Failed to set a user's sasl password %s", cmd)
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:13,代码来源:utils_sasl.py
示例20: snapshot_del
def snapshot_del(self, blkdebug_cfg=""):
"""
Delete a snapshot image.
:param blkdebug_cfg: The configure file of blkdebug
:note: params should contain:
snapshot_image_name -- the name of snapshot image file
"""
cmd = self.image_cmd
if self.snapshot_tag:
cmd += " snapshot -d %s" % self.snapshot_image_filename
else:
raise exceptions.TestError("Can not find the snapshot image"
" parameters")
if blkdebug_cfg:
cmd += " blkdebug:%s:%s" % (blkdebug_cfg, self.image_filename)
else:
cmd += " %s" % self.image_filename
decode_to_text(process.system_output(cmd))
开发者ID:jcfaracco,项目名称:avocado-vt,代码行数:22,代码来源:qemu_storage.py
注:本文中的virttest.compat_52lts.decode_to_text函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论