You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2022/07/09 16:22:56 UTC

[cloudstack] branch main updated: api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 65b0bcb069 api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540)
65b0bcb069 is described below

commit 65b0bcb06966ddb03f99b129ecbdeb66fbe95b54
Author: Harikrishna <ha...@gmail.com>
AuthorDate: Sat Jul 9 21:52:51 2022 +0530

    api: Deprecated changeServiceForVirtualMachine API and replaced all the occurences in the tests with scaleVirtualMachine (#6540)
---
 .../cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java |  2 +-
 .../api/command/admin/vm/UpgradeVMCmdByAdmin.java          |  9 +++++----
 .../apache/cloudstack/api/command/user/vm/ScaleVMCmd.java  |  2 +-
 .../cloudstack/api/command/user/vm/UpgradeVMCmd.java       |  5 +++--
 test/integration/component/test_deploy_vgpu_vm.py          | 14 +++++++-------
 test/integration/smoke/test_service_offerings.py           | 14 +++++++-------
 .../sandbox/demo/simulator/testcase/test_vm_life_cycle.py  |  4 ++--
 7 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java
index 144663f3ef..fd71a44595 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java
@@ -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 {}
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java
index 9db9907830..f3230e6481 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java
@@ -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 {}
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
index 193a3b1c05..63226ca7f0 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
@@ -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());
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
index 13185d34c5..c74bac6f87 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
@@ -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 {
diff --git a/test/integration/component/test_deploy_vgpu_vm.py b/test/integration/component/test_deploy_vgpu_vm.py
index 2c1f124e8e..fb99e877a5 100644
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@ -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)
diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py
index f266616a60..039b032b3a 100644
--- a/test/integration/smoke/test_service_offerings.py
+++ b/test/integration/smoke/test_service_offerings.py
@@ -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,
diff --git a/tools/marvin/marvin/sandbox/demo/simulator/testcase/test_vm_life_cycle.py b/tools/marvin/marvin/sandbox/demo/simulator/testcase/test_vm_life_cycle.py
index c05eda1d14..28c4c3513a 100644
--- a/tools/marvin/marvin/sandbox/demo/simulator/testcase/test_vm_life_cycle.py
+++ b/tools/marvin/marvin/sandbox/demo/simulator/testcase/test_vm_life_cycle.py
@@ -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)