Revision 090128b6 qa/qa_instance.py
b/qa/qa_instance.py | ||
---|---|---|
52 | 52 |
qa_config.get(constants.BE_MAXMEM))) |
53 | 53 |
|
54 | 54 |
if disk_template != constants.DT_DISKLESS: |
55 |
for idx, size in enumerate(qa_config.get("disk")): |
|
56 |
params.extend(["--disk", "%s:size=%s" % (idx, size)]) |
|
55 |
for idx, disk in enumerate(qa_config.GetDiskOptions()): |
|
56 |
size = disk.get("size") |
|
57 |
name = disk.get("name") |
|
58 |
params.extend(["--disk", "%s:size=%s,name=%s" % (idx, size, name)]) |
|
57 | 59 |
|
58 | 60 |
# Set static MAC address if configured |
59 | 61 |
if force_mac: |
... | ... | |
780 | 782 |
return |
781 | 783 |
|
782 | 784 |
name = instance.name |
783 |
all_size = qa_config.get("disk") |
|
784 |
all_grow = qa_config.get("disk-growth") |
|
785 |
disks = qa_config.GetDiskOptions() |
|
786 |
all_size = [d.get("size") for d in disks] |
|
787 |
all_grow = [d.get("growth") for d in disks] |
|
785 | 788 |
|
786 | 789 |
if not all_grow: |
787 | 790 |
# missing disk sizes but instance grow disk has been enabled, |
... | ... | |
801 | 804 |
str(int_size + 2 * int_grow)]) |
802 | 805 |
|
803 | 806 |
|
807 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) |
|
808 |
def TestInstanceDeviceNames(instance): |
|
809 |
if instance.disk_template == constants.DT_DISKLESS: |
|
810 |
print qa_utils.FormatInfo("Test not supported for diskless instances") |
|
811 |
return |
|
812 |
|
|
813 |
name = instance.name |
|
814 |
for dev_type in ["disk", "net"]: |
|
815 |
if dev_type == "disk": |
|
816 |
options = ",size=512M" |
|
817 |
else: |
|
818 |
options = "" |
|
819 |
# succeed in adding a device named 'test_device' |
|
820 |
AssertCommand(["gnt-instance", "modify", |
|
821 |
"--%s=-1:add,name=test_device%s" % (dev_type, options), |
|
822 |
name]) |
|
823 |
# succeed in removing the 'test_device' |
|
824 |
AssertCommand(["gnt-instance", "modify", |
|
825 |
"--%s=test_device:remove" % dev_type, |
|
826 |
name]) |
|
827 |
# fail to add two devices with the same name |
|
828 |
AssertCommand(["gnt-instance", "modify", |
|
829 |
"--%s=-1:add,name=test_device%s" % (dev_type, options), |
|
830 |
"--%s=-1:add,name=test_device%s" % (dev_type, options), |
|
831 |
name], fail=True) |
|
832 |
# fail to add a device with invalid name |
|
833 |
AssertCommand(["gnt-instance", "modify", |
|
834 |
"--%s=-1:add,name=2%s" % (dev_type, options), |
|
835 |
name], fail=True) |
|
836 |
# Rename disks |
|
837 |
disks = qa_config.GetDiskOptions() |
|
838 |
disk_names = [d.get("name") for d in disks] |
|
839 |
for idx, disk_name in enumerate(disk_names): |
|
840 |
# Refer to disk by idx |
|
841 |
AssertCommand(["gnt-instance", "modify", |
|
842 |
"--disk=%s:modify,name=renamed" % idx, |
|
843 |
name]) |
|
844 |
# Refer to by name and rename to original name |
|
845 |
AssertCommand(["gnt-instance", "modify", |
|
846 |
"--disk=renamed:modify,name=%s" % disk_name, |
|
847 |
name]) |
|
848 |
if len(disks) >= 2: |
|
849 |
# fail in renaming to disks to the same name |
|
850 |
AssertCommand(["gnt-instance", "modify", |
|
851 |
"--disk=0:modify,name=same_name", |
|
852 |
"--disk=1:modify,name=same_name", |
|
853 |
name], fail=True) |
|
854 |
|
|
855 |
|
|
804 | 856 |
def TestInstanceList(): |
805 | 857 |
"""gnt-instance list""" |
806 | 858 |
qa_utils.GenericQueryTest("gnt-instance", query.INSTANCE_FIELDS.keys()) |
Also available in: Unified diff