CLOUDSTACK-5651 deployVm: customparameters param name has to be changed

Signed-off-by: Alena Prokharchyk <alena.prokharchyk@citrix.com>
This commit is contained in:
Bharat Kumar 2014-01-09 15:36:27 +05:30 committed by Alena Prokharchyk
parent db10acd8b3
commit 35e09c81e6
8 changed files with 37 additions and 40 deletions

View File

@ -71,7 +71,6 @@ public class ApiConstants {
public static final String DISPLAY_VM = "displayvm";
public static final String DISPLAY_OFFERING = "displayoffering";
public static final String DISPLAY_VOLUME = "displayvolume";
public static final String CUSTOM_PARAMETERS = "customparameters";
public static final String DNS1 = "dns1";
public static final String DNS2 = "dns2";
public static final String IP6_DNS1 = "ip6dns1";

View File

@ -63,8 +63,8 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
required=true, description="the service offering ID to apply to the system vm")
private Long serviceOfferingId;
@Parameter(name=ApiConstants.CUSTOM_PARAMETERS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example customparameters[i].name=value")
private Map<String, String> customParameters;
@Parameter(name=ApiConstants.DETAILS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example details[i].name=value")
private Map<String, String> details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -78,10 +78,10 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
return serviceOfferingId;
}
public Map<String, String> getCustomParameters() {
public Map<String, String> getDetails() {
Map<String,String> customparameterMap = new HashMap<String, String>();
if (customParameters != null && customParameters.size() !=0){
Collection parameterCollection = customParameters.values();
if (details != null && details.size() !=0){
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>) iter.next();

View File

@ -58,8 +58,8 @@ public class UpgradeSystemVMCmd extends BaseCmd {
required=true, description="the service offering ID to apply to the system vm")
private Long serviceOfferingId;
@Parameter(name=ApiConstants.CUSTOM_PARAMETERS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example customparameters[i].name=value")
private Map<String, String> customParameters;
@Parameter(name=ApiConstants.DETAILS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example details[i].name=value")
private Map<String, String> details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -73,10 +73,10 @@ public class UpgradeSystemVMCmd extends BaseCmd {
return serviceOfferingId;
}
public Map<String, String> getCustomParameters() {
public Map<String, String> getDetails() {
Map<String,String> customparameterMap = new HashMap<String, String>();
if (customParameters != null && customParameters.size() !=0){
Collection parameterCollection = customParameters.values();
if (details != null && details.size() !=0){
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>) iter.next();

View File

@ -188,11 +188,11 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.DISPLAY_VM, type=CommandType.BOOLEAN, since="4.2", description="an optional field, whether to the display the vm to the end user or not.")
private Boolean displayVm;
@Parameter(name = ApiConstants.CUSTOM_PARAMETERS,
@Parameter(name = ApiConstants.DETAILS,
type = CommandType.MAP,
since= "4.3",
description = "used to specify the custom parameters.")
private Map customParameters;
private Map details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -221,10 +221,10 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
return domainId;
}
public Map<String, String> getCustomParameters() {
public Map<String, String> getDetails() {
Map<String,String> customparameterMap = new HashMap<String, String>();
if (customParameters != null && customParameters.size() !=0){
Collection parameterCollection = customParameters.values();
if (details != null && details.size() !=0){
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>) iter.next();
@ -519,14 +519,14 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
vm =
_userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name, displayName,
diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard,
getAffinityGroupIdList(), getCustomParameters());
getAffinityGroupIdList(), getDetails());
}
} else {
if (zone.isSecurityGroupEnabled()) {
vm =
_userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(), owner, name,
displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm,
keyboard, getAffinityGroupIdList(), getCustomParameters());
keyboard, getAffinityGroupIdList(), getDetails());
} else {
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
@ -535,7 +535,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
vm =
_userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName, diskOfferingId, size,
group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(),
getCustomParameters());
getDetails());
}
}

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
@ -55,8 +54,8 @@ public class ScaleVMCmd extends BaseAsyncCmd {
required=true, description="the ID of the service offering for the virtual machine")
private Long serviceOfferingId;
@Parameter(name=ApiConstants.CUSTOM_PARAMETERS,type = BaseCmd.CommandType.MAP, description = "name value pairs of custom parameters for cpu,memory and cpunumber. example customparameters[i].name=value")
private Map<String, String> customParameters;
@Parameter(name=ApiConstants.DETAILS,type = BaseCmd.CommandType.MAP, description = "name value pairs of custom parameters for cpu,memory and cpunumber. example details[i].name=value")
private Map<String, String> details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -71,12 +70,12 @@ public class ScaleVMCmd extends BaseAsyncCmd {
}
//instead of reading a map directly we are using collections.
//it is because customParameters.values() cannot be cast to a map.
//it is because details.values() cannot be cast to a map.
//it gives a exception
public Map<String, String> getCustomParameters() {
public Map<String, String> getDetails() {
Map<String,String> customparameterMap = new HashMap<String, String>();
if (customParameters != null && customParameters.size() !=0){
Collection parameterCollection = customParameters.values();
if (details != null && details.size() !=0){
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>) iter.next();

View File

@ -58,8 +58,8 @@ public class UpgradeVMCmd extends BaseCmd {
required=true, description="the service offering ID to apply to the virtual machine")
private Long serviceOfferingId;
@Parameter(name=ApiConstants.CUSTOM_PARAMETERS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example customparameters[i].name=value")
private Map<String, String> customParameters;
@Parameter(name=ApiConstants.DETAILS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example details[i].name=value")
private Map<String, String> details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -73,10 +73,10 @@ public class UpgradeVMCmd extends BaseCmd {
return serviceOfferingId;
}
public Map<String, String> getCustomParameters() {
public Map<String, String> getDetails() {
Map<String,String> customparameterMap = new HashMap<String, String>();
if (customParameters != null && customParameters.size() !=0){
Collection parameterCollection = customParameters.values();
if (details != null && details.size() !=0){
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>) iter.next();

View File

@ -3837,7 +3837,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (vmInstance.getHypervisorType() == HypervisorType.XenServer && vmInstance.getState().equals(State.Running)) {
throw new InvalidParameterValueException("Dynamic Scaling operation is not permitted for this hypervisor on system vm");
}
boolean result = _userVmMgr.upgradeVirtualMachine(cmd.getId(), cmd.getServiceOfferingId(), cmd.getCustomParameters());
boolean result = _userVmMgr.upgradeVirtualMachine(cmd.getId(), cmd.getServiceOfferingId(), cmd.getDetails());
if(result){
VirtualMachine vm = _vmInstanceDao.findById(cmd.getId());
return vm;
@ -3851,7 +3851,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
public VirtualMachine upgradeSystemVM(UpgradeSystemVMCmd cmd) {
Long systemVmId = cmd.getId();
Long serviceOfferingId = cmd.getServiceOfferingId();
return upgradeStoppedSystemVm(systemVmId, serviceOfferingId, cmd.getCustomParameters());
return upgradeStoppedSystemVm(systemVmId, serviceOfferingId, cmd.getDetails());
}

View File

@ -35,7 +35,6 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.capacity.Capacity;
import com.cloud.exception.InsufficientServerCapacityException;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
@ -829,11 +828,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
_accountMgr.checkAccess(caller, null, true, vmInstance);
// Check resource limits for CPU and Memory.
Map<String,String> customParameters = cmd.getCustomParameters();
Map<String,String> customParameters = cmd.getDetails();
ServiceOfferingVO newServiceOffering = _offeringDao.findById(svcOffId);
if (newServiceOffering.isDynamic()) {
newServiceOffering.setDynamicFlag(true);
validateCustomParameters(newServiceOffering, cmd.getCustomParameters());
validateCustomParameters(newServiceOffering, cmd.getDetails());
newServiceOffering = _offeringDao.getcomputeOffering(newServiceOffering, customParameters);
}
ServiceOfferingVO currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getId(), vmInstance.getServiceOfferingId());
@ -890,7 +889,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
// Generate usage event for VM upgrade
generateUsageEvent(newServiceOffering, cmd.getCustomParameters(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
generateUsageEvent(newServiceOffering, cmd.getDetails(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
return _vmDao.findById(vmInstance.getId());
}
@ -1233,16 +1232,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
Long newServiceOfferingId = cmd.getServiceOfferingId();
CallContext.current().setEventDetails("Vm Id: " + vmId);
boolean result = upgradeVirtualMachine(vmId, newServiceOfferingId, cmd.getCustomParameters());
boolean result = upgradeVirtualMachine(vmId, newServiceOfferingId, cmd.getDetails());
if(result){
UserVmVO vmInstance = _vmDao.findById(vmId);
if(vmInstance.getState().equals(State.Stopped)){
// Generate usage event for VM upgrade
generateUsageEvent(_offeringDao.findById(newServiceOfferingId), cmd.getCustomParameters(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
generateUsageEvent(_offeringDao.findById(newServiceOfferingId), cmd.getDetails(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
}
if(vmInstance.getState().equals(State.Running)){
// Generate usage event for Dynamic scaling of VM
generateUsageEvent(_offeringDao.findById(newServiceOfferingId), cmd.getCustomParameters(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
generateUsageEvent(_offeringDao.findById(newServiceOfferingId), cmd.getDetails(), _vmDao.findById(vmId), EventTypes.EVENT_VM_UPGRADE);
}
return vmInstance;
} else {