diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java index a4c5bfa38db..025ca3b9c3b 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]; + } + } 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 ba466b05a04..ae0cf2a6103 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/////////////////// ///////////////////////////////////////////////////// diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index b8a7a5f7790..7727061ad39 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); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 267a21e1715..a40af6e58e3 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()); }