cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/master to 05d056b
Date Mon, 04 Aug 2014 21:22:07 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 0fe1d4bb2 -> 05d056bb9


CLOUDSTACK-7194: deployVm Api, "hypervisor" parameter:
* is respected only when vm is deployed from ISO, or hypervisorType is not set on the template
record
* if parameter passed when vm is deployed from template having hypervisor info set, validate
that these 2 parameters are the same instead of silently defaulting the final value to the
one set on the template


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

Branch: refs/heads/master
Commit: 05d056bb90c80a42a8be087bdac5f0ed93bc3462
Parents: 0fe1d4b
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Aug 4 13:39:53 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Aug 4 14:21:52 2014 -0700

----------------------------------------------------------------------
 .../api/command/user/vm/DeployVMCmd.java        |  3 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 38 ++++++++++----------
 2 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/05d056bb/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 14b703c..8ceccb9 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -128,7 +128,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
     @Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "an optional
group for the virtual machine")
     private String group;
 
-    @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, description = "the
hypervisor on which to deploy the virtual machine")
+    @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, description = "the
hypervisor on which to deploy the virtual machine. "
+            + "The parameter is respected only when hypervisor info is not set on the ISO/Template
passed to the call")
     private String hypervisor;
 
     @Parameter(name = ApiConstants.USER_DATA, type = CommandType.STRING, description = "an
optional binary data that can be sent to the virtual machine upon a successful deployment.
This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via
querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST
body), you can send up to 32K of data after base64 encoding.", length = 32768)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/05d056bb/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 0fa5085..a9f8efd 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2716,7 +2716,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
             }
         }
 
-        if (template.getHypervisorType() != null && template.getHypervisorType()
!= HypervisorType.BareMetal) {
+        HypervisorType hypervisorType = null;
+        if (template.getHypervisorType() == null || template.getHypervisorType() == HypervisorType.None)
{
+            hypervisorType = hypervisor;
+        } else {
+            if (hypervisor != null && hypervisor != HypervisorType.None &&
hypervisor != template.getHypervisorType()) {
+                throw new InvalidParameterValueException("Hypervisor passed to the deployVm
call, is different from the hypervisor type of the template");
+            }
+            hypervisorType = template.getHypervisorType();
+        }
+
+        if (hypervisorType != HypervisorType.BareMetal) {
             // check if we have available pools for vm deployment
             long availablePools = _storagePoolDao.countPoolsByStatus(StoragePoolStatus.Up);
             if (availablePools < 1) {
@@ -2892,15 +2902,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
         checkIfHostNameUniqueInNtwkDomain(hostName, networkList);
 
-        HypervisorType hypervisorType = null;
-        if (template.getHypervisorType() == null || template.getHypervisorType() == HypervisorType.None)
{
-            hypervisorType = hypervisor;
-        } else {
-            hypervisorType = template.getHypervisorType();
-        }
-
-        UserVmVO vm = commitUserVm(zone, template, hostName, displayName, owner, diskOfferingId,
diskSize, userData, hypervisor, caller, isDisplayVm, keyboard, accountId,
-                offering, isIso, sshPublicKey, networkNicMap, id, instanceName, uuidName,
hypervisorType, customParameters);
+        UserVmVO vm = commitUserVm(zone, template, hostName, displayName, owner, diskOfferingId,
diskSize, userData, caller, isDisplayVm, keyboard, accountId, offering,
+                isIso, sshPublicKey, networkNicMap, id, instanceName, uuidName, hypervisorType,
customParameters);
 
         // Assign instance to the group
         try {
@@ -2957,10 +2960,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     }
 
     private UserVmVO commitUserVm(final DataCenter zone, final VirtualMachineTemplate template,
final String hostName, final String displayName, final Account owner,
-            final Long diskOfferingId, final Long diskSize, final String userData, final
HypervisorType hypervisor, final Account caller, final Boolean isDisplayVm,
-            final String keyboard, final long accountId, final ServiceOfferingVO offering,
final boolean isIso, final String sshPublicKey,
-            final LinkedHashMap<String, NicProfile> networkNicMap, final long id, final
String instanceName, final String uuidName, final HypervisorType hypervisorType,
-            final Map<String, String> customParameters) throws InsufficientCapacityException
{
+            final Long diskOfferingId, final Long diskSize, final String userData, final
Account caller, final Boolean isDisplayVm, final String keyboard,
+            final long accountId, final ServiceOfferingVO offering, final boolean isIso,
final String sshPublicKey, final LinkedHashMap<String, NicProfile> networkNicMap,
+            final long id, final String instanceName, final String uuidName, final HypervisorType
hypervisorType, final Map<String, String> customParameters) throws InsufficientCapacityException
{
         return Transaction.execute(new TransactionCallbackWithException<UserVmVO, InsufficientCapacityException>()
{
             @Override
             public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCapacityException
{
@@ -2993,8 +2995,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                     rootDiskSize = Long.parseLong(customParameters.get("rootdisksize"));
 
                     // only KVM supports rootdisksize override
-                    if (hypervisor != HypervisorType.KVM) {
-                        throw new InvalidParameterValueException("Hypervisor " + hypervisor
+ " does not support rootdisksize override");
+                    if (hypervisorType != HypervisorType.KVM) {
+                        throw new InvalidParameterValueException("Hypervisor " + hypervisorType
+ " does not support rootdisksize override");
                     }
 
                     // rotdisksize must be larger than template
@@ -3064,10 +3066,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
                 if (isIso) {
                     _orchSrvc.createVirtualMachineFromScratch(vm.getUuid(), Long.toString(owner.getAccountId()),
vm.getIsoId().toString(), hostName, displayName,
-                            hypervisor.name(), guestOSCategory.getName(), offering.getCpu(),
offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags,
+                            hypervisorType.name(), guestOSCategory.getName(), offering.getCpu(),
offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags,
                             networkNicMap, plan);
                 } else {
-                    _orchSrvc.createVirtualMachine(vm.getUuid(), Long.toString(owner.getAccountId()),
Long.toString(template.getId()), hostName, displayName, hypervisor.name(),
+                    _orchSrvc.createVirtualMachine(vm.getUuid(), Long.toString(owner.getAccountId()),
Long.toString(template.getId()), hostName, displayName, hypervisorType.name(),
                             offering.getCpu(), offering.getSpeed(), offering.getRamSize(),
diskSize, computeTags, rootDiskTags, networkNicMap, plan, rootDiskSize);
                 }
 


Mime
View raw message