4242
4343import org .apache .log4j .Logger ;
4444
45+ import com .cloud .deploy .DeploymentPlanner ;
4546import org .apache .cloudstack .affinity .dao .AffinityGroupVMMapDao ;
4647import org .apache .cloudstack .context .CallContext ;
4748import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
@@ -555,7 +556,7 @@ public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params
555556 @ Override
556557 public void start (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlan planToDeploy ) {
557558 try {
558- advanceStart (vmUuid , params , planToDeploy );
559+ advanceStart (vmUuid , params , planToDeploy , null );
559560 } catch (ConcurrentOperationException e ) {
560561 throw new CloudRuntimeException ("Unable to start a VM due to concurrent operation" , e ).add (VirtualMachine .class , vmUuid );
561562 } catch (InsufficientCapacityException e ) {
@@ -696,20 +697,20 @@ protected boolean areAffinityGroupsAssociated(VirtualMachineProfile vmProfile) {
696697 }
697698
698699 @ Override
699- public void advanceStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params )
700+ public void advanceStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlanner planner )
700701 throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException {
701702
702- advanceStart (vmUuid , params , null );
703+ advanceStart (vmUuid , params , null , planner );
703704 }
704705
705706 @ Override
706- public void advanceStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlan planToDeploy ) throws InsufficientCapacityException ,
707+ public void advanceStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlan planToDeploy , DeploymentPlanner planner ) throws InsufficientCapacityException ,
707708 ConcurrentOperationException , ResourceUnavailableException {
708709
709710 AsyncJobExecutionContext jobContext = AsyncJobExecutionContext .getCurrentExecutionContext ();
710711 if (!VmJobEnabled .value () || jobContext .isJobDispatchedBy (VmWorkConstants .VM_WORK_JOB_DISPATCHER )) {
711712 // avoid re-entrance
712- orchestrateStart (vmUuid , params , planToDeploy );
713+ orchestrateStart (vmUuid , params , planToDeploy , planner );
713714 } else {
714715 Outcome <VirtualMachine > outcome = startVmThroughJobQueue (vmUuid , params , planToDeploy );
715716
@@ -731,9 +732,11 @@ else if(jobException instanceof ResourceUnavailableException)
731732 }
732733 }
733734
734- private void orchestrateStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlan planToDeploy ) throws InsufficientCapacityException ,
735- ConcurrentOperationException , ResourceUnavailableException {
736735
736+ @ Override
737+ public void orchestrateStart (String vmUuid , Map <VirtualMachineProfile .Param , Object > params , DeploymentPlan planToDeploy , DeploymentPlanner planner )
738+ throws InsufficientCapacityException , ConcurrentOperationException , ResourceUnavailableException {
739+
737740 CallContext cctxt = CallContext .current ();
738741 Account account = cctxt .getCallingAccount ();
739742 User caller = cctxt .getCallingUser ();
@@ -848,7 +851,7 @@ private void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Ob
848851 VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl (vm , template , offering , owner , params );
849852 DeployDestination dest = null ;
850853 try {
851- dest = _dpMgr .planDeployment (vmProfile , plan , avoids );
854+ dest = _dpMgr .planDeployment (vmProfile , plan , avoids , planner );
852855 } catch (AffinityConflictException e2 ) {
853856 s_logger .warn ("Unable to create deployment, affinity rules associted to the VM conflict" , e2 );
854857 throw new CloudRuntimeException ("Unable to create deployment, affinity rules associted to the VM conflict" );
@@ -2035,7 +2038,7 @@ protected void cancelWorkItems(long nodeId) {
20352038 }
20362039
20372040 @ Override
2038- public void migrateAway (String vmUuid , long srcHostId ) throws InsufficientServerCapacityException {
2041+ public void migrateAway (String vmUuid , long srcHostId , DeploymentPlanner planner ) throws InsufficientServerCapacityException {
20392042 VMInstanceVO vm = _vmDao .findByUuid (vmUuid );
20402043 if (vm == null ) {
20412044 s_logger .debug ("Unable to find a VM for " + vmUuid );
@@ -2068,7 +2071,7 @@ public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServer
20682071 while (true ) {
20692072
20702073 try {
2071- dest = _dpMgr .planDeployment (profile , plan , excludes );
2074+ dest = _dpMgr .planDeployment (profile , plan , excludes , planner );
20722075 } catch (AffinityConflictException e2 ) {
20732076 s_logger .warn ("Unable to create deployment, affinity rules associted to the VM conflict" , e2 );
20742077 throw new CloudRuntimeException ("Unable to create deployment, affinity rules associted to the VM conflict" );
@@ -3390,7 +3393,7 @@ public void findHostAndMigrate(String vmUuid, Long newSvcOfferingId, ExcludeList
33903393 DeployDestination dest = null ;
33913394
33923395 try {
3393- dest = _dpMgr .planDeployment (profile , plan , excludes );
3396+ dest = _dpMgr .planDeployment (profile , plan , excludes , null );
33943397 } catch (AffinityConflictException e2 ) {
33953398 s_logger .warn ("Unable to create deployment, affinity rules associted to the VM conflict" , e2 );
33963399 throw new CloudRuntimeException ("Unable to create deployment, affinity rules associted to the VM conflict" );
@@ -4714,7 +4717,7 @@ public Pair<JobInfo.Status, String> handleVmWorkJob(AsyncJob job, VmWork work) t
47144717 assert (vm != null );
47154718 if (work instanceof VmWorkStart ) {
47164719 VmWorkStart workStart = (VmWorkStart )work ;
4717- orchestrateStart (vm .getUuid (), workStart .getParams (), workStart .getPlan ());
4720+ orchestrateStart (vm .getUuid (), workStart .getParams (), workStart .getPlan (), null );
47184721 return new Pair <JobInfo .Status , String >(JobInfo .Status .SUCCEEDED , null );
47194722 } else if (work instanceof VmWorkStop ) {
47204723 VmWorkStop workStop = (VmWorkStop )work ;
0 commit comments