|
37 | 37 | get_zone, |
38 | 38 | get_template, |
39 | 39 | find_storage_pool_type, |
40 | | - get_pod) |
| 40 | + get_pod, |
| 41 | + list_disk_offering) |
41 | 42 | from marvin.lib.utils import checkVolumeSize |
42 | 43 | from marvin.codes import SUCCESS, FAILED, XEN_SERVER |
43 | 44 | from nose.plugins.attrib import attr |
@@ -875,3 +876,77 @@ def checkVolumeResponse(): |
875 | 876 | if not res: |
876 | 877 | self.fail("Failed to return root volume response") |
877 | 878 | return response |
| 879 | + |
| 880 | + |
| 881 | + @attr(tags=["advanced", "advancedns", "smoke", "basic"], required_hardware="true") |
| 882 | + def test_11_migrate_volume_and_change_offering(self): |
| 883 | + |
| 884 | + # Validates the following |
| 885 | + # |
| 886 | + # 1. Creates a new Volume with a small disk offering |
| 887 | + # |
| 888 | + # 2. Migrates the Volume to another primary storage and changes the offering |
| 889 | + # |
| 890 | + # 3. Verifies the Volume has new offering when migrated to the new storage. |
| 891 | + |
| 892 | + small_offering = list_disk_offering( |
| 893 | + self.apiclient, |
| 894 | + name = "Small" |
| 895 | + )[0] |
| 896 | + |
| 897 | + large_offering = list_disk_offering( |
| 898 | + self.apiclient, |
| 899 | + name = "Large" |
| 900 | + )[0] |
| 901 | + volume = Volume.create( |
| 902 | + self.apiClient, |
| 903 | + self.services, |
| 904 | + zoneid = self.zone.id, |
| 905 | + account = self.account.name, |
| 906 | + domainid = self.account.domainid, |
| 907 | + diskofferingid = small_offering.id |
| 908 | + ) |
| 909 | + self.debug("Created a small volume: %s" % volume.id) |
| 910 | + |
| 911 | + self.virtual_machine.attach_volume(self.apiclient, volume=volume) |
| 912 | + |
| 913 | + if self.virtual_machine.hypervisor == "KVM": |
| 914 | + self.virtual_machine.stop(self.apiclient) |
| 915 | + |
| 916 | + pools = StoragePool.listForMigration( |
| 917 | + self.apiclient, |
| 918 | + id=volume.id |
| 919 | + ) |
| 920 | + |
| 921 | + pool = None |
| 922 | + |
| 923 | + if pools and len(pools) > 0: |
| 924 | + pool = pools[0] |
| 925 | + else: |
| 926 | + raise self.skipTest("Not enough storage pools found, skipping test") |
| 927 | + |
| 928 | + self.debug("Migrating Volume-ID: %s to Pool: %s" % (volume.id, pool.id)) |
| 929 | + Volume.migrate( |
| 930 | + self.apiclient, |
| 931 | + volumeid = volume.id, |
| 932 | + storageid = pool.id, |
| 933 | + newdiskofferingid = large_offering.id |
| 934 | + ) |
| 935 | + |
| 936 | + if self.virtual_machine.hypervisor == "KVM": |
| 937 | + self.virtual_machine.start(self.apiclient |
| 938 | + ) |
| 939 | + |
| 940 | + migrated_vol = Volume.list( |
| 941 | + self.apiclient, |
| 942 | + id = volume.id |
| 943 | + )[0] |
| 944 | + |
| 945 | + self.assertEqual( |
| 946 | + migrated_vol.diskofferingname, |
| 947 | + large_offering.name, |
| 948 | + "Offering name did not match with the new one " |
| 949 | + ) |
| 950 | + |
| 951 | + return |
| 952 | + |
0 commit comments