Skip to content

Commit a13c03b

Browse files
committedJan 7, 2016
Catch process.CmdError instead of error.CmdError
Now we using process module from avocado to run commands and raise exceptiones, so adapt tp-libvirt cases to it. Signed-off-by: Yanbing Du <ydu@redhat.com>
1 parent 8d23e4d commit a13c03b

38 files changed

+194
-127
lines changed
 

‎libguestfs/tests/virt_sysprep.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import aexpect
55

66
from autotest.client.shared import error
7-
from autotest.client import utils
7+
8+
from avocado.utils import process
89

910
from virttest import libvirt_vm
1011
from virttest import virsh
@@ -80,7 +81,7 @@ def modify_source(vm_name, target, dst_image):
8081
virsh.attach_disk(vm_name, dst_image, target, extra=options,
8182
ignore_status=False)
8283
except (remote.LoginError, virt_vm.VMError,
83-
aexpect.ShellError, error.CmdError), detail:
84+
aexpect.ShellError, process.CmdError), detail:
8485
raise error.TestFail("Modify guest source failed: %s" % detail)
8586

8687
def modify_network(vm_name, first_nic):
@@ -141,7 +142,7 @@ def clean_clone_vm():
141142
virsh.undefine(vm_clone_name, ignore_status=False)
142143
if os.path.exists(clone_image):
143144
os.remove(clone_image)
144-
except error.CmdError, detail:
145+
except process.CmdError, detail:
145146
raise error.TestFail("Clean clone guest failed!:%s" % detail)
146147

147148
sysprep_type = params.get("sysprep_type", 'clone')
@@ -193,8 +194,8 @@ def clean_clone_vm():
193194
if sysprep_type == "resize":
194195
img_size = image_info_dict['vsize'] / 1024 / 1024 / 1024
195196
resize_image = "%s_resize.img" % clone_image
196-
utils.run("qemu-img create -f raw %s %dG" % (resize_image,
197-
(img_size + 1)))
197+
cmd = "qemu-img create -f raw %s %dG" % (resize_image, (img_size + 1))
198+
process.run(cmd, shell=True)
198199
lgf.virt_resize_cmd(clone_image, resize_image, timeout=600,
199200
debug=True)
200201
modify_source(vm_clone_name, target, resize_image)

‎libvirt/tests/src/libvirt_bench/libvirt_bench_usb_hotplug.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from autotest.client.shared import error
66

7+
from avocado.utils import process
8+
79
from virttest import data_dir
810
from virttest import virsh
911
from virttest import utils_test
@@ -91,28 +93,28 @@ def _is_stress_running():
9193

9294
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
9395
if result.exit_status:
94-
raise error.CmdError(result.command, result)
96+
raise process.CmdError(result.command, result)
9597
if keyboard:
9698
attach_cmd = "device_add"
9799
attach_cmd += " usb-kdb,bus=usb1.0,id=kdb"
98100

99101
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
100102
if result.exit_status:
101-
raise error.CmdError(result.command, result)
103+
raise process.CmdError(result.command, result)
102104
if mouse:
103105
attach_cmd = "device_add"
104106
attach_cmd += " usb-mouse,bus=usb1.0,id=mouse"
105107

106108
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
107109
if result.exit_status:
108-
raise error.CmdError(result.command, result)
110+
raise process.CmdError(result.command, result)
109111
if tablet:
110112
attach_cmd = "device_add"
111113
attach_cmd += " usb-tablet,bus=usb1.0,id=tablet"
112114

113115
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
114116
if result.exit_status:
115-
raise error.CmdError(result.command, result)
117+
raise process.CmdError(result.command, result)
116118
else:
117119
if disk:
118120
utils_test.libvirt.create_local_disk("file", path, size="1M")
@@ -128,7 +130,7 @@ def _is_stress_running():
128130

129131
result = virsh.attach_device(vm_name, disk_xml.xml)
130132
if result.exit_status:
131-
raise error.CmdError(result.command, result)
133+
raise process.CmdError(result.command, result)
132134
if mouse:
133135
mouse_xml = Input("mouse")
134136
mouse_xml.input_bus = "usb"
@@ -137,7 +139,7 @@ def _is_stress_running():
137139

138140
result = virsh.attach_device(vm_name, mouse_xml.xml)
139141
if result.exit_status:
140-
raise error.CmdError(result.command, result)
142+
raise process.CmdError(result.command, result)
141143
if tablet:
142144
tablet_xml = Input("tablet")
143145
tablet_xml.input_bus = "usb"
@@ -146,7 +148,7 @@ def _is_stress_running():
146148

147149
result = virsh.attach_device(vm_name, tablet_xml.xml)
148150
if result.exit_status:
149-
raise error.CmdError(result.command, result)
151+
raise process.CmdError(result.command, result)
150152
if keyboard:
151153
kbd_xml = Input("keyboard")
152154
kbd_xml.input_bus = "usb"
@@ -155,7 +157,7 @@ def _is_stress_running():
155157

156158
result = virsh.attach_device(vm_name, kbd_xml.xml)
157159
if result.exit_status:
158-
raise error.CmdError(result.command, result)
160+
raise process.CmdError(result.command, result)
159161

160162
if attach_type == "qemu_monitor":
161163
options = "--hmp"
@@ -165,46 +167,46 @@ def _is_stress_running():
165167

166168
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
167169
if result.exit_status:
168-
raise error.CmdError(result.command, result)
170+
raise process.CmdError(result.command, result)
169171
if mouse:
170172
attach_cmd = "device_del"
171173
attach_cmd += (" mouse")
172174

173175
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
174176
if result.exit_status:
175-
raise error.CmdError(result.command, result)
177+
raise process.CmdError(result.command, result)
176178
if keyboard:
177179
attach_cmd = "device_del"
178180
attach_cmd += (" keyboard")
179181

180182
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
181183
if result.exit_status:
182-
raise error.CmdError(result.command, result)
184+
raise process.CmdError(result.command, result)
183185
if tablet:
184186
attach_cmd = "device_del"
185187
attach_cmd += (" tablet")
186188

187189
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=options)
188190
if result.exit_status:
189-
raise error.CmdError(result.command, result)
191+
raise process.CmdError(result.command, result)
190192
else:
191193
if disk:
192194
result = virsh.detach_device(vm_name, disk_xml.xml)
193195
if result.exit_status:
194-
raise error.CmdError(result.command, result)
196+
raise process.CmdError(result.command, result)
195197
if mouse:
196198
result = virsh.detach_device(vm_name, mouse_xml.xml)
197199
if result.exit_status:
198-
raise error.CmdError(result.command, result)
200+
raise process.CmdError(result.command, result)
199201
if keyboard:
200202
result = virsh.detach_device(vm_name, kbd_xml.xml)
201203
if result.exit_status:
202-
raise error.CmdError(result.command, result)
204+
raise process.CmdError(result.command, result)
203205
if tablet:
204206
result = virsh.detach_device(vm_name, tablet_xml.xml)
205207
if result.exit_status:
206-
raise error.CmdError(result.command, result)
207-
except error.CmdError, e:
208+
raise process.CmdError(result.command, result)
209+
except process.CmdError, e:
208210
if not status_error:
209211
raise error.TestFail("failed to attach device.\n"
210212
"Detail: %s." % result)

‎libvirt/tests/src/libvirt_scsi.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from autotest.client.shared import error
99

10+
from avocado.utils import process
11+
1012
from virttest import virt_vm
1113
from virttest import qemu_storage
1214
from virttest import data_dir
@@ -77,7 +79,7 @@ def run(test, params, env):
7779
try:
7880
cdrom = CdromDisk(cdrom_path, data_dir.get_tmp_dir())
7981
cdrom.close()
80-
except error.CmdError, detail:
82+
except process.CmdError, detail:
8183
raise error.TestNAError("Failed to create cdrom disk: %s" % detail)
8284

8385
cdrom_disk = Disk(type_name="file")

‎libvirt/tests/src/libvirt_usb_hotplug_device.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from autotest.client.shared import error
88

9+
from avocado.utils import process
10+
911
from virttest import data_dir
1012
from virttest import virsh
1113
from virttest import utils_misc
@@ -91,7 +93,7 @@ def is_hotplug_ok():
9193

9294
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=opt)
9395
if result.exit_status or (result.stdout.find("OK") == -1):
94-
raise error.CmdError(result.command, result)
96+
raise process.CmdError(result.command, result)
9597

9698
attach_cmd = "device_add usb-storage,"
9799
attach_cmd += ("id=drive-usb-%s,bus=usb1.0,drive=drive-usb-%s" % (i, i))
@@ -101,7 +103,7 @@ def is_hotplug_ok():
101103

102104
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=opt)
103105
if result.exit_status:
104-
raise error.CmdError(result.command, result)
106+
raise process.CmdError(result.command, result)
105107
else:
106108
attributes = {'type_name': "usb", 'bus': "1", 'port': "0"}
107109
if usb_type == "storage":
@@ -124,7 +126,7 @@ def is_hotplug_ok():
124126

125127
result = virsh.attach_device(vm_name, dev_xml.xml)
126128
if result.exit_status:
127-
raise error.CmdError(result.command, result)
129+
raise process.CmdError(result.command, result)
128130

129131
if status_error and usb_type == "storage":
130132
if utils_misc.wait_for(is_hotplug_ok, timeout=30):
@@ -148,12 +150,12 @@ def is_hotplug_ok():
148150

149151
result = virsh.qemu_monitor_command(vm_name, attach_cmd, options=opt)
150152
if result.exit_status:
151-
raise error.CmdError(result.command, result)
153+
raise process.CmdError(result.command, result)
152154
else:
153155
result = virsh.detach_device(vm_name, dev_xml.xml)
154156
if result.exit_status:
155-
raise error.CmdError(result.command, result)
156-
except error.CmdError, e:
157+
raise process.CmdError(result.command, result)
158+
except process.CmdError, e:
157159
if not status_error:
158160
# live attach of device 'input' is not supported
159161
ret = result.stderr.find("Operation not supported")

‎libvirt/tests/src/macvtap.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from autotest.client.shared import error
66

7+
from avocado.utils import process
8+
79
from virttest import remote
810
from virttest import utils_net
911
from virttest import virsh
@@ -52,7 +54,7 @@ def run(test, params, env):
5254
origin_status = iface_cls.is_up()
5355
if not origin_status:
5456
iface_cls.up()
55-
except error.CmdError, detail:
57+
except process.CmdError, detail:
5658
raise error.TestNAError(str(detail))
5759
br_cls = utils_net.Bridge()
5860
if eth_card_no in br_cls.list_iface():
@@ -154,7 +156,7 @@ def private_test(session):
154156
% (vm1.name, vm2.name))
155157
try:
156158
iface_cls.down()
157-
except error.CmdError, detail:
159+
except process.CmdError, detail:
158160
raise error.TestNAError(str(detail))
159161
ping_s, _ = ping(vm2_ip, count=1, timeout=5, session=session)
160162
if not ping_s:
@@ -199,7 +201,7 @@ def bridge_test(session):
199201
% (vm1.name, vm2.name))
200202
try:
201203
iface_cls.down()
202-
except error.CmdError, detail:
204+
except process.CmdError, detail:
203205
raise error.TestNAError(str(detail))
204206
ping_s, _ = ping(remote_ip, count=1, timeout=5, session=session)
205207
if not ping_s:

‎libvirt/tests/src/multifunction.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from autotest.client.shared import error
66

7+
from avocado.utils import process
8+
79
from virttest import libvirt_vm
810
from virttest import virsh
911
from virttest import data_dir
@@ -33,7 +35,7 @@ def cleanup_vm(vm_name=None, disk_removed=None):
3335
try:
3436
if vm_name is not None:
3537
virsh.undefine(vm_name)
36-
except error.CmdError:
38+
except process.CmdError:
3739
pass
3840
try:
3941
if disk_removed is not None:

‎libvirt/tests/src/numa/guest_numa.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import re
22
import logging
33

4-
from autotest.client.shared import utils
54
from autotest.client.shared import error
65

6+
from avocado.utils import process
7+
78
from virttest import virt_vm
89
from virttest import libvirt_xml
910
from virttest import utils_misc
@@ -359,6 +360,6 @@ def _update_qemu_conf():
359360
libvirtd.restart()
360361
for mt_path in mount_path:
361362
try:
362-
utils.system("umount %s" % mt_path)
363-
except error.CmdError:
363+
process.run("umount %s" % mt_path, shell=True)
364+
except process.CmdError:
364365
logging.warning("umount %s failed" % mt_path)

‎libvirt/tests/src/storage_discard.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import logging
77
import time
88

9-
from autotest.client import utils, lv_utils
9+
from autotest.client import lv_utils
1010
from autotest.client.shared import error
1111

12+
from avocado.utils import process
13+
1214
from virttest import virsh
1315
from virttest import data_dir
1416
from virttest import iscsi
@@ -35,7 +37,7 @@ def get_disk_capacity(disk_type, imagefile=None, lvname=None):
3537
while for block, it's volume space percentage in 'lvs'
3638
"""
3739
if disk_type == "file":
38-
result = utils.run("du -sm %s" % imagefile)
40+
result = process.run("du -sm %s" % imagefile, shell=True)
3941
return result.stdout.split()[0].strip()
4042
elif disk_type == "block":
4143
if lvname is None:
@@ -64,7 +66,7 @@ def create_iscsi_device(device_size="2G"):
6466
if iscsi_device == ():
6567
raise error.TestFail("No matched iscsi device.")
6668

67-
check_ret = utils.run("ls %s" % device_name)
69+
check_ret = process.run("ls %s" % device_name, shell=True)
6870
if check_ret.exit_status:
6971
raise error.TestFail("Can not find provided device:%s" % check_ret)
7072
return device_name
@@ -208,7 +210,7 @@ def do_fstrim(fstrim_type, vm, status_error=False):
208210
% vm.name)
209211
try:
210212
virsh.command(cmd, debug=True, ignore_status=False)
211-
except error.CmdError:
213+
except process.CmdError:
212214
raise error.TestFail("Execute qemu-agent-command failed.")
213215

214216

@@ -323,6 +325,7 @@ def run(test, params, env):
323325
lv_utils.vg_remove("vgthin")
324326
except error.TestError, detail:
325327
logging.debug(str(detail))
326-
utils.run("pvremove -f %s" % discard_device, ignore_status=True)
328+
process.run("pvremove -f %s" % discard_device, ignore_status=True,
329+
shell=True)
327330
if create_iscsi:
328331
utlv.setup_or_cleanup_iscsi(is_setup=False)

‎libvirt/tests/src/svirt/dac_nfs_disk.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import logging
44

55
from autotest.client.shared import error
6-
from autotest.client import utils
6+
7+
from avocado.utils import process
78

89
from virttest import qemu_storage
910
from virttest import data_dir
@@ -131,7 +132,8 @@ def run(test, params, env):
131132
export_options=export_options)
132133

133134
# set virt_use_nfs
134-
result = utils.run("setsebool virt_use_nfs %s" % virt_use_nfs)
135+
result = process.run("setsebool virt_use_nfs %s" % virt_use_nfs,
136+
shell=True)
135137
if result.exit_status:
136138
raise error.TestNAError("Failed to set virt_use_nfs value")
137139

@@ -213,7 +215,7 @@ def run(test, params, env):
213215
try:
214216
virsh.detach_disk(vm_name, target="vdf", extra="--persistent",
215217
debug=True)
216-
except error.CmdError:
218+
except process.CmdError:
217219
raise error.TestFail("Detach disk 'vdf' from VM %s failed."
218220
% vm.name)
219221
finally:

‎libvirt/tests/src/svirt/svirt_attach_disk.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
22

33
from autotest.client.shared import error
4-
from autotest.client import utils
4+
5+
from avocado.utils import process
56

67
from virttest import qemu_storage
78
from virttest import data_dir
@@ -130,7 +131,8 @@ def run(test, params, env):
130131
# set host_sestatus as nfs pool will reset it
131132
utils_selinux.set_status(host_sestatus)
132133
# set virt_use_nfs
133-
result = utils.run("setsebool virt_use_nfs %s" % virt_use_nfs)
134+
result = process.run("setsebool virt_use_nfs %s" % virt_use_nfs,
135+
shell=True)
134136
if result.exit_status:
135137
raise error.TestNAError("Failed to set virt_use_nfs value")
136138
else:
@@ -195,7 +197,7 @@ def run(test, params, env):
195197
try:
196198
virsh.detach_disk(vm_name, target="vdf", extra="--persistent",
197199
debug=True)
198-
except error.CmdError:
200+
except process.CmdError:
199201
raise error.TestFail("Detach disk 'vdf' from VM %s failed."
200202
% vm.name)
201203
finally:

‎libvirt/tests/src/timer_management.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from autotest.client import utils
1010
from autotest.client.shared import error
1111

12+
from avocado.utils import process
13+
1214
from virttest import utils_test
1315
from virttest import virsh
1416
from virttest import data_dir
@@ -253,7 +255,7 @@ def manipulate_vm(vm, operation, params=None):
253255
try:
254256
inject_times -= 1
255257
virsh.inject_nmi(vm.name, debug=True, ignore_status=False)
256-
except error.CmdError, detail:
258+
except process.CmdError, detail:
257259
err_msg = "Inject nmi failed: %s" % detail
258260
elif operation == "dump":
259261
dump_times = int(params.get("dump_times", 10))
@@ -263,7 +265,7 @@ def manipulate_vm(vm, operation, params=None):
263265
dump_path = os.path.join(data_dir.get_tmp_dir(), "dump.file")
264266
try:
265267
virsh.dump(vm.name, dump_path, debug=True, ignore_status=False)
266-
except (error.CmdError, OSError), detail:
268+
except (process.CmdError, OSError), detail:
267269
err_msg = "Dump %s failed: %s" % (vm.name, detail)
268270
try:
269271
os.remove(dump_path)
@@ -277,7 +279,7 @@ def manipulate_vm(vm, operation, params=None):
277279
try:
278280
virsh.suspend(vm.name, debug=True, ignore_status=False)
279281
virsh.resume(vm.name, debug=True, ignore_status=False)
280-
except error.CmdError, detail:
282+
except process.CmdError, detail:
281283
err_msg = "Suspend-Resume %s failed: %s" % (vm.name, detail)
282284
elif operation == "save_restore":
283285
save_times = int(params.get("save_times", 10))
@@ -289,7 +291,7 @@ def manipulate_vm(vm, operation, params=None):
289291
virsh.save(vm.name, save_path, debug=True,
290292
ignore_status=False)
291293
virsh.restore(save_path, debug=True, ignore_status=False)
292-
except error.CmdError, detail:
294+
except process.CmdError, detail:
293295
err_msg = "Save-Restore %s failed: %s" % (vm.name, detail)
294296
try:
295297
os.remove(save_path)

‎libvirt/tests/src/vfio.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from autotest.client.shared import error
66

7+
from avocado.utils import process
8+
79
from virttest import libvirt_vm
810
from virttest import virsh
911
from virttest import data_dir
@@ -187,7 +189,7 @@ def execute_ttcp(vm, params):
187189
# Check connection first
188190
try:
189191
session1.cmd("ping -c 4 %s" % remote_ip)
190-
except error.CmdError:
192+
except Exception:
191193
raise error.TestFail("Couldn't connect to %s through %s"
192194
% (remote_ip, vm.name))
193195

@@ -247,7 +249,7 @@ def cleanup_vm(vm_name=None):
247249
try:
248250
if vm_name is not None:
249251
virsh.undefine(vm_name)
250-
except error.CmdError:
252+
except process.CmdError:
251253
pass
252254

253255

@@ -292,7 +294,7 @@ def test_nic_group(vm, params):
292294
ignore_status=False)
293295
logging.debug("VMXML with disk boot:\n%s", virsh.dumpxml(vm.name))
294296
vm.start()
295-
except (error.CmdError, virt_vm.VMStartError), detail:
297+
except (process.CmdError, virt_vm.VMStartError), detail:
296298
cleanup_devices(pci_id, device_type)
297299
raise error.TestFail("New device does not work well: %s" % detail)
298300

@@ -368,7 +370,7 @@ def test_fibre_group(vm, params):
368370
ignore_status=False)
369371
logging.debug("VMXML with disk boot:\n%s", virsh.dumpxml(vm.name))
370372
vm.start()
371-
except (error.CmdError, virt_vm.VMStartError), detail:
373+
except (process.CmdError, virt_vm.VMStartError), detail:
372374
cleanup_devices(pci_id, device_type)
373375
raise error.TestFail("New device does not work well: %s" % detail)
374376

@@ -437,7 +439,7 @@ def test_win_fibre_group(vm, params):
437439
flagstr="--config", debug=True,
438440
ignore_status=False)
439441
vm.start()
440-
except (error.CmdError, virt_vm.VMStartError), detail:
442+
except (process.CmdError, virt_vm.VMStartError), detail:
441443
cleanup_devices(pci_id, device_type)
442444
raise error.TestFail("New device does not work well: %s" % detail)
443445

@@ -506,7 +508,7 @@ def test_nic_fibre_group(vm, params):
506508
flagstr="--config", debug=True,
507509
ignore_status=False)
508510
vm.start()
509-
except (error.CmdError, virt_vm.VMStartError), detail:
511+
except (process.CmdError, virt_vm.VMStartError), detail:
510512
cleanup_devices(nic_pci_id, "Ethernet")
511513
cleanup_devices(fibre_pci_id, "Fibre")
512514
raise error.TestFail("New device does not work well: %s" % detail)
@@ -596,7 +598,7 @@ def test_nic_single(vm, params):
596598
cleanup_devices(pci_id, device_type)
597599
raise error.TestFail("Start vm succesfully after attaching single "
598600
"device to iommu group.Not expected.")
599-
except (error.CmdError, virt_vm.VMStartError), detail:
601+
except (process.CmdError, virt_vm.VMStartError), detail:
600602
logging.debug("Expected:New device does not work well: %s" % detail)
601603

602604
# Reattaching all devices in iommu group

‎libvirt/tests/src/virsh_cmd/domain/virsh_destroy.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from autotest.client.shared import error
22
from autotest.client.shared import ssh_key
33

4+
from avocado.utils import process
5+
46
from virttest import libvirt_vm
57
from virttest import remote
68
from virttest import virsh
@@ -83,7 +85,7 @@ def run(test, params, env):
8385
status, output = session.cmd_status_output(command,
8486
internal_timeout=5)
8587
session.close()
86-
except error.CmdError:
88+
except process.CmdError:
8789
status = 1
8890

8991
if libvirtd == "off":

‎libvirt/tests/src/virsh_cmd/domain/virsh_domid.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from autotest.client.shared import error
22

3+
from avocado.utils import process
4+
35
from virttest import libvirt_vm
46
from virttest import remote
57
from virttest import virsh
@@ -55,7 +57,7 @@ def remote_test(params, vm_name):
5557
if status != 0:
5658
err = output
5759
session.close()
58-
except error.CmdError:
60+
except process.CmdError:
5961
status = 1
6062
output = ""
6163
err = "remote test failed"

‎libvirt/tests/src/virsh_cmd/domain/virsh_migrate_multi_vms.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from autotest.client.shared import error
66
from autotest.client.shared import ssh_key
77

8+
from avocado.utils import process
9+
810
from virttest import libvirt_vm
911
from virttest import virsh
1012
from virttest import remote
@@ -126,8 +128,8 @@ def thread_func_migration(virsh_instance, cmd):
126128
global ret_migration
127129
# Migrate the domain.
128130
try:
129-
result = virsh_instance.command(cmd, ignore_status=False)
130-
except error.CmdError, detail:
131+
virsh_instance.command(cmd, ignore_status=False)
132+
except process.CmdError, detail:
131133
logging.error("Migration with %s failed:\n%s" % (cmd, detail))
132134
ret_migration = False
133135

‎libvirt/tests/src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import time
55

66
from autotest.client.shared import error
7-
from autotest.client.shared import utils
87
from autotest.client.shared import ssh_key
98

9+
from avocado.utils import process
10+
1011
from virttest import utils_test
1112
from virttest import virsh
1213
from virttest import utils_misc
@@ -27,7 +28,7 @@ def check_vm_state(vm, state):
2728
"""
2829
try:
2930
actual_state = vm.state()
30-
except error.CmdError:
31+
except process.CmdError:
3132
return False
3233
if cmp(actual_state, state) == 0:
3334
return True
@@ -47,7 +48,7 @@ def check_disks_in_vm(vm, vm_ip, disks_list=[], runner=None):
4748
try:
4849
logging.debug(runner.run(check_cmd))
4950
continue
50-
except error.CmdError, detail:
51+
except process.CmdError, detail:
5152
logging.debug("Remote checking failed:%s", detail)
5253
fail_list.append(disk)
5354
else:
@@ -65,12 +66,12 @@ def get_disk_id(device):
6566
"""
6667
Show disk by id.
6768
"""
68-
output = utils.run("ls /dev/disk/by-id/").stdout
69+
output = process.run("ls /dev/disk/by-id/", shell=True).stdout
6970
for line in output.splitlines():
7071
disk_ids = line.split()
7172
for disk_id in disk_ids:
72-
disk = os.path.basename(utils.run("readlink %s"
73-
% disk_id).stdout)
73+
disk = os.path.basename(
74+
process.run("readlink %s" % disk_id, shell=True).stdout)
7475
if disk == os.path.basename(device):
7576
return disk_id
7677
return None
@@ -240,7 +241,7 @@ def start_check_vm(vm):
240241
params, config=attach_disk_config)
241242
if ret.exit_status:
242243
raise error.TestFail(ret)
243-
except (error.TestFail, error.CmdError), detail:
244+
except (error.TestFail, process.CmdError), detail:
244245
if status_error:
245246
logging.debug("Expected failure:%s", detail)
246247
return
@@ -309,4 +310,4 @@ def start_check_vm(vm):
309310

310311
if runner:
311312
runner.session.close()
312-
utils.run("rm -f %s/*vsmtest" % created_img_path)
313+
process.run("rm -f %s/*vsmtest" % created_img_path, shell=True)

‎libvirt/tests/src/virsh_cmd/domain/virsh_qemu_monitor_blockjob.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from autotest.client.shared import error
66
from autotest.client.shared import ssh_key
77

8+
from avocado.utils import process
9+
810
from virttest import utils_test
911
from virttest import libvirt_vm
1012
from virttest import virsh
@@ -88,7 +90,7 @@ def copied_migration(vm, params, blockjob_type=None, block_target="vda"):
8890
elif blockjob_type == "complete":
8991
virsh.qemu_monitor_command(vm.name, complete_cmd, debug=True,
9092
ignore_status=False)
91-
except error.CmdError, detail:
93+
except process.CmdError, detail:
9294
blockjob_failures.append(str(detail))
9395

9496
# Job info FYI

‎libvirt/tests/src/virsh_cmd/domain/virsh_reboot.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from autotest.client.shared import error
77

8+
from avocado.utils import process
9+
810
from virttest import libvirt_vm
911
from virttest import virt_vm
1012
from virttest import virsh
@@ -80,7 +82,7 @@ def run(test, params, env):
8082
status, output = session.cmd_status_output(command,
8183
internal_timeout=5)
8284
session.close()
83-
except (remote.LoginError, error.CmdError, aexpect.ShellError), e:
85+
except (remote.LoginError, process.CmdError, aexpect.ShellError), e:
8486
logging.error("Exception: %s", str(e))
8587
status = -1
8688
if vm_ref != "remote_name":

‎libvirt/tests/src/virsh_cmd/domain/virsh_setvcpus.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from autotest.client.shared import error
77

8+
from avocado.utils import process
9+
810
from virttest import remote
911
from virttest import virsh
1012
from virttest import libvirt_vm
@@ -33,7 +35,7 @@ def remote_test(remote_ip, local_ip, remote_pwd, remote_prompt,
3335
session.close()
3436
if status != 0:
3537
err = output
36-
except error.CmdError:
38+
except process.CmdError:
3739
status = 1
3840
err = "remote test failed"
3941
return status, status_error, err

‎libvirt/tests/src/virsh_cmd/domain/virsh_shutdown.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from autotest.client.shared import error
22

3+
from avocado.utils import process
4+
35
from virttest import remote
46
from virttest import libvirt_vm
57
from virttest import virsh
@@ -88,7 +90,7 @@ def run(test, params, env):
8890
% (remote_uri, vm_name, mode))
8991
status = session.cmd_status(command, internal_timeout=5)
9092
session.close()
91-
except error.CmdError:
93+
except process.CmdError:
9294
status = 1
9395

9496
# recover libvirtd service start

‎libvirt/tests/src/virsh_cmd/domain/virsh_undefine.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import aexpect
55

66
from autotest.client.shared import error
7-
from autotest.client import utils
7+
8+
from avocado.utils import process
89

910
from virttest import libvirt_vm
1011
from virttest import virsh
@@ -154,7 +155,7 @@ def run(test, params, env):
154155
cmd_undefine = "virsh -c %s undefine %s" % (uri, vm_name)
155156
status, output = session.cmd_status_output(cmd_undefine)
156157
logging.info("Undefine output: %s", output)
157-
except (error.CmdError, remote.LoginError, aexpect.ShellError), de:
158+
except (process.CmdError, remote.LoginError, aexpect.ShellError), de:
158159
logging.error("Detail: %s", de)
159160
status = 1
160161

@@ -167,7 +168,7 @@ def run(test, params, env):
167168
try:
168169
if vm.is_alive():
169170
vm.destroy(gracefully=False)
170-
except error.CmdError, detail:
171+
except process.CmdError, detail:
171172
logging.error("Detail: %s", detail)
172173

173174
# Check if VM exists.
@@ -197,7 +198,7 @@ def run(test, params, env):
197198
if virsh.domain_exists(vm.name):
198199
virsh.undefine(vm_ref, ignore_status=True)
199200
cmd = "chmod 666 %s" % backup_xml.xml
200-
utils.run(cmd, ignore_status=False)
201+
process.run(cmd, ignore_status=False, shell=True)
201202
s_define = virsh.define(backup_xml.xml,
202203
unprivileged_user=unprivileged_user,
203204
uri=uri, ignore_status=True, debug=True)

‎libvirt/tests/src/virsh_cmd/domain/virsh_vcpuinfo.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from autotest.client.shared import error
44

5+
from avocado.utils import process
6+
57
from virttest import virsh
68
from virttest import utils_libvirtd
79

@@ -62,7 +64,7 @@ def remote_case(params, vm_name):
6264
vcback.close_session()
6365
if status != 0:
6466
err = output
65-
except error.CmdError:
67+
except process.CmdError:
6668
status = 1
6769
output = ""
6870
err = "remote test failed"

‎libvirt/tests/src/virsh_cmd/domain/virsh_vncdisplay.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from autotest.client.shared import error
22

3+
from avocado.utils import process
4+
35
from virttest import libvirt_vm
46
from virttest import virsh
57
from virttest import remote
@@ -59,7 +61,7 @@ def remote_case(params, vm_name):
5961
status, output = session.cmd_status_output(command,
6062
internal_timeout=5)
6163
session.close()
62-
except error.CmdError:
64+
except process.CmdError:
6365
status = 1
6466
output = "remote test failed"
6567
return status, output

‎libvirt/tests/src/virsh_cmd/host/virsh_capabilities.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import re
33

44
from autotest.client import os_dep
5-
from autotest.client.shared import utils
65
from autotest.client.shared import error
76

87
from avocado.utils import path as utils_path
8+
from avocado.utils import process
99

1010
from virttest import libvirt_vm
1111
from virttest import virsh
@@ -34,7 +34,7 @@ def compare_capabilities_xml(source):
3434
# Check the host arch.
3535
xml_arch = cap_xml.arch
3636
logging.debug("Host arch (capabilities_xml): %s", xml_arch)
37-
exp_arch = utils.run("arch", ignore_status=True).stdout.strip()
37+
exp_arch = process.run("arch", shell=True).stdout.strip()
3838
if cmp(xml_arch, exp_arch) != 0:
3939
raise error.TestFail("The host arch in capabilities_xml is expected"
4040
" to be %s, but get %s" % (exp_arch, xml_arch))
@@ -43,7 +43,7 @@ def compare_capabilities_xml(source):
4343
xml_cpu_count = cap_xml.cpu_count
4444
logging.debug("Host cpus count (capabilities_xml): %s", xml_cpu_count)
4545
cmd = "grep processor /proc/cpuinfo | wc -l"
46-
exp_cpu_count = int(utils.run(cmd, ignore_status=True).stdout.strip())
46+
exp_cpu_count = int(process.run(cmd, shell=True).stdout.strip())
4747
if xml_cpu_count != exp_cpu_count:
4848
raise error.TestFail("Host cpus count is expected to be %s, but get "
4949
"%s" % (exp_cpu_count, xml_cpu_count))
@@ -55,11 +55,11 @@ def compare_capabilities_xml(source):
5555
img = utils_path.find_command("qemu-kvm")
5656
except utils_path.CmdNotFoundError:
5757
raise error.TestNAError("Cannot find qemu-kvm")
58-
if re.search("ppc", utils.run("arch").stdout):
58+
if re.search("ppc", process.run("arch", shell=True).stdout):
5959
cmd = img + " --cpu ? | grep ppc"
6060
else:
6161
cmd = img + " --cpu ? | grep qemu"
62-
cmd_result = utils.run(cmd, ignore_status=True)
62+
cmd_result = process.run(cmd, shell=True)
6363
for guest in cap_xml.xmltreefile.findall('guest'):
6464
guest_wordsize = guest.find('arch').find('wordsize').text
6565
logging.debug("Arch of guest supported (capabilities_xml):%s",
@@ -73,7 +73,7 @@ def compare_capabilities_xml(source):
7373
first_domain = first_guest.find('arch').findall('domain')[0]
7474
guest_domain_type = first_domain.get('type')
7575
logging.debug("Hypervisor (capabilities_xml):%s", guest_domain_type)
76-
cmd_result = utils.run("virsh uri", ignore_status=True)
76+
cmd_result = process.run("virsh uri", shell=True)
7777
if not re.search(guest_domain_type, cmd_result.stdout.strip()):
7878
raise error.TestFail("The capabilities_xml gives an different "
7979
"hypervisor")
@@ -88,7 +88,7 @@ def compare_capabilities_xml(source):
8888
exp_pms = []
8989
for opt in pm_cap_map:
9090
cmd = '%s --%s' % (pm_cmd, opt)
91-
res = utils.run(cmd, ignore_status=True)
91+
res = process.run(cmd, ignore_status=True, shell=True)
9292
if res.exit_status == 0:
9393
exp_pms.append(pm_cap_map[opt])
9494
pms = cap_xml.power_management_list
@@ -114,7 +114,7 @@ def compare_capabilities_xml(source):
114114
output = virsh.capabilities(option, uri=connect_uri,
115115
ignore_status=False, debug=True)
116116
status = 0 # good
117-
except error.CmdError:
117+
except process.CmdError:
118118
status = 1 # bad
119119
output = ''
120120

‎libvirt/tests/src/virsh_cmd/host/virsh_uri.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from autotest.client.shared import error
44

5+
from avocado.utils import process
6+
57
from virttest import libvirt_vm
68
from virttest import virsh
79
from virttest import utils_libvirtd
@@ -48,7 +50,7 @@ def run(test, params, env):
4850
ignore_status=False,
4951
debug=True)
5052
status = 0 # good
51-
except error.CmdError:
53+
except process.CmdError:
5254
status = 1 # bad
5355
uri_test = ''
5456

‎libvirt/tests/src/virsh_cmd/interface/virsh_iface_edit.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
import aexpect
66

7-
from autotest.client import utils
87
from autotest.client.shared import error
98

9+
from avocado.utils import process
10+
1011
from virttest import remote
1112
from virttest import utils_net
1213
from virttest import virsh
@@ -23,7 +24,7 @@ def get_ifstart_mode(iface_name):
2324
try:
2425
xml = virsh.iface_dumpxml(iface_name, "--inactive", "", debug=True)
2526
start_mode = re.findall("start mode='(\S+)'", xml)[0]
26-
except (error.CmdError, IndexError):
27+
except (process.CmdError, IndexError):
2728
logging.error("Fail to get start mode for interface %s", iface_name)
2829
return start_mode
2930

@@ -72,15 +73,15 @@ def run(test, params, env):
7273
new_ifstart_mode = "onboot"
7374
try:
7475
# Backup interface script
75-
utils.run("cp %s %s" % (iface_script, iface_script_bk))
76+
process.run("cp %s %s" % (iface_script, iface_script_bk), shell=True)
7677

7778
# Edit interface
7879
edit_ifstart_mode(iface_name, old_ifstart_mode, new_ifstart_mode)
7980

8081
# Restart interface
8182
if iface_is_up:
8283
net_iface.down()
83-
utils.run("ifup %s" % iface_name)
84+
process.run("ifup %s" % iface_name, shell=True)
8485

8586
after_edit_mode = get_ifstart_mode(iface_name)
8687
if not after_edit_mode:
@@ -92,6 +93,6 @@ def run(test, params, env):
9293
% after_edit_mode)
9394
finally:
9495
net_iface.down()
95-
utils.run("mv %s %s" % (iface_script_bk, iface_script))
96+
process.run("mv %s %s" % (iface_script_bk, iface_script), shell=True)
9697
if iface_is_up:
97-
utils.run("ifup %s" % iface_name)
98+
process.run("ifup %s" % iface_name, shell=True)

‎libvirt/tests/src/virsh_cmd/monitor/virsh_domblkinfo.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from autotest.client.shared import error
44

5+
from avocado.utils import process
6+
57
from virttest import virsh
68
from virttest.libvirt_xml import vm_xml
79

@@ -46,7 +48,7 @@ def attach_disk_test():
4648
output_target = "Xen doesn't support domblkinfo target!"
4749
virsh.detach_disk(vm_name, front_dev, debug=True)
4850
return status_target, output_target, status_source, output_source
49-
except (error.CmdError, IOError):
51+
except (process.CmdError, IOError):
5052
return 1, "", 1, ""
5153

5254
def check_disk_info():

‎libvirt/tests/src/virsh_cmd/monitor/virsh_dominfo.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from autotest.client.shared import error
22

3+
from avocado.utils import process
4+
35
from virttest import libvirt_vm
46
from virttest import remote
57
from virttest import virsh
@@ -55,7 +57,7 @@ def remote_test(params, vm_name):
5557
if status != 0:
5658
err = output
5759
session.close()
58-
except error.CmdError:
60+
except process.CmdError:
5961
status = 1
6062
output = ""
6163
err = "remote test failed"

‎libvirt/tests/src/virsh_cmd/monitor/virsh_dommemstat.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from autotest.client.shared import error
22

3+
from avocado.utils import process
4+
35
from virttest import libvirt_vm
46
from virttest import virsh
57
from virttest import remote
@@ -65,7 +67,7 @@ def run(test, params, env):
6567
extra)
6668
status = session.cmd_status(command, internal_timeout=5)
6769
session.close()
68-
except error.CmdError:
70+
except process.CmdError:
6971
status = 1
7072

7173
# recover libvirtd service start

‎libvirt/tests/src/virsh_cmd/monitor/virsh_domstate.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from aexpect import ShellProcessTerminatedError
88

99
from autotest.client.shared import error
10-
from autotest.client.shared import utils
10+
11+
from avocado.utils import process
1112

1213
from virttest import libvirt_vm
1314
from virttest import remote
@@ -54,7 +55,7 @@ def check_crash_state(cmd_output, crash_action, dump_file=""):
5455
if cmd_output.strip() == expect_output:
5556
crash_state = True
5657
if dump_file:
57-
result = utils.run("ls %s" % dump_file, ignore_status=True)
58+
result = process.run("ls %s" % dump_file, ignore_status=True, shell=True)
5859
if result.exit_status == 0:
5960
logging.debug("Find the auto dump core file:\n%s", result.stdout)
6061
find_dump_file = True
@@ -102,7 +103,7 @@ def run(test, params, env):
102103
backup_xml = vmxml.copy()
103104

104105
# Back up qemu.conf
105-
utils.run("cp %s %s" % (QEMU_CONF, QEMU_CONF_BK))
106+
process.run("cp %s %s" % (QEMU_CONF, QEMU_CONF_BK), shell=True)
106107

107108
dump_path = os.path.join(test.tmpdir, "dump/")
108109
dump_file = ""
@@ -121,7 +122,7 @@ def run(test, params, env):
121122
# Config auto_dump_path in qemu.conf
122123
cmd = "echo auto_dump_path = \\\"%s\\\" >> %s" % (dump_path,
123124
QEMU_CONF)
124-
utils.run(cmd)
125+
process.run(cmd, shell=True)
125126
libvirtd_service.restart()
126127
if vm_oncrash_action in ['coredump-destroy', 'coredump-restart']:
127128
dump_file = dump_path + vm_name + "-*"
@@ -168,7 +169,7 @@ def run(test, params, env):
168169
except (ShellTimeoutError, ShellProcessTerminatedError):
169170
pass
170171
session.close()
171-
except error.CmdError, e:
172+
except process.CmdError, e:
172173
raise error.TestError("Guest prepare action error: %s" % e)
173174

174175
if libvirtd == "off":
@@ -190,7 +191,7 @@ def run(test, params, env):
190191
status, output = session.cmd_status_output(command,
191192
internal_timeout=5)
192193
session.close()
193-
except error.CmdError:
194+
except process.CmdError:
194195
status = 1
195196
else:
196197
result = virsh.domstate(vm_ref, extra, ignore_status=True,
@@ -237,7 +238,7 @@ def run(test, params, env):
237238
if libvirtd == "off":
238239
utils_libvirtd.libvirtd_start()
239240
# Recover VM
240-
utils.run("mv -f %s %s" % (QEMU_CONF_BK, QEMU_CONF))
241+
process.run("mv -f %s %s" % (QEMU_CONF_BK, QEMU_CONF), shell=True)
241242
vm.destroy(gracefully=False)
242243
backup_xml.sync()
243244
if os.path.exists(dump_path):

‎libvirt/tests/src/virsh_cmd/monitor/virsh_domstats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def prepare_vm_state(vm, vm_state):
5757
except (ShellTimeoutError, ShellProcessTerminatedError):
5858
pass
5959
session.close()
60-
except error.CmdError, e:
60+
except Exception, e:
6161
logging.error("Crash domain failed: %s", e)
6262
else:
6363
logging.error("Unknown state for this test")

‎libvirt/tests/src/virsh_cmd/network/virsh_net_destroy.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from autotest.client.shared import error
44

5+
from avocado.utils import process
6+
57
from virttest import virsh
68

79
from provider import libvirt_version
@@ -59,7 +61,7 @@ def run(test, params, env):
5961
else:
6062
if network_status == "inactive":
6163
virsh.net_destroy(network_name)
62-
except error.CmdError:
64+
except process.CmdError:
6365
raise error.TestError("Prepare network status failed!")
6466

6567
status = virsh.net_destroy(net_ref, extra, uri=uri, debug=True,
@@ -78,7 +80,7 @@ def run(test, params, env):
7880
if (network_current_status == "inactive" and
7981
virsh.net_state_dict()[network_name]['active']):
8082
virsh.net_destroy(network_name)
81-
except error.CmdError:
83+
except process.CmdError:
8284
raise error.TestError("Recover network status failed!")
8385

8486
# Check status_error

‎libvirt/tests/src/virsh_cmd/network/virsh_net_list.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from autotest.client.shared import error
55

6+
from avocado.utils import process
7+
68
from virttest import virsh
79

810
from provider import libvirt_version
@@ -54,21 +56,21 @@ def run(test, params, env):
5456
virsh.net_destroy(net_name, ignore_status=False)
5557
virsh.net_undefine(net_name, ignore_status=False)
5658
virsh.net_create(tmp_xml, ignore_status=False)
57-
except error.CmdError:
59+
except process.CmdError:
5860
raise error.TestFail("Transient network test failed!")
5961

6062
# Prepare network's status for testing.
6163
if net_status == "active":
6264
try:
6365
if not virsh.net_state_dict()[net_name]['active']:
6466
virsh.net_start(net_name, ignore_status=False)
65-
except error.CmdError:
67+
except process.CmdError:
6668
raise error.TestFail("Active network test failed!")
6769
else:
6870
try:
6971
if virsh.net_state_dict()[net_name]['active']:
7072
virsh.net_destroy(net_name, ignore_status=False)
71-
except error.CmdError:
73+
except process.CmdError:
7274
raise error.TestFail("Inactive network test failed!")
7375

7476
virsh_dargs = {'ignore_status': True}
@@ -93,7 +95,7 @@ def run(test, params, env):
9395
virsh.net_start(net_name, ignore_status=False)
9496
elif net_current_status == "inactive" and net_status == "active":
9597
virsh.net_destroy(net_name, ignore_status=False)
96-
except error.CmdError:
98+
except process.CmdError:
9799
raise error.TestFail("Recover network failed!")
98100

99101
# check result

‎libvirt/tests/src/virsh_cmd/snapshot/virsh_snapshot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from autotest.client.shared import error
55

6+
from avocado.utils import process
7+
68
from virttest import virt_vm
79
from virttest import virsh
810

@@ -23,7 +25,7 @@ def remove_snapshots(vm):
2325
for snap in snaps:
2426
try:
2527
virsh.snapshot_delete(vm, snap)
26-
except error.CmdError:
28+
except process.CmdError:
2729
logging.debug("Can not remove snapshot %s.", snap)
2830
remove_failed = remove_failed + 1
2931

@@ -136,7 +138,7 @@ def check_info(i1, i2, errorstr="Values differ"):
136138
check_info(infos["Descendants"], sni["Descendants"],
137139
"Incorrect descendants count")
138140

139-
except error.CmdError:
141+
except process.CmdError:
140142
handle_error("Failed getting snapshots info", vm_name)
141143
except error.TestFail, e:
142144
handle_error(str(e), vm_name)
@@ -163,7 +165,7 @@ def check_info(i1, i2, errorstr="Values differ"):
163165
session = vm.wait_for_login()
164166
test_file(session, sni["to_create"], 0)
165167
test_file(session, sni["to_delete"], 2)
166-
except error.CmdError:
168+
except process.CmdError:
167169
handle_error("Failed to revert snapshot", vm_name)
168170
except (error.TestFail, virt_vm.VMDeadError), e:
169171
handle_error(str(e), vm_name)

‎libvirt/tests/src/virsh_cmd/volume/virsh_vol_create.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import os
22
import logging
33

4-
from autotest.client import utils
54
from autotest.client.shared import error
65

6+
from avocado.utils import process
7+
78
from virttest import virsh
89
from virttest import libvirt_storage
910
from virttest import libvirt_xml
@@ -147,7 +148,7 @@ def post_process_vol(ori_vol_path):
147148
else:
148149
logging.error(unsupport_err)
149150
return
150-
rst = utils.run(process_vol_cmd, ignore_status=True)
151+
rst = process.run(process_vol_cmd, ignore_status=True, shell=True)
151152
if rst.exit_status:
152153
if "Snapshots of snapshots are not supported" in rst.stderr:
153154
logging.debug("%s is already a snapshot volume", ori_vol_path)
@@ -218,7 +219,8 @@ def check_vol(pool_name, vol_name, expect_exist=True):
218219
newvol = volxml.new_vol(**vol_arg)
219220
vol_xml = newvol['xml']
220221
if params.get('setup_libvirt_polkit') == 'yes':
221-
utils.run("chmod 666 %s" % vol_xml, ignore_status=True)
222+
process.run("chmod 666 %s" % vol_xml, ignore_status=True,
223+
shell=True)
222224

223225
# Run virsh_vol_create to create vol
224226
logging.debug("Create volume from XML: %s" % newvol.xmltreefile)
@@ -257,7 +259,7 @@ def check_vol(pool_name, vol_name, expect_exist=True):
257259
try:
258260
virsh.pool_refresh(src_pool_name, ignore_status=False)
259261
check_vol(src_pool_name, process_vol, expect_vol_exist)
260-
except (error.CmdError, error.TestFail), e:
262+
except (process.CmdError, error.TestFail), e:
261263
if process_vol_type == "thin":
262264
logging.error(e)
263265
raise error.TestNAError("You may encounter bug BZ#1060287")
@@ -272,7 +274,7 @@ def check_vol(pool_name, vol_name, expect_exist=True):
272274
# lv snapshot, so before destroy the pool, we need activate it manually
273275
if src_pool_type == 'logical' and vol_path_list:
274276
vg_name = vol_path_list[0].split('/')[2]
275-
utils.run("lvchange -ay %s" % vg_name)
277+
process.run("lvchange -ay %s" % vg_name, shell=True)
276278
try:
277279
pvt.cleanup_pool(src_pool_name, src_pool_type, src_pool_target,
278280
src_emulated_image)

‎libvirt/tests/src/virsh_cmd/volume/virsh_volume_application.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from autotest.client.shared import error
55

6+
from avocado.utils import process
7+
68
from virttest import libvirt_storage
79
from virttest import virsh
810
from virttest import data_dir
@@ -130,7 +132,7 @@ def run(test, params, env):
130132
utils_selinux.set_status("permissive")
131133
try:
132134
unattended_install.run(test, params, env)
133-
except error.CmdError, detail:
135+
except process.CmdError, detail:
134136
raise error.TestFail("Guest install failed:%s" % detail)
135137
finally:
136138
if selinux_mode is not None:

‎libvirt/tests/src/virt_cmd/virt_xml_validate.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from autotest.client import os_dep, utils
66
from autotest.client.shared import error
77

8+
from avocado.utils import process
9+
810
from virttest import virsh
911
from virttest import data_dir
1012
from virttest.utils_test import libvirt
@@ -25,7 +27,7 @@ def check_info(s1, s2, errorstr="Values differ"):
2527
ss_info = virsh.snapshot_info(vm_name, snapshot_name)
2628
check_info(ss_info["Name"], snapshot_name, "Incorrect snapshot name")
2729
check_info(ss_info["Domain"], vm_name, "Incorrect domain name")
28-
except error.CmdError, e:
30+
except process.CmdError, e:
2931
error.TestFail(str(e))
3032
except error.TestFail, e:
3133
error.TestFail(str(e))
@@ -70,7 +72,7 @@ def storagepool_validate(pool_name, file=None, **virsh_dargs):
7072

7173
try:
7274
virsh.pool_dumpxml(pool_name, to_file=file)
73-
except error.CmdError, e:
75+
except process.CmdError, e:
7476
error.TestFail(str(e))
7577

7678

@@ -156,7 +158,7 @@ def secret_validate(file=None, **virsh_dargs):
156158
if uuid:
157159
try:
158160
virsh.secret_dumpxml(uuid, to_file=file, **virsh_dargs)
159-
except error.CmdError, e:
161+
except process.CmdError, e:
160162
raise error.TestError(str(e))
161163

162164

@@ -177,7 +179,7 @@ def interface_validate(file=None, **virsh_dargs):
177179

178180
try:
179181
virsh.iface_dumpxml(iface_name, to_file=file, **virsh_dargs)
180-
except error.CmdError, e:
182+
except process.CmdError, e:
181183
raise error.TestError(str(e))
182184

183185

‎libvirt/tests/src/virtual_disks/at_dt_iscsi_disk.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from autotest.client.shared import error
99

10+
from avocado.utils import process
11+
1012
from virttest import virsh
1113
from virttest.remote import LoginError
1214
from virttest.virt_vm import VMError
@@ -195,12 +197,12 @@ def run(test, params, env):
195197

196198
try:
197199
virsh.snapshot_list(vm_name, **virsh_dargs)
198-
except error.CmdError:
200+
except process.CmdError:
199201
error.TestFail("Failed getting snapshots list for %s", vm_name)
200202

201203
try:
202204
virsh.snapshot_info(vm_name, snapshot_name1, **virsh_dargs)
203-
except error.CmdError:
205+
except process.CmdError:
204206
error.TestFail("Failed getting snapshots info for %s", vm_name)
205207

206208
cmd_result = virsh.snapshot_dumpxml(vm_name, snapshot_name1,

0 commit comments

Comments
 (0)
Please sign in to comment.