|
30 | 30 | Account, |
31 | 31 | Volume, |
32 | 32 | Host, |
33 | | - DiskOffering) |
| 33 | + DiskOffering, |
| 34 | + StoragePool) |
34 | 35 | from marvin.lib.common import (get_domain, |
35 | 36 | get_zone, |
36 | 37 | get_template) |
@@ -660,41 +661,55 @@ def test_08_resize_volume(self): |
660 | 661 | "Check if the data volume resized appropriately" |
661 | 662 | ) |
662 | 663 |
|
663 | | - self.services["disk_offering"]["disksize"] = 10 |
664 | | - disk_offering_10_GB = DiskOffering.create( |
665 | | - self.apiclient, |
666 | | - self.services["disk_offering"] |
667 | | - ) |
668 | | - self.cleanup.append(disk_offering_10_GB) |
| 664 | + can_shrink = False |
669 | 665 |
|
670 | | - cmd = resizeVolume.resizeVolumeCmd() |
671 | | - cmd.id = self.volume.id |
672 | | - cmd.diskofferingid = disk_offering_10_GB.id |
673 | | - cmd.shrinkok = "true" |
| 666 | + list_volume_response = Volume.list( |
| 667 | + self.apiClient, |
| 668 | + id=self.volume.id, |
| 669 | + type='DATADISK' |
| 670 | + ) |
| 671 | + storage_pool_id = [x.storageid for x in list_volume_response if x.id == self.volume.id][0] |
| 672 | + storage = StoragePool.list(self.apiclient, id=storage_pool_id)[0] |
| 673 | + # At present only CLVM supports shrinking volumes |
| 674 | + if storage.type.lower() == "clvm": |
| 675 | + can_shrink = True |
| 676 | + |
| 677 | + if can_shrink: |
| 678 | + self.services["disk_offering"]["disksize"] = 10 |
| 679 | + disk_offering_10_GB = DiskOffering.create( |
| 680 | + self.apiclient, |
| 681 | + self.services["disk_offering"] |
| 682 | + ) |
| 683 | + self.cleanup.append(disk_offering_10_GB) |
674 | 684 |
|
675 | | - self.apiClient.resizeVolume(cmd) |
| 685 | + cmd = resizeVolume.resizeVolumeCmd() |
| 686 | + cmd.id = self.volume.id |
| 687 | + cmd.diskofferingid = disk_offering_10_GB.id |
| 688 | + cmd.shrinkok = "true" |
676 | 689 |
|
677 | | - count = 0 |
678 | | - success = False |
679 | | - while count < 3: |
680 | | - list_volume_response = Volume.list( |
681 | | - self.apiClient, |
682 | | - id=self.volume.id |
683 | | - ) |
684 | | - for vol in list_volume_response: |
685 | | - if vol.id == self.volume.id and int(vol.size) == (int(disk_offering_10_GB.disksize) * (1024 ** 3)) and vol.state == 'Ready': |
686 | | - success = True |
687 | | - if success: |
688 | | - break |
689 | | - else: |
690 | | - time.sleep(10) |
691 | | - count += 1 |
| 690 | + self.apiClient.resizeVolume(cmd) |
692 | 691 |
|
693 | | - self.assertEqual( |
694 | | - success, |
695 | | - True, |
696 | | - "Check if the root volume resized appropriately" |
697 | | - ) |
| 692 | + count = 0 |
| 693 | + success = False |
| 694 | + while count < 3: |
| 695 | + list_volume_response = Volume.list( |
| 696 | + self.apiClient, |
| 697 | + id=self.volume.id |
| 698 | + ) |
| 699 | + for vol in list_volume_response: |
| 700 | + if vol.id == self.volume.id and int(vol.size) == (int(disk_offering_10_GB.disksize) * (1024 ** 3)) and vol.state == 'Ready': |
| 701 | + success = True |
| 702 | + if success: |
| 703 | + break |
| 704 | + else: |
| 705 | + time.sleep(10) |
| 706 | + count += 1 |
| 707 | + |
| 708 | + self.assertEqual( |
| 709 | + success, |
| 710 | + True, |
| 711 | + "Check if the root volume resized appropriately" |
| 712 | + ) |
698 | 713 |
|
699 | 714 | #start the vm if it is on xenserver |
700 | 715 |
|
|
0 commit comments