Skip to content

Commit 9b783d1

Browse files
johnmdilleySrikanteswaraRao Talluri
authored andcommitted
CLOUDSTACK-7228 Only shrink disk when CLVM is in use.
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
1 parent 396f29c commit 9b783d1

1 file changed

Lines changed: 47 additions & 32 deletions

File tree

test/integration/smoke/test_volumes.py

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
Account,
3131
Volume,
3232
Host,
33-
DiskOffering)
33+
DiskOffering,
34+
StoragePool)
3435
from marvin.lib.common import (get_domain,
3536
get_zone,
3637
get_template)
@@ -660,41 +661,55 @@ def test_08_resize_volume(self):
660661
"Check if the data volume resized appropriately"
661662
)
662663

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
669665

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)
674684

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"
676689

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)
692691

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+
)
698713

699714
#start the vm if it is on xenserver
700715

0 commit comments

Comments
 (0)