30
31
xmldir = "tests/cli-test-xml"
31
treedir = "tests/cli-test-xml/faketree"
32
ro_img = "cli_exist3ro.img"
32
treedir = "%s/faketree" % xmldir
33
vcdir = "%s/virtconv" % xmldir
34
ro_dir = "clitest_rodir"
35
ro_img = "%s/cli_exist3ro.img" % ro_dir
36
ro_noexist_img = "%s/idontexist.img" % ro_dir
37
virtconv_out = "virtconv-outdir"
34
39
# Images that will be created by virt-install/virt-clone, and removed before
45
50
# Images created by virt-image
46
51
virtimage_new = [os.path.join(xmldir, "cli_scratch.raw")]
53
# virt-convert output dirs
54
virtconv_dirs = [virtconv_out]
48
56
exist_files = exist_images + virtimage_exist
49
new_files = new_images + virtimage_new
50
clean_files = new_images + exist_images + virtimage_exist + virtimage_new
57
new_files = new_images + virtimage_new + virtconv_dirs
58
clean_files = (new_images + exist_images +
59
virtimage_exist + virtimage_new + virtconv_dirs + [ro_dir])
53
62
'TESTURI' : testuri,
54
63
'REMOTEURI' : remoteuri,
55
64
'CLONE_DISK_XML' : "%s/clone-disk.xml" % xmldir,
56
65
'CLONE_STORAGE_XML' : "%s/clone-disk-managed.xml" % xmldir,
66
'CLONE_NOEXIST_XML' : "%s/clone-disk-noexist.xml" % xmldir,
57
67
'IMAGE_XML' : "%s/image.xml" % xmldir,
58
68
'NEWIMG1' : new_images[0],
59
69
'NEWIMG2' : new_images[1],
61
71
'EXISTIMG1' : exist_images[0],
62
72
'EXISTIMG2' : exist_images[1],
74
'ROIMGNOEXIST' : ro_noexist_img,
64
75
'POOL' : "default-pool",
65
76
'VOL' : "testvol1.img",
66
78
'MANAGEDEXIST1' : "/default-pool/testvol1.img",
67
79
'MANAGEDEXIST2' : "/default-pool/testvol2.img",
68
80
'MANAGEDNEW1' : "/default-pool/clonevol",
69
81
'MANAGEDNEW2' : "/default-pool/clonevol",
70
82
'MANAGEDDISKNEW1' : "/disk-pool/newvol1.img",
83
'COLLIDE' : "/default-pool/collidevol1.img",
84
'SHARE' : "/default-pool/sharevol.img",
86
'VIRTCONV_OUT' : "%s/test.out" % virtconv_out,
87
'VC_IMG1' : "%s/virtimage/test1.virt-image" % vcdir,
88
'VMX_IMG1' : "%s/vmx/test1.vmx" % vcdir,
150
168
"--disk %(EXISTIMG1)s",
151
169
# Not specifying path= but creating storage
152
170
"--disk %(NEWIMG1)s,format=raw,size=.0000001",
171
# Colliding storage with --force
172
"--disk %(COLLIDE)s --force",
173
# Colliding shareable storage
174
"--disk %(SHARE)s,perms=sh",
176
"--disk path=%(EXISTIMG1)s,device=cdrom --disk path=%(EXISTIMG1)s,device=cdrom",
177
# Dir with a floppy dev
178
"--disk %(DIR)s,device=floppy",
161
187
"--file %(NEWIMG1)s",
163
189
"--file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s --file %(EXISTIMG1)s",
165
"--disk path=%(EXISTIMG1)s,device=cdrom --disk path=%(EXISTIMG1)s,device=cdrom",
167
191
"--file-size .0001",
168
192
# Specify a nonexistent pool
181
205
"--disk path=%(MANAGEDDISKNEW1)s,format=raw,size=.0000001",
182
206
# Not specifying path= and non existent storage w/ no size
183
207
"--disk %(NEWIMG1)s",
208
# Colliding storage without --force
209
"--disk %(COLLIDE)s",
211
"--disk %(DIR)s,device=cdrom",
185
213
}, # category "storage"
199
227
# Explicity fullvirt + arch
200
228
"--arch i686 --pxe",
201
229
# Convert i*86 -> i686
202
#"--arch i486 --pxe",
203
231
# Directory tree URL install
204
232
"--hvm --location %s" % treedir,
233
# Directory tree URL install with extra-args
234
"--hvm --location %s --extra-args console=ttyS0" % treedir,
205
235
# Directory tree CDROM install
206
236
"--hvm --cdrom %s" % treedir,
207
237
# Paravirt location
324
354
"--hvm --import --disk path=virt-install",
325
355
# PV Import install
326
356
"--paravirt --import --disk path=virt-install",
358
"--hvm --nodisks --pxe --autostart",
360
"--hvm --nodisks --pxe --description \"foobar & baz\"",
361
# HVM windows install with disk
362
"--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0",
363
# --watchdog dev default
364
"--hvm --nodisks --pxe --watchdog default",
366
"--hvm --nodisks --pxe --watchdog ib700,action=pause",
368
"--hvm --nodisks --pxe --sound",
370
"--hvm --nodisks --pxe --soundhw default --soundhw ac97",
372
"--hvm --nodisks --pxe --security type=dynamic",
373
# --security implicit static
374
"--hvm --nodisks --pxe --security label=foobar.label",
330
378
# pxe and nonetworks
331
379
"--nodisks --pxe --nonetworks",
381
"--nodisks --pxe --name test",
383
"--hvm --nodisks --pxe --watchdog default,action=foobar",
385
"--hvm --nodisks --pxe --soundhw default --soundhw foobar",
387
"--hvm --nodisks --pxe --security type=foobar",
333
389
}, # category "misc"
340
"--mac 11:22:33:44:55:66",
396
"--mac 11:22:33:44:55:AF",
341
397
# user networking
342
398
"--network=user",
343
399
# Old bridge option
344
400
"--bridge mybr0",
345
401
# Old bridge w/ mac
346
"--bridge mybr0 --mac 11:22:33:44:55:66",
402
"--bridge mybr0 --mac 11:22:33:44:55:AF",
347
403
# --network bridge:
348
404
"--network bridge:mybr0,model=e1000",
349
405
# VirtualNetwork with a random macaddr
356
412
"--network=user,model=e1000",
357
413
# several networks
358
"--network=network:default,model=e1000 --network=user,model=virtio,mac=11:22:33:44:55:66",
414
"--network=network:default,model=e1000 --network=user,model=virtio,mac=11:22:33:44:55:AF",
361
417
# Nonexistent network
364
420
"--network=network:default --mac 1234",
365
421
# More mac addrs than nics
366
"--network user --mac 00:11:22:33:44:55 --mac 00:11:22:33:44:66",
422
"--network user --mac 00:11:22:33:44:EF --mac 00:11:22:33:44:AB",
367
423
# Mixing bridge and network
368
424
"--network user --bridge foo0",
426
"--mac 11:22:33:44:55:66",
371
429
}, # category "network"
432
"hostdev_args": "--noautoconsole --nographics --nodisks --pxe",
435
# Host dev by libvirt name
436
"--host-device usb_device_781_5151_2004453082054CA1BEEE",
437
# Many hostdev parsing types
438
"--host-device 001.003 --host-device 15:0.1 --host-device 2:15:0.2 --host-device 0:15:0.3 --host-device 0x0781:0x5151 --host-device 1d6b:2",
442
# Unsupported hostdev type
443
"--host-device pci_8086_2850_scsi_host_scsi_host",
445
"--host-device foobarhostdev",
446
# Parseable hostdev, but unknown digits
447
"--host-device 300:400",
449
}, # category "hostdev"
374
452
"remote_args": "--connect %(REMOTEURI)s --nographics --noautoconsole",
423
501
# XML w/ managed storage, specify managed path
424
502
"--original-xml %(CLONE_STORAGE_XML)s --file %(MANAGEDNEW1)s",
425
503
# XML w/ managed storage, specify managed path across pools
426
#"--original-xml %(CLONE_STORAGE_XML)s --file /cross-pool/clonevol",
504
"--original-xml %(CLONE_STORAGE_XML)s --file /cross-pool/clonevol",
505
# XML w/ non-existent storage, with --preserve
506
"--original-xml %(CLONE_NOEXIST_XML)s --file %(EXISTIMG1)s --preserve",
441
521
"--original-xml %(CLONE_DISK_XML)s --file %(NEWIMG1)s --file %(NEWIMG2)s --force-copy=hdc",
442
522
# XML w/ managed storage, specify unmanaged path (should fail)
443
523
"--original-xml %(CLONE_STORAGE_XML)s --file /tmp/clonevol",
524
# XML w/ non-existent storage, WITHOUT --preserve
525
"--original-xml %(CLONE_NOEXIST_XML)s --file %(EXISTIMG1)s",
526
# XML w/ managed storage, specify RO image without preserve
527
"--original-xml %(CLONE_DISK_XML)s --file %(ROIMG)s --file %(ROIMG)s --force",
528
# XML w/ managed storage, specify RO non existent
529
"--original-xml %(CLONE_DISK_XML)s --file %(ROIMG)s --file %(ROIMGNOEXIST)s --force",
445
531
}, # category "general"
560
651
}, # category "network"
561
"prompt" : [ " --connect %(TESTURI) %(IMAGE_XML)s --debug --prompt" ],
652
"prompt" : [ " --connect %(TESTURI)s %(IMAGE_XML)s --debug --prompt" ],
654
}, # app 'virt-image'
658
"global_args" : "--debug",
664
# virt-image to default (virt-image) w/ no convert
665
"%(VC_IMG1)s -D none %(VIRTCONV_OUT)s",
666
# virt-image to virt-image w/ no convert
667
"%(VC_IMG1)s -o virt-image -D none %(VIRTCONV_OUT)s",
668
# virt-image to vmx w/ no convert
669
"%(VC_IMG1)s -o vmx -D none %(VIRTCONV_OUT)s",
670
# virt-image to vmx w/ raw
671
"%(VC_IMG1)s -o vmx -D raw %(VIRTCONV_OUT)s",
672
# virt-image to vmx w/ vmdk
673
"%(VC_IMG1)s -o vmx -D vmdk %(VIRTCONV_OUT)s",
674
# virt-image to vmx w/ qcow2
675
"%(VC_IMG1)s -o vmx -D qcow2 %(VIRTCONV_OUT)s",
676
# vmx to vmx no convert
677
"%(VMX_IMG1)s -o vmx -D none %(VIRTCONV_OUT)s",
681
# virt-image to virt-image with invalid format
682
"%(VC_IMG1)s -o virt-image -D foobarfmt %(VIRTCONV_OUT)s",
683
# virt-image to ovf (has no output formatter)
684
"%(VC_IMG1)s -o ovf %(VIRTCONV_OUT)s",
689
}, # app 'virt-conver'
566
692
def runcomm(comm):
601
727
"Output was:\n%s" % ret[1])
603
729
# Setup: build cliarg dict, which uses
730
def run_tests(do_app):
731
if do_app and do_app not in args_dict.keys():
732
raise ValueError("Unknown app '%s'" % do_app)
605
734
for app in args_dict:
735
if do_app and app != do_app:
647
779
global testprompt
649
783
if len(sys.argv) > 1:
650
784
for i in range(1, len(sys.argv)):
651
785
if sys.argv[i].count("debug"):
653
787
elif sys.argv[i].count("prompt"):
654
788
testprompt = True
789
elif sys.argv[i].count("--app"):
790
do_app = sys.argv[i+1]
656
792
# Setup needed files
657
793
for i in exist_files:
658
794
if os.path.exists(i):
659
795
raise ValueError("'%s' will be used by testsuite, can not already"
798
os.system("mkdir %s" % ro_dir)
661
800
for i in exist_files:
662
801
os.system("touch %s" % i)
664
803
# Set ro_img to readonly
665
804
os.system("chmod 444 %s" % ro_img)
805
os.system("chmod 555 %s" % ro_dir)
671
for i in clean_files:
672
os.system("rm -f %s > /dev/null 2>&1" % i)
814
for i in clean_files:
815
os.system("chmod 777 %s > /dev/null 2>&1" % i)
816
os.system("rm -rf %s > /dev/null 2>&1" % i)
674
818
if __name__ == "__main__":