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.5 to c401dbc
Date Mon, 10 Nov 2014 12:23:43 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.5 85ac979f7 -> c401dbc8f


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

Allows updating details (key/value) pair which updatse entries
invm_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>
(cherry picked from commit 97fa4a023e2346b3b9f56bf213ed4125c371ca6d)
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/c401dbc8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c401dbc8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c401dbc8

Branch: refs/heads/4.5
Commit: c401dbc8f986563159f49f5c419ad31437ef9d04
Parents: 85ac979
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Mon Nov 10 17:51:25 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Nov 10 17:53:26 2014 +0530

----------------------------------------------------------------------
 .../cloudstack/api/BaseUpdateTemplateOrIsoCmd.java | 17 ++++++++++++++++-
 .../api/command/user/vm/UpdateVMCmd.java           | 16 ++++++++++++++++
 .../com/cloud/template/TemplateManagerImpl.java    |  8 +++++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |  6 ++++++
 4 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c401dbc8/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 2350f6b..2754b25 100644
--- a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -22,6 +22,9 @@ import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
 import org.apache.cloudstack.api.response.GuestOSResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 
+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());
 
@@ -64,6 +67,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 ///////////////////////
     /////////////////////////////////////////////////////
@@ -107,4 +113,13 @@ 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];
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c401dbc8/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 d185b91..6954832 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
@@ -38,6 +38,9 @@ import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
 import com.cloud.vm.VirtualMachine;
 
+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. " +
         "Therefore, stop the VM manually before issuing this call.", responseObject = UserVmResponse.class,
responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
@@ -90,6 +93,9 @@ public class UpdateVMCmd extends BaseCustomIdCmd {
     @Parameter(name = ApiConstants.INSTANCE_NAME, type = CommandType.STRING, description
= "instance name of the user vm", since = "4.4", authorized = {RoleType.Admin})
     private String instanceName;
 
+    @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details
in key/value pairs.")
+    protected Map details;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -129,6 +135,16 @@ public class UpdateVMCmd extends BaseCustomIdCmd {
     public String getInstanceName() {
         return instanceName;
     }
+
+    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/c401dbc8/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 c7d2283..5641f57 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1776,6 +1776,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
@@ -1798,7 +1799,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);
+                        isDynamicallyScalable == null && isRoutingTemplate == null
&& details == null);
         if (!updateNeeded) {
             return template;
         }
@@ -1858,6 +1859,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/c401dbc8/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 28ec6ec..77ace7a 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1899,6 +1899,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         String userData = cmd.getUserData();
         Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
         String hostName = cmd.getHostName();
+        Map details = cmd.getDetails();
         Account caller = CallContext.current().getCallingAccount();
 
         // Input validation and permission checks
@@ -1938,6 +1939,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, isDisplayVm, osTypeId, userData,
isDynamicallyScalable,
                 cmd.getHttpMethod(), cmd.getCustomId(), hostName, cmd.getInstanceName());
     }


Mime
View raw message