cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [11/54] [abbrv] git commit: updated refs/heads/distributedrouter to 42b553e
Date Fri, 14 Mar 2014 10:37:24 GMT
deployVm/startVm APIs: ability to define deploymentPlanner for VmToStart in the api call (available
to ROOT admin only)


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

Branch: refs/heads/distributedrouter
Commit: 1b83698dac712e3497d4140b15c9fcba3870c705
Parents: 5779292
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Mar 11 10:14:08 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Mar 13 10:23:34 2014 -0700

----------------------------------------------------------------------
 .../api/command/user/vm/DeployVMCmd.java        |  7 ++++
 .../api/command/user/vm/StartVMCmd.java         | 13 ++++++--
 .../src/com/cloud/vm/VirtualMachineManager.java |  2 +-
 .../cloud/entity/api/VirtualMachineEntity.java  |  3 +-
 .../cloud/deploy/DeploymentPlanningManager.java |  4 ++-
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 20 ++++++-----
 .../src/com/cloud/vm/VmWorkStart.java           | 12 +++++--
 .../cloud/entity/api/VMEntityManager.java       |  3 +-
 .../cloud/entity/api/VMEntityManagerImpl.java   | 19 ++++++-----
 .../entity/api/VirtualMachineEntityImpl.java    |  4 +--
 .../cloud/entity/api/db/VMReservationVO.java    | 11 ++++++
 .../lb/InternalLoadBalancerVMManagerImpl.java   |  2 +-
 .../deploy/DeploymentPlanningManagerImpl.java   | 31 +++++++++++------
 .../src/com/cloud/deploy/FirstFitPlanner.java   |  3 +-
 .../cloud/network/as/AutoScaleManagerImpl.java  |  4 +--
 server/src/com/cloud/vm/UserVmManager.java      |  2 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 35 ++++++++++----------
 setup/db/db/schema-430to440.sql                 |  2 ++
 18 files changed, 113 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/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 bd363da..44edef8 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
@@ -178,6 +178,9 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
     @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.3", description
= "used to specify the custom parameters.")
     private Map details;
 
+    @Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description
= "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4",
authorized = { RoleType.Admin })
+    private String deploymentPlanner;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -193,6 +196,10 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
         return diskOfferingId;
     }
 
+    public String getDeploymentPlanner() {
+        return deploymentPlanner;
+    }
+
     public String getDisplayName() {
         return displayName;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
index 553b753..f55aa59 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
@@ -16,18 +16,18 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
-import org.apache.cloudstack.api.BaseAsyncVMCmd;
-import org.apache.log4j.Logger;
-
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -61,6 +61,9 @@ public class StartVMCmd extends BaseAsyncVMCmd {
                since = "3.0.1")
     private Long hostId;
 
+    @Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description
= "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4",
authorized = { RoleType.Admin })
+    private String deploymentPlanner;
+
     // ///////////////////////////////////////////////////
     // ///////////////// Accessors ///////////////////////
     // ///////////////////////////////////////////////////
@@ -86,6 +89,10 @@ public class StartVMCmd extends BaseAsyncVMCmd {
         return "virtualmachine";
     }
 
+    public String getDeploymentPlanner() {
+        return deploymentPlanner;
+    }
+
     @Override
     public long getEntityOwnerId() {
         UserVm vm = _responseGenerator.findUserVmById(getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/api/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/com/cloud/vm/VirtualMachineManager.java b/engine/api/src/com/cloud/vm/VirtualMachineManager.java
index 350f396..99f5595 100644
--- a/engine/api/src/com/cloud/vm/VirtualMachineManager.java
+++ b/engine/api/src/com/cloud/vm/VirtualMachineManager.java
@@ -85,7 +85,7 @@ public interface VirtualMachineManager extends Manager {
 
     void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params);
 
-    void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan
planToDeploy);
+    void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan
planToDeploy, DeploymentPlanner planner);
 
     void stop(String vmUuid) throws ResourceUnavailableException;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java
b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java
index 773c683..37501f0 100755
--- a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java
+++ b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java
@@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
 
 import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.CloudException;
@@ -90,7 +91,7 @@ public interface VirtualMachineEntity extends CloudStackEntity {
      * @param exclude list of areas to exclude
      * @return a reservation id
      */
-    String reserve(String plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude,
String caller) throws InsufficientCapacityException,
+    String reserve(DeploymentPlanner plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList
exclude, String caller) throws InsufficientCapacityException,
         ResourceUnavailableException;
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
index de2fc0e..ee6721a 100644
--- a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
+++ b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
@@ -43,8 +43,10 @@ public interface DeploymentPlanningManager extends Manager {
             ExcludeList avoids, DeploymentPlanner planner) throws InsufficientServerCapacityException,
AffinityConflictException;
 
     String finalizeReservation(DeployDestination plannedDestination,
-            VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)
+            VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids, DeploymentPlanner
planner)
             throws InsufficientServerCapacityException, AffinityConflictException;
 
     void cleanupVMReservations();
+
+    DeploymentPlanner getDeploymentPlannerByName(String plannerName);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 609aefa..2cbde35 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -40,8 +40,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -70,6 +68,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -80,8 +79,8 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
 import com.cloud.agent.api.CheckVirtualMachineCommand;
 import com.cloud.agent.api.ClusterSyncAnswer;
 import com.cloud.agent.api.ClusterSyncCommand;
-import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
 import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
+import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.MigrateAnswer;
 import com.cloud.agent.api.MigrateCommand;
@@ -608,13 +607,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
     @Override
     public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params)
{
-        start(vmUuid, params, null);
+        start(vmUuid, params, null, null);
     }
 
     @Override
-    public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params,
DeploymentPlan planToDeploy) {
+    public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params,
DeploymentPlan planToDeploy, DeploymentPlanner planner) {
         try {
-            advanceStart(vmUuid, params, planToDeploy, null);
+            advanceStart(vmUuid, params, planToDeploy, planner);
         } catch (ConcurrentOperationException e) {
             throw new CloudRuntimeException("Unable to start a VM due to concurrent operation",
e).add(VirtualMachine.class, vmUuid);
         } catch (InsufficientCapacityException e) {
@@ -779,7 +778,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                     _workJobDao.expunge(placeHolder.getId());
             }
         } else {
-            Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params,
planToDeploy);
+            Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params,
planToDeploy, planner);
 
             try {
                 VirtualMachine vm = outcome.get();
@@ -4451,7 +4450,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     //
     public Outcome<VirtualMachine> startVmThroughJobQueue(final String vmUuid,
             final Map<VirtualMachineProfile.Param, Object> params,
-            final DeploymentPlan planToDeploy) {
+            final DeploymentPlan planToDeploy, final DeploymentPlanner planner) {
 
         final CallContext context = CallContext.current();
         final User callingUser = context.getCallingUser();
@@ -4488,6 +4487,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         // save work context info (there are some duplications)
                         VmWorkStart workInfo = new VmWorkStart(callingUser.getId(), callingAccount.getId(),
vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER);
                         workInfo.setPlan(planToDeploy);
+                        if (planner != null) {
+                            workInfo.setDeploymentPlanner(planner.getName());
+                        }
                         workInfo.setParams(params);
                         workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
 
@@ -5123,7 +5125,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         }
         assert (vm != null);
 
-        orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), null);
+        orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner()));
         return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
index f1b2efd..bb9f375 100644
--- a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
@@ -21,10 +21,9 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
+import org.apache.log4j.Logger;
 
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeploymentPlan;
@@ -46,6 +45,7 @@ public class VmWorkStart extends VmWork {
 
     String reservationId;
     String journalName;
+    String planner;
 
     // use serialization friendly map
     private Map<String, String> rawParams;
@@ -91,6 +91,14 @@ public class VmWorkStart extends VmWork {
         }
     }
 
+    public void setDeploymentPlanner(String planner) {
+        this.planner = planner;
+    }
+
+    public String getDeploymentPlanner() {
+        return this.planner;
+    }
+
     public Map<String, String> getRawParams() {
         return rawParams;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
index 7c53302..3145314 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
 
 import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.ConcurrentOperationException;
@@ -35,7 +36,7 @@ public interface VMEntityManager {
 
     void saveVirtualMachine(VMEntityVO vmInstanceVO);
 
-    String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan
plan, ExcludeList exclude) throws InsufficientCapacityException,
+    String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse, DeploymentPlan
plan, ExcludeList exclude) throws InsufficientCapacityException,
         ResourceUnavailableException;
 
     void deployVirtualMachine(String reservationId, VMEntityVO vmEntityVO, String caller,
Map<VirtualMachineProfile.Param, Object> params)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
index 36481ab..b1ac2f8 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java
@@ -22,9 +22,6 @@ import java.util.UUID;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
 import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
@@ -32,6 +29,8 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
 import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.dc.DataCenter;
 import com.cloud.deploy.DataCenterDeployment;
@@ -114,6 +113,8 @@ public class VMEntityManagerImpl implements VMEntityManager {
 
     @Inject
     protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
+    @Inject
+    DeploymentPlanningManager _planningMgr;
 
     @Override
     public VMEntityVO loadVirtualMachine(String vmId) {
@@ -138,7 +139,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
     }
 
     @Override
-    public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan
planToDeploy, ExcludeList exclude)
+    public String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse,
DeploymentPlan planToDeploy, ExcludeList exclude)
         throws InsufficientCapacityException, ResourceUnavailableException {
 
         //call planner and get the deployDestination.
@@ -189,13 +190,13 @@ public class VMEntityManagerImpl implements VMEntityManager {
         while (true) {
             DeployDestination dest = null;
             try {
-                dest = _dpMgr.planDeployment(vmProfile, plan, exclude, null);
+                dest = _dpMgr.planDeployment(vmProfile, plan, exclude, plannerToUse);
             } catch (AffinityConflictException e) {
                 throw new CloudRuntimeException("Unable to create deployment, affinity rules
associted to the VM conflict");
             }
 
             if (dest != null) {
-                String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan,
exclude);
+                String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan,
exclude, plannerToUse);
                 if (reservationId != null) {
                     return reservationId;
                 } else {
@@ -229,7 +230,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
             DataCenterDeployment reservedPlan =
                 new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(),
vmReservation.getClusterId(), vmReservation.getHostId(), null, null);
             try {
-                _itMgr.start(vm.getUuid(), params, reservedPlan);
+                _itMgr.start(vm.getUuid(), params, reservedPlan, _planningMgr.getDeploymentPlannerByName(vmReservation.getDeploymentPlanner()));
             } catch (Exception ex) {
                 // Retry the deployment without using the reservation plan
                 DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null,
null, null);
@@ -238,11 +239,11 @@ public class VMEntityManagerImpl implements VMEntityManager {
                     plan.setAvoids(reservedPlan.getAvoids());
                 }
 
-                _itMgr.start(vm.getUuid(), params, plan);
+                _itMgr.start(vm.getUuid(), params, plan, null);
             }
         } else {
             // no reservation found. Let VirtualMachineManager retry
-            _itMgr.start(vm.getUuid(), params, null);
+            _itMgr.start(vm.getUuid(), params, null, null);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
index 7f2e4ff..706748f 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java
@@ -24,10 +24,10 @@ import java.util.Map;
 import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
 
 import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.ConcurrentOperationException;
@@ -195,7 +195,7 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity
{
     }
 
     @Override
-    public String reserve(String plannerToUse, DeploymentPlan plan, ExcludeList exclude,
String caller) throws InsufficientCapacityException,
+    public String reserve(DeploymentPlanner plannerToUse, DeploymentPlan plan, ExcludeList
exclude, String caller) throws InsufficientCapacityException,
         ResourceUnavailableException {
         return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
index dabed15..b934a5d 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java
@@ -66,6 +66,9 @@ public class VMReservationVO implements Identity, InternalIdentity {
     @Column(name = GenericDao.REMOVED_COLUMN)
     private Date removed;
 
+    @Column(name = "deployment_planner")
+    private String deploymentPlanner;
+
     // VolumeId -> poolId
     @Transient
     Map<Long, Long> volumeReservationMap;
@@ -124,4 +127,12 @@ public class VMReservationVO implements Identity, InternalIdentity {
         this.volumeReservationMap = volumeReservationMap;
     }
 
+    public void setDeploymentPlanner(String planner) {
+        this.deploymentPlanner = planner;
+    }
+
+    public String getDeploymentPlanner() {
+        return this.deploymentPlanner;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index 8b82306..aa763d5 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -805,7 +805,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
In
     protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller,
long callerUserId, Map<Param, Object> params)
         throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException,
ResourceUnavailableException {
         s_logger.debug("Starting Internal LB VM " + internalLbVm);
-        _itMgr.start(internalLbVm.getUuid(), params, null);
+        _itMgr.start(internalLbVm.getUuid(), params, null, null);
         if (internalLbVm.isStopPending()) {
             s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName()
+ " after start router successfully!");
             internalLbVm.setStopPending(false);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index f76e485..5312e15 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -31,8 +31,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.AffinityGroupProcessor;
 import org.apache.cloudstack.affinity.AffinityGroupService;
 import org.apache.cloudstack.affinity.AffinityGroupVMMapVO;
@@ -51,6 +49,7 @@ import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -284,12 +283,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                     plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
                 }
             }
-            for (DeploymentPlanner plannerInList : _planners) {
-                if (plannerName.equals(plannerInList.getName())) {
-                    planner = plannerInList;
-                    break;
-                }
-            }
+            planner = getDeploymentPlannerByName(plannerName);
         }
 
         int cpu_requested = offering.getCpu() * offering.getSpeed();
@@ -450,7 +444,6 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
 
         if (planner != null && planner.canHandle(vmProfile, plan, avoids)) {
             while (true) {
-
                 if (planner instanceof DeploymentClusterPlanner) {
 
                     ExcludeList plannerAvoidInput =
@@ -502,6 +495,21 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
         return dest;
     }
 
+    @Override
+    public DeploymentPlanner getDeploymentPlannerByName(String plannerName) {
+        if (plannerName != null) {
+            for (DeploymentPlanner plannerInList : _planners) {
+                if (plannerName != null) {
+                }
+                if (plannerName.equalsIgnoreCase(plannerInList.getName())) {
+                    return plannerInList;
+                }
+            }
+        }
+
+        return null;
+    }
+
     private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter
dc, ExcludeList avoids) {
         boolean isExplicit = false;
         VirtualMachine vm = vmProfile.getVirtualMachine();
@@ -1345,7 +1353,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
 
     @DB
     @Override
-    public String finalizeReservation(final DeployDestination plannedDestination, final VirtualMachineProfile
vmProfile, DeploymentPlan plan, ExcludeList avoids)
+    public String finalizeReservation(final DeployDestination plannedDestination, final VirtualMachineProfile
vmProfile, DeploymentPlan plan, ExcludeList avoids, final DeploymentPlanner planner)
         throws InsufficientServerCapacityException, AffinityConflictException {
 
         final VirtualMachine vm = vmProfile.getVirtualMachine();
@@ -1374,6 +1382,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                     VMReservationVO vmReservation =
                         new VMReservationVO(vm.getId(), plannedDestination.getDataCenter().getId(),
plannedDestination.getPod().getId(), plannedDestination.getCluster()
                             .getId(), plannedDestination.getHost().getId());
+                    if (planner != null) {
+                        vmReservation.setDeploymentPlanner(planner.getName());
+                    }
                     Map<Long, Long> volumeReservationMap = new HashMap<Long, Long>();
 
                     if (vm.getHypervisorType() != HypervisorType.BareMetal) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/server/src/com/cloud/deploy/FirstFitPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java
index 1c79a67..c09fa7a 100755
--- a/server/src/com/cloud/deploy/FirstFitPlanner.java
+++ b/server/src/com/cloud/deploy/FirstFitPlanner.java
@@ -25,13 +25,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.log4j.Logger;
 
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityManager;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index 2fa3821..61b7f4b 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -53,7 +53,6 @@ import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 import org.apache.cloudstack.config.ApiServiceConfiguration;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiDBUtils;
@@ -120,7 +119,6 @@ import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmService;
-
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 
@@ -1371,7 +1369,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements
AutoScale
     private boolean startNewVM(final long vmId) {
         try {
             CallContext.current().setEventDetails("Vm Id: " + vmId);
-            _userVmManager.startVirtualMachine(vmId, null, null);
+            _userVmManager.startVirtualMachine(vmId, null, null, null);
         } catch (final ResourceUnavailableException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/server/src/com/cloud/vm/UserVmManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManager.java b/server/src/com/cloud/vm/UserVmManager.java
index 7371692..11b110f 100755
--- a/server/src/com/cloud/vm/UserVmManager.java
+++ b/server/src/com/cloud/vm/UserVmManager.java
@@ -108,7 +108,7 @@ public interface UserVmManager extends UserVmService {
     Pair<List<UserVmJoinVO>, Integer> searchForUserVMs(Criteria c, Account caller,
Long domainId, boolean isRecursive, List<Long> permittedAccounts, boolean listAll,
         ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String>
tags);
 
-    Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long
vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams)
+    Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long
vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String
deploymentPlannerToUse)
         throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
 
     boolean upgradeVirtualMachine(Long id, Long serviceOfferingId, Map<String, String>
customParameters) throws ResourceUnavailableException,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/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 be00aa8..0751d27 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -115,7 +115,9 @@ import com.cloud.dc.dao.DedicatedResourceDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeployDestination;
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.deploy.DeploymentPlanningManager;
 import com.cloud.deploy.PlannerHostReservationVO;
 import com.cloud.deploy.dao.PlannerHostReservationDao;
 import com.cloud.domain.DomainVO;
@@ -396,7 +398,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     protected ProjectManager _projectMgr;
     @Inject
     protected ResourceManager _resourceMgr;
-
     @Inject
     protected NetworkServiceMapDao _ntwkSrvcDao;
     @Inject
@@ -415,17 +416,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     protected GuestOSCategoryDao _guestOSCategoryDao;
     @Inject
     UsageEventDao _usageEventDao;
-
     @Inject
     SecondaryStorageVmDao _secondaryDao;
     @Inject
     VmDiskStatisticsDao _vmDiskStatsDao;
-
     @Inject
     protected VMSnapshotDao _vmSnapshotDao;
     @Inject
     protected VMSnapshotManager _vmSnapshotMgr;
-
     @Inject
     AffinityGroupVMMapDao _affinityGroupVMMapDao;
     @Inject
@@ -450,6 +448,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     UserVmDetailsDao _uservmDetailsDao;
     @Inject
     UUIDManager _uuidMgr;
+    @Inject
+    DeploymentPlanningManager _planningMgr;
 
     protected ScheduledExecutorService _executor = null;
     protected int _expungeInterval;
@@ -1975,7 +1975,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VM_START, eventDescription = "starting Vm",
async = true)
     public UserVm startVirtualMachine(StartVMCmd cmd) throws ExecutionException, ConcurrentOperationException,
ResourceUnavailableException, InsufficientCapacityException {
-        return startVirtualMachine(cmd.getId(), cmd.getHostId(), null).first();
+        return startVirtualMachine(cmd.getId(), cmd.getHostId(), null, cmd.getDeploymentPlanner()).first();
     }
 
     @Override
@@ -2974,10 +2974,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "starting Vm",
async = true)
     public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException,
InsufficientCapacityException, ConcurrentOperationException {
-        return startVirtualMachine(cmd, null);
+        return startVirtualMachine(cmd, null, cmd.getDeploymentPlanner());
     }
 
-    protected UserVm startVirtualMachine(DeployVMCmd cmd, Map<VirtualMachineProfile.Param,
Object> additonalParams) throws ResourceUnavailableException,
+    protected UserVm startVirtualMachine(DeployVMCmd cmd, Map<VirtualMachineProfile.Param,
Object> additonalParams, String deploymentPlannerToUse) throws ResourceUnavailableException,
             InsufficientCapacityException, ConcurrentOperationException {
 
         long vmId = cmd.getEntityId();
@@ -2986,7 +2986,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
         Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair
= null;
         try {
-            vmParamPair = startVirtualMachine(vmId, hostId, additonalParams);
+            vmParamPair = startVirtualMachine(vmId, hostId, additonalParams, deploymentPlannerToUse);
             vm = vmParamPair.first();
         } finally {
             updateVmStateForFailedVmCreation(vm.getId(), hostId);
@@ -3232,7 +3232,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
     }
 
     @Override
-    public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long
vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams)
+    public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long
vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String
deploymentPlannerToUse)
             throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException
{
         // Input validation
         Account callerAccount = CallContext.current().getCallingAccount();
@@ -3324,18 +3324,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
         VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
 
-        // Get serviceOffering for Virtual Machine
-        ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(),
vm.getServiceOfferingId());
-        String plannerName = offering.getDeploymentPlanner();
-        if (plannerName == null) {
-            if (vm.getHypervisorType() == HypervisorType.BareMetal) {
-                plannerName = "BareMetalPlanner";
-            } else {
-                plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
+        DeploymentPlanner planner = null;
+        if (deploymentPlannerToUse != null) {
+            // if set to null, the deployment planner would be later figured out either from
global config var, or from
+            // the service offering
+            planner = _planningMgr.getDeploymentPlannerByName(deploymentPlannerToUse);
+            if (planner == null) {
+                throw new InvalidParameterValueException("Can't find a planner by name "
+ deploymentPlannerToUse);
             }
         }
 
-        String reservationId = vmEntity.reserve(plannerName, plan, new ExcludeList(), Long.toString(callerUser.getId()));
+        String reservationId = vmEntity.reserve(planner, plan, new ExcludeList(), Long.toString(callerUser.getId()));
         vmEntity.deploy(reservationId, Long.toString(callerUser.getId()), params);
 
         Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair
= new Pair(vm, params);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b83698d/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index ab6bc98..235f357 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -621,3 +621,5 @@ UPDATE `cloud`.`guest_os_hypervisor` SET `created` = now();
 ALTER TABLE `cloud`.`guest_os` ADD COLUMN `created` datetime COMMENT 'Time when Guest OS
was created in system';
 ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when Guest OS
was removed if deleted, else NULL';
 UPDATE `cloud`.`guest_os` SET `created` = now();
+
+ALTER TABLE `cloud`.`vm_reservation` ADD COLUMN `deployment_planner` varchar(40) DEFAULT
NULL COMMENT 'Preferred deployment planner for the vm';


Mime
View raw message