api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540)

This commit is contained in:
Harikrishna 2022-07-09 21:52:51 +05:30 committed by GitHub
parent 0cae4406fb
commit 65b0bcb069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 24 deletions

View File

@ -25,6 +25,6 @@ import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.vm.VirtualMachine;
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering. This command also takes into account the Volume and it may resize the root disk size according to the service offering.", responseObject = SuccessResponse.class, responseView = ResponseView.Full, entityType = {VirtualMachine.class},
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering. This command also considers the volume size in the service offering or disk offering linked to the new service offering and apply all characteristics to the root volume.", responseObject = SuccessResponse.class, responseView = ResponseView.Full, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ScaleVMCmdByAdmin extends ScaleVMCmd implements AdminCmd {}

View File

@ -24,9 +24,10 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import com.cloud.vm.VirtualMachine;
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " +
"The virtual machine must be in a \"Stopped\" state for " +
"this command to take effect. Note that it only changes the VM's compute offering and it does not update the root volume offering. "
+ "If the Service Offering has a root disk size the volume will be resized only if using API command 'scaleVirtualMachine'.", responseView = ResponseView.Full, entityType = {VirtualMachine.class},
@Deprecated(since = "4.18")
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="(This API is deprecated, use scaleVirtualMachine API)" +
"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for " +
"this command to take effect.",
responseView = ResponseView.Full, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class UpgradeVMCmdByAdmin extends UpgradeVMCmd implements AdminCmd {}

View File

@ -49,7 +49,7 @@ import com.cloud.uservm.UserVm;
import com.cloud.vm.VirtualMachine;
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering. This command also considers the volume size in the service offering or disk offering linked to the new service offering and apply all characteristics to the root volume.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ScaleVMCmd extends BaseAsyncCmd implements UserCmd {
public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());

View File

@ -44,8 +44,9 @@ import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.VirtualMachine;
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " +
"The virtual machine must be in a \"Stopped\" state for " +
@Deprecated(since = "4.18")
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="(This API is deprecated, use scaleVirtualMachine API)" +
"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for " +
"this command to take effect.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class UpgradeVMCmd extends BaseCmd implements UserCmd {

View File

@ -20,7 +20,7 @@
# All tests inherit from cloudstackTestCase
from marvin.cloudstackTestCase import cloudstackTestCase
import unittest
from marvin.cloudstackAPI import changeServiceForVirtualMachine, startVirtualMachine
from marvin.cloudstackAPI import scaleVirtualMachine, startVirtualMachine
# Import Integration Libraries
@ -594,10 +594,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
self.destvgpuoffering = self.vgpu_serviceoffering_creation(
desttype,
destmodel)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = vm.id
cmd.serviceofferingid = self.destvgpuoffering.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Starting VM - ID: %s" % vm.id)
self.start_vm()
@ -644,10 +644,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
self.destvgpuoffering = self.vgpu_serviceoffering_creation(
desttype,
destmodel)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = vm.id
cmd.serviceofferingid = self.destvgpuoffering.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Starting VM - ID: %s" % vm.id)
self.start_vm()
@ -1367,10 +1367,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
desttype,
destmodel)
self.stop_life_cycle_vm(vmcard)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = vmcard.id
cmd.serviceofferingid = self.destvgpuoffering.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Starting VM - ID: %s" % vmcard.id)
self.start_life_cycle_vm(vmcard)

View File

@ -19,7 +19,7 @@
# Import Local Modules
from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import (changeServiceForVirtualMachine,
from marvin.cloudstackAPI import (scaleVirtualMachine,
updateServiceOffering)
from marvin.lib.utils import (isAlmostEqual,
cleanup_resources,
@ -546,10 +546,10 @@ class TestServiceOfferings(cloudstackTestCase):
except Exception as e:
self.fail("Failed to stop VM: %s" % e)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = self.medium_virtual_machine.id
cmd.serviceofferingid = self.small_offering.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Starting VM - ID: %s" % self.medium_virtual_machine.id)
self.medium_virtual_machine.start(self.apiclient)
@ -695,12 +695,12 @@ class TestServiceOfferings(cloudstackTestCase):
offering_data,
)
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessTrue2)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = self.virtual_machine_with_diskoffering_strictness_true.id
cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessTrue2.id
with self.assertRaises(Exception) as e:
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Upgrade VM with new service offering having different disk offering operation failed as expected with exception: %s" %
e.exception)
return
@ -800,10 +800,10 @@ class TestServiceOfferings(cloudstackTestCase):
offering_data,
)
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessFalse2)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = self.virtual_machine_with_diskoffering_strictness_false.id
cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessFalse2.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
list_vm_response = VirtualMachine.list(
self.apiclient,

View File

@ -414,10 +414,10 @@ class TestVMLifeCycle(cloudstackTestCase):
self.debug("Change Service offering VM - ID: %s" %
self.medium_virtual_machine.id)
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
cmd.id = self.medium_virtual_machine.id
cmd.serviceofferingid = self.small_offering.id
self.apiclient.changeServiceForVirtualMachine(cmd)
self.apiclient.scaleVirtualMachine(cmd)
self.debug("Starting VM - ID: %s" % self.medium_virtual_machine.id)
self.medium_virtual_machine.start(self.apiclient)