cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/4.3 to c8929df
Date Mon, 10 Nov 2014 12:44:00 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.3 9a4e79990 -> c8929dfd1


CLOUDSTACK-7871: allow VM and template details update using update APIs

Allows updating details (key/value) pair which updates entries in
vm_template_details and user_vm_details tables using updateVM and updateTemplate
APIs. This allows sys admins to update nics, controllers etc without DB hacking.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c8929dfd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c8929dfd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c8929dfd

Branch: refs/heads/4.3
Commit: c8929dfd10a3c0361dca6fd4bd4ff83010c9bcad
Parents: 9a4e799
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Mon Nov 10 18:12:37 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Nov 10 18:12:37 2014 +0530

----------------------------------------------------------------------
 .../cloudstack/api/BaseUpdateTemplateOrIsoCmd.java  | 16 ++++++++++++++++
 .../cloudstack/api/command/user/vm/UpdateVMCmd.java | 14 ++++++++++++++
 .../src/com/cloud/template/TemplateManagerImpl.java |  8 +++++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java      |  6 ++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8929dfd/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
index a4c5bfa..025ca3b 100644
--- a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -21,6 +21,9 @@ import org.apache.cloudstack.api.response.GuestOSResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.log4j.Logger;
 
+import java.util.Collection;
+import java.util.Map;
+
 public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName());
 
@@ -60,6 +63,9 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     @Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true
if the template type is routing i.e., if template is used to deploy router")
     protected Boolean isRoutingType;
 
+    @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details
in key/value pairs.")
+    protected Map details;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -103,4 +109,14 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
     public Boolean isRoutingType() {
         return isRoutingType;
     }
+
+    public Map getDetails() {
+        if (this.details == null || this.details.isEmpty()) {
+            return null;
+        }
+
+        Collection paramsCollection = this.details.values();
+        return (Map) (paramsCollection.toArray())[0];
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8929dfd/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
index ba466b0..ae0cf2a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
@@ -33,6 +33,8 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
 
+import java.util.Collection;
+import java.util.Map;
 
 @APICommand(name = "updateVirtualMachine", description="Updates properties of a virtual machine.
The VM has to be stopped and restarted for the " +
         "new properties to take effect. UpdateVirtualMachine does not first check whether
the VM is stopped. " +
@@ -71,6 +73,9 @@ public class UpdateVMCmd extends BaseCmd{
     @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description
= "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
     protected Boolean isDynamicallyScalable;
 
+    @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details
in key/value pairs.")
+    protected Map details;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -103,6 +108,15 @@ public class UpdateVMCmd extends BaseCmd{
         return isDynamicallyScalable;
     }
 
+    public Map getDetails() {
+        if (this.details == null || this.details.isEmpty()) {
+            return null;
+        }
+
+        Collection paramsCollection = this.details.values();
+        return (Map) (paramsCollection.toArray())[0];
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8929dfd/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index b8a7a5f..7727061 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1825,6 +1825,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         Boolean isRoutingTemplate = cmd.isRoutingType();
         Boolean bootable = cmd.isBootable();
         Integer sortKey = cmd.getSortKey();
+        Map details = cmd.getDetails();
         Account account = CallContext.current().getCallingAccount();
 
         // verify that template exists
@@ -1851,7 +1852,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         }
 
         boolean updateNeeded = !(name == null && displayText == null && format
== null && guestOSId == null && passwordEnabled == null
-                && bootable == null && sortKey == null && isDynamicallyScalable
== null && isRoutingTemplate == null);
+                && bootable == null && sortKey == null && isDynamicallyScalable
== null && isRoutingTemplate == null && details == null);
         if (!updateNeeded) {
             return template;
         }
@@ -1912,6 +1913,11 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
             }
         }
 
+        if (details != null && !details.isEmpty()) {
+            template.setDetails(details);
+            _tmpltDao.saveDetails(template);
+        }
+
         _tmpltDao.update(id, template);
 
         return _tmpltDao.findById(id);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8929dfd/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 267a21e..a40af6e 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1904,6 +1904,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         Long osTypeId = cmd.getOsTypeId();
         String userData = cmd.getUserData();
         Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
+        Map details = cmd.getDetails();
         Account caller = CallContext.current().getCallingAccount();
 
         // Input validation and permission checks
@@ -1922,6 +1923,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
             }
         }
 
+        if (details != null && !details.isEmpty()) {
+            vmInstance.setDetails(details);
+            _vmDao.saveDetails(vmInstance);
+        }
+
         return updateVirtualMachine(id, displayName, group, ha, isDisplayVmEnabled, osTypeId,
userData, isDynamicallyScalable, cmd.getHttpMethod());
     }
 


Mime
View raw message