Skip to content

Commit 089c7bc

Browse files
bvbharatJayapal
authored andcommitted
CLOUDSTACK-5161 use a map to specify the custom parameters instead of having one parameter each
1 parent cb70ed1 commit 089c7bc

8 files changed

Lines changed: 100 additions & 144 deletions

File tree

api/src/com/cloud/vm/UserVmService.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
203203
* available.
204204
* @throws InsufficientResourcesException
205205
*/
206-
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName,
207-
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
208-
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
209-
IpAddresses defaultIp, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList, Integer cpuSpeed, Integer memory, Integer cpuNumber, Long rootdisksize)
210-
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
206+
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList,
207+
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod,
208+
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
209+
List<Long> affinityGroupIdList, Map<String, String> customParameter) throws InsufficientCapacityException,
210+
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
211211

212212
/**
213213
* Creates a User VM in Advanced Zone (Security Group feature is enabled) in
@@ -282,10 +282,11 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
282282
* available.
283283
* @throws InsufficientResourcesException
284284
*/
285-
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList,
286-
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair,
287-
Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList, Integer cpuSpeed, Integer memory, Integer cpuNumber, Long rootdisksize)
288-
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
285+
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
286+
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
287+
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
288+
List<Long> affinityGroupIdList, Map<String, String> customParameters) throws InsufficientCapacityException,
289+
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
289290

290291
/**
291292
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
@@ -357,10 +358,10 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
357358
* available.
358359
* @throws InsufficientResourcesException
359360
*/
360-
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
361-
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
362-
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
363-
IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList, Integer cpuSpeed, Integer memory, Integer cpuNumber, Long rootdkisksize)
361+
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner,
362+
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
363+
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
364+
Map<String, String> customParameters)
364365

365366
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
366367

api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,11 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
188188
@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.")
189189
private Boolean displayVm;
190190

191-
@Parameter(name=ApiConstants.CPU_SPEED, type = CommandType.INTEGER, since="4.3", description = "optional field to specify the cpu speed when using dynamic compute offering.")
192-
private Integer cpuSpeed;
193-
194-
@Parameter(name=ApiConstants.MEMORY, type = CommandType.INTEGER, since="4.3", description = "optional field to specify the memory when using dynamic compute offering")
195-
private Integer memory;
196-
197-
@Parameter(name=ApiConstants.CPU_NUMBER, type=CommandType.INTEGER, since="4.3", description = "optional field to specify the number of cpu cores when using dynamic offering.")
198-
private Integer cpuNumber;
199-
200-
@Parameter(name=ApiConstants.ROOT_DISK_SIZE, type=CommandType.LONG, since="4.3", description = "optional field to specify the number of cpu cores when using dynamic offering.")
201-
private Long rootdisksize;
191+
@Parameter(name = ApiConstants.CUSTOM_PARAMETERS,
192+
type = CommandType.MAP,
193+
since= "4.3",
194+
description = "used to specify the custom parameters.")
195+
private Map customParameters;
202196

203197
/////////////////////////////////////////////////////
204198
/////////////////// Accessors ///////////////////////
@@ -227,6 +221,21 @@ public Long getDomainId() {
227221
return domainId;
228222
}
229223

224+
public Map<String, String> getCustomParameters() {
225+
Map<String,String> customparameterMap = new HashMap<String, String>();
226+
if (customParameters != null && customParameters.size() !=0){
227+
Collection parameterCollection = customParameters.values();
228+
Iterator iter = parameterCollection.iterator();
229+
while (iter.hasNext()) {
230+
HashMap<String, String> value = (HashMap<String, String>) iter.next();
231+
for (String key : value.keySet()) {
232+
customparameterMap.put(key, value.get(key));
233+
}
234+
}
235+
}
236+
return customparameterMap;
237+
}
238+
230239
public String getGroup() {
231240
return group;
232241
}
@@ -239,21 +248,6 @@ public Boolean getDisplayVm() {
239248
return displayVm;
240249
}
241250

242-
public Integer getMemory() {
243-
return memory;
244-
}
245-
246-
public Integer getCpuSpeed() {
247-
return cpuSpeed;
248-
}
249-
250-
public Integer getCpuNumber() {
251-
return cpuNumber;
252-
}
253-
254-
public Long getRootdisksize() {
255-
return rootdisksize;
256-
}
257251

258252
public List<Long> getSecurityGroupIdList() {
259253
if (securityGroupNameList != null && securityGroupIdList != null) {
@@ -522,20 +516,26 @@ public void create() throws ResourceAllocationException{
522516
if (getNetworkIds() != null) {
523517
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
524518
} else {
525-
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
526-
displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(), cpuSpeed, memory, cpuNumber, rootdisksize);
519+
vm =
520+
_userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name, displayName,
521+
diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard,
522+
getAffinityGroupIdList(), getCustomParameters());
527523
}
528524
} else {
529-
if (zone.isSecurityGroupEnabled()) {
530-
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
531-
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(), cpuSpeed, memory, cpuNumber, rootdisksize );
525+
if (zone.isSecurityGroupEnabled()) {
526+
vm =
527+
_userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(), owner, name,
528+
displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm,
529+
keyboard, getAffinityGroupIdList(), getCustomParameters());
532530

533531
} else {
534532
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
535533
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
536534
}
537-
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
538-
diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(), cpuSpeed, memory, cpuNumber, rootdisksize);
535+
vm =
536+
_userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName, diskOfferingId, size,
537+
group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(),
538+
getCustomParameters());
539539

540540
}
541541
}

engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public interface VolumeOrchestrationService {
8686

8787
boolean canVmRestartOnAnotherServer(long vmId);
8888

89-
DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm, Account owner);
89+
DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, VirtualMachineTemplate template, VirtualMachine vm, Account owner);
9090

9191
String getVmNameFromVolumeId(long volumeId);
9292

engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public interface OrchestrationService {
5555
* @param computeTags tags for the compute
5656
* @param rootDiskTags tags for the root disk
5757
* @param networks networks that this VM should join
58-
* @param rootDiskSize size the root disk in case of templates.
5958
* @return VirtualMachineEntity
6059
*/
6160
@POST
@@ -74,8 +73,7 @@ VirtualMachineEntity createVirtualMachine(
7473
@QueryParam("compute-tags") List<String> computeTags,
7574
@QueryParam("root-disk-tags") List<String> rootDiskTags,
7675
@QueryParam("network-nic-map") Map<String, NicProfile> networkNicMap,
77-
@QueryParam("deploymentplan") DeploymentPlan plan,
78-
@QueryParam("root-disk-size") Long rootDiskSize
76+
@QueryParam("deploymentplan") DeploymentPlan plan
7977
) throws InsufficientCapacityException;
8078

8179
@POST

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) throws Insuff
398398
} else if (template.getFormat() == ImageFormat.BAREMETAL) {
399399
// Do nothing
400400
} else {
401-
volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), rootDiskOffering.second(), template, vmFinal, owner);
401+
volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), template, vmFinal, owner);
402402
}
403403

404404
for (Map.Entry<? extends DiskOffering, Long> offering : dataDiskOfferingsFinal.entrySet()) {

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public VirtualMachineEntity createVirtualMachine(
164164
Long diskSize,
165165
List<String> computeTags,
166166
List<String> rootDiskTags,
167-
Map<String, NicProfile> networkNicMap, DeploymentPlan plan, Long rootDiskSize) throws InsufficientCapacityException {
167+
Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
168168

169169
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
170170

@@ -193,7 +193,6 @@ public VirtualMachineEntity createVirtualMachine(
193193

194194
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
195195
rootDiskOffering.first(offering);
196-
rootDiskOffering.second(rootDiskSize);
197196

198197
if(vm.getDiskOfferingId() != null){
199198
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,10 @@ public DiskProfile allocateRawVolume(Type type, String name, DiskOffering offeri
587587
}
588588

589589
@Override
590-
public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm, Account owner) {
590+
public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, VirtualMachineTemplate template, VirtualMachine vm, Account owner) {
591591
assert (template.getFormat() != ImageFormat.ISO) : "ISO is not a template really....";
592592

593593
Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId());
594-
if (rootDisksize != null) {
595-
size = (rootDisksize * 1024 * 1024 * 1024);
596-
}
597594
VolumeVO vol = new VolumeVO(type,
598595
name,
599596
vm.getDataCenterId(),

0 commit comments

Comments
 (0)