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

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


The following commit(s) were added to refs/heads/master by this push:
     new d1090c0  server: fix for inactive service offering for VM (#3320)
d1090c0 is described below

commit d1090c0577b7389fb52406a416c93a90b5abb13d
Author: Abhishek Kumar <[email protected]>
AuthorDate: Mon May 27 18:27:23 2019 +0530

    server: fix for inactive service offering for VM (#3320)
    
    Fixes #3315
    Currently, the code was allowed to change service offering for VM to a 
deleted or inactive service offering. Added check for it to throw an exception.
    
    Signed-off-by: Abhishek Kumar <[email protected]>
---
 server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java 
b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index 3727ea6..08742b5 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -965,6 +965,9 @@ public class UserVmManagerImpl extends ManagerBase 
implements UserVmManager, Vir
         // Check resource limits for CPU and Memory.
         Map<String, String> customParameters = cmd.getDetails();
         ServiceOfferingVO newServiceOffering = _offeringDao.findById(svcOffId);
+        if (newServiceOffering.getState() == DiskOffering.State.Inactive) {
+            throw new InvalidParameterValueException(String.format("Unable to 
upgrade virtual machine %s with an inactive service offering %s", 
vmInstance.getUuid(), newServiceOffering.getUuid()));
+        }
         if (newServiceOffering.isDynamic()) {
             newServiceOffering.setDynamicFlag(true);
             validateCustomParameters(newServiceOffering, cmd.getDetails());

Reply via email to