Skip to content

Commit 65b0bcb

Browse files
api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540)
1 parent 0cae440 commit 65b0bcb

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
import com.cloud.vm.VirtualMachine;
2626

2727

28-
@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},
28+
@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},
2929
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
3030
public class ScaleVMCmdByAdmin extends ScaleVMCmd implements AdminCmd {}

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
import com.cloud.vm.VirtualMachine;
2626

27-
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " +
28-
"The virtual machine must be in a \"Stopped\" state for " +
29-
"this command to take effect. Note that it only changes the VM's compute offering and it does not update the root volume offering. "
30-
+ "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},
27+
@Deprecated(since = "4.18")
28+
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="(This API is deprecated, use scaleVirtualMachine API)" +
29+
"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for " +
30+
"this command to take effect.",
31+
responseView = ResponseView.Full, entityType = {VirtualMachine.class},
3132
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
3233
public class UpgradeVMCmdByAdmin extends UpgradeVMCmd implements AdminCmd {}

api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import com.cloud.vm.VirtualMachine;
5050

5151

52-
@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
52+
@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},
5353
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
5454
public class ScaleVMCmd extends BaseAsyncCmd implements UserCmd {
5555
public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());

api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
import com.cloud.uservm.UserVm;
4545
import com.cloud.vm.VirtualMachine;
4646

47-
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " +
48-
"The virtual machine must be in a \"Stopped\" state for " +
47+
@Deprecated(since = "4.18")
48+
@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="(This API is deprecated, use scaleVirtualMachine API)" +
49+
"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for " +
4950
"this command to take effect.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
5051
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
5152
public class UpgradeVMCmd extends BaseCmd implements UserCmd {

test/integration/component/test_deploy_vgpu_vm.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# All tests inherit from cloudstackTestCase
2121
from marvin.cloudstackTestCase import cloudstackTestCase
2222
import unittest
23-
from marvin.cloudstackAPI import changeServiceForVirtualMachine, startVirtualMachine
23+
from marvin.cloudstackAPI import scaleVirtualMachine, startVirtualMachine
2424

2525
# Import Integration Libraries
2626

@@ -594,10 +594,10 @@ def serviceoffering_upgrade(
594594
self.destvgpuoffering = self.vgpu_serviceoffering_creation(
595595
desttype,
596596
destmodel)
597-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
597+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
598598
cmd.id = vm.id
599599
cmd.serviceofferingid = self.destvgpuoffering.id
600-
self.apiclient.changeServiceForVirtualMachine(cmd)
600+
self.apiclient.scaleVirtualMachine(cmd)
601601

602602
self.debug("Starting VM - ID: %s" % vm.id)
603603
self.start_vm()
@@ -644,10 +644,10 @@ def vm_snapshot_serviceoffering_upgrade(
644644
self.destvgpuoffering = self.vgpu_serviceoffering_creation(
645645
desttype,
646646
destmodel)
647-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
647+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
648648
cmd.id = vm.id
649649
cmd.serviceofferingid = self.destvgpuoffering.id
650-
self.apiclient.changeServiceForVirtualMachine(cmd)
650+
self.apiclient.scaleVirtualMachine(cmd)
651651

652652
self.debug("Starting VM - ID: %s" % vm.id)
653653
self.start_vm()
@@ -1367,10 +1367,10 @@ def vm_snapshot_vgpu(
13671367
desttype,
13681368
destmodel)
13691369
self.stop_life_cycle_vm(vmcard)
1370-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
1370+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
13711371
cmd.id = vmcard.id
13721372
cmd.serviceofferingid = self.destvgpuoffering.id
1373-
self.apiclient.changeServiceForVirtualMachine(cmd)
1373+
self.apiclient.scaleVirtualMachine(cmd)
13741374

13751375
self.debug("Starting VM - ID: %s" % vmcard.id)
13761376
self.start_life_cycle_vm(vmcard)

test/integration/smoke/test_service_offerings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Import Local Modules
2020
from marvin.codes import FAILED
2121
from marvin.cloudstackTestCase import cloudstackTestCase
22-
from marvin.cloudstackAPI import (changeServiceForVirtualMachine,
22+
from marvin.cloudstackAPI import (scaleVirtualMachine,
2323
updateServiceOffering)
2424
from marvin.lib.utils import (isAlmostEqual,
2525
cleanup_resources,
@@ -546,10 +546,10 @@ def test_04_change_offering_small(self):
546546
except Exception as e:
547547
self.fail("Failed to stop VM: %s" % e)
548548

549-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
549+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
550550
cmd.id = self.medium_virtual_machine.id
551551
cmd.serviceofferingid = self.small_offering.id
552-
self.apiclient.changeServiceForVirtualMachine(cmd)
552+
self.apiclient.scaleVirtualMachine(cmd)
553553

554554
self.debug("Starting VM - ID: %s" % self.medium_virtual_machine.id)
555555
self.medium_virtual_machine.start(self.apiclient)
@@ -695,12 +695,12 @@ def test_05_disk_offering_strictness_true(self):
695695
offering_data,
696696
)
697697
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessTrue2)
698-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
698+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
699699
cmd.id = self.virtual_machine_with_diskoffering_strictness_true.id
700700
cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessTrue2.id
701701

702702
with self.assertRaises(Exception) as e:
703-
self.apiclient.changeServiceForVirtualMachine(cmd)
703+
self.apiclient.scaleVirtualMachine(cmd)
704704
self.debug("Upgrade VM with new service offering having different disk offering operation failed as expected with exception: %s" %
705705
e.exception)
706706
return
@@ -800,10 +800,10 @@ def test_06_disk_offering_strictness_false(self):
800800
offering_data,
801801
)
802802
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessFalse2)
803-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
803+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
804804
cmd.id = self.virtual_machine_with_diskoffering_strictness_false.id
805805
cmd.serviceofferingid = self.serviceOfferingWithDiskOfferingStrictnessFalse2.id
806-
self.apiclient.changeServiceForVirtualMachine(cmd)
806+
self.apiclient.scaleVirtualMachine(cmd)
807807

808808
list_vm_response = VirtualMachine.list(
809809
self.apiclient,

tools/marvin/marvin/sandbox/demo/simulator/testcase/test_vm_life_cycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ def test_04_change_offering_small(self):
414414
self.debug("Change Service offering VM - ID: %s" %
415415
self.medium_virtual_machine.id)
416416

417-
cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
417+
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
418418
cmd.id = self.medium_virtual_machine.id
419419
cmd.serviceofferingid = self.small_offering.id
420-
self.apiclient.changeServiceForVirtualMachine(cmd)
420+
self.apiclient.scaleVirtualMachine(cmd)
421421

422422
self.debug("Starting VM - ID: %s" % self.medium_virtual_machine.id)
423423
self.medium_virtual_machine.start(self.apiclient)

0 commit comments

Comments
 (0)