Remove condition that are prevent resizing for root volumes (vmware) (#5186)

* remove condition that are prevent resizing for root volumes

* adjust tests acordingly

* enable disk resize tests for VMware

Co-authored-by: DK101010 <dirk.klahre@itelligence.de>
Co-authored-by: mib1185 <mail@mib85.de>
This commit is contained in:
DK101010 2021-07-22 03:33:51 +02:00 committed by GitHub
parent eff2da2518
commit c23cbdff8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 27 deletions

View File

@ -1159,10 +1159,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
UserVmVO userVm = _userVmDao.findById(volume.getInstanceId());
if (userVm != null) {
if (volume.getVolumeType().equals(Volume.Type.ROOT) && userVm.getPowerState() != VirtualMachine.PowerState.PowerOff && hypervisorType == HypervisorType.VMware) {
s_logger.error(" For ROOT volume resize VM should be in Power Off state.");
throw new InvalidParameterValueException("VM current state is : " + userVm.getPowerState() + ". But VM should be in " + VirtualMachine.PowerState.PowerOff + " state.");
}
// serialize VM operation
AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();

View File

@ -228,16 +228,14 @@ class TestResizeVolume(cloudstackTestCase):
listall='True'
)
rootvolume = list_volume_response[0]
if vm.state == "Running" and \
(vm.hypervisor.lower() == "xenserver" or \
vm.hypervisor.lower() == "vmware"):
if vm.state == "Running" and vm.hypervisor.lower() == "xenserver":
self.virtual_machine.stop(apiclient)
time.sleep(self.services["sleep"])
if vm.hypervisor.lower() == "vmware":
rootdiskcontroller = self.getDiskController(vm)
if rootdiskcontroller!="scsi":
raise Exception("root volume resize only supported on scsi disk ,"
"please check rootdiskcontroller type")
if vm.hypervisor.lower() == "vmware":
rootdiskcontroller = self.getDiskController(vm)
if rootdiskcontroller!="scsi":
raise Exception("root volume resize only supported on scsi disk ,"
"please check rootdiskcontroller type")
rootvolobj = Volume(rootvolume.__dict__)
newsize = (rootvolume.size >> 30) + 2
@ -245,8 +243,7 @@ class TestResizeVolume(cloudstackTestCase):
if rootvolume is not None:
try:
rootvolobj.resize(apiclient, size=newsize)
if vm.hypervisor.lower() == "xenserver" or \
vm.hypervisor.lower() == "vmware":
if vm.hypervisor.lower() == "xenserver":
self.virtual_machine.start(apiclient)
time.sleep(self.services["sleep"])
ssh = SshClient(self.virtual_machine.ssh_ip, 22,
@ -916,9 +913,7 @@ class TestResizeVolume(cloudstackTestCase):
)
res = validateList(list_volume_response)
self.assertNotEqual(res[2], INVALID_INPUT, "listVolumes returned invalid object in response")
if vm.state == "Running" and (
vm.hypervisor.lower() == "xenserver" or
vm.hypervisor.lower() == "vmware"):
if vm.state == "Running" and vm.hypervisor.lower() == "xenserver":
self.virtual_machine.stop(self.apiclient)
time.sleep(self.services["sleep"])
@ -998,9 +993,7 @@ class TestResizeVolume(cloudstackTestCase):
)
res = validateList(list_volume_response)
self.assertNotEqual(res[2], INVALID_INPUT, "listVolumes returned invalid object in response")
if vm.state == "Running" and (
vm.hypervisor.lower() == "xenserver" or
vm.hypervisor.lower() == "vmware"):
if vm.state == "Running" and vm.hypervisor.lower() == "xenserver":
self.virtual_machine.stop(self.apiclient)
time.sleep(self.services["sleep"])
rootvolume = list_volume_response[0]
@ -1115,9 +1108,7 @@ class TestResizeVolume(cloudstackTestCase):
)
res = validateList(list_volume_response)
self.assertNotEqual(res[2], INVALID_INPUT, "listVolumes returned invalid object in response")
if vm.state == "Running" and \
(vm.hypervisor.lower() == "xenserver" or
vm.hypervisor.lower() == "vmware"):
if vm.state == "Running" and vm.hypervisor.lower() == "xenserver":
self.virtual_machine.stop(self.apiclient)
time.sleep(self.services["sleep"])
rootvolume = list_volume_response[0]

View File

@ -627,8 +627,8 @@ class TestVolumes(cloudstackTestCase):
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() in ("vmware", "hyperv"):
self.skipTest("Resize Volume is unsupported on VmWare and Hyper-V")
elif hosts[0].hypervisor.lower() == "hyperv":
self.skipTest("Resize Volume is unsupported on Hyper-V")
# Attempting to resize it should throw an exception, as we're using a non
# customisable disk offering, therefore our size parameter should be ignored
@ -659,8 +659,8 @@ class TestVolumes(cloudstackTestCase):
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() in ("vmware", "hyperv"):
self.skipTest("Resize Volume is unsupported on VmWare and Hyper-V")
elif hosts[0].hypervisor.lower() == "hyperv":
self.skipTest("Resize Volume is unsupported on Hyper-V")
# resize the data disk
self.debug("Resize Volume ID: %s" % self.volume.id)