@@ -760,8 +760,9 @@ public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object>
760760 try {
761761 orchestrateStart (vmUuid , params , planToDeploy , planner );
762762 } finally {
763- if (VmJobEnabled . value ())
763+ if (placeHolder != null ) {
764764 _workJobDao .expunge (placeHolder .getId ());
765+ }
765766 }
766767 } else {
767768 Outcome <VirtualMachine > outcome = startVmThroughJobQueue (vmUuid , params , planToDeploy );
@@ -1311,8 +1312,9 @@ public void advanceStop(String vmUuid, boolean cleanUpEvenIfUnableToStop)
13111312 try {
13121313 orchestrateStop (vmUuid , cleanUpEvenIfUnableToStop );
13131314 } finally {
1314- if (VmJobEnabled . value ())
1315+ if (placeHolder != null ) {
13151316 _workJobDao .expunge (placeHolder .getId ());
1317+ }
13161318 }
13171319
13181320 } else {
@@ -1405,7 +1407,7 @@ private void advanceStop(VMInstanceVO vm, boolean cleanUpEvenIfUnableToStop) thr
14051407 if (s_logger .isDebugEnabled ()) {
14061408 s_logger .debug ("Unable to transition the state but we're moving on because it's forced stop" );
14071409 }
1408- if (state == State .Starting || state == State .Migrating ) {
1410+ if (( state == State .Starting ) || ( state == State .Migrating ) || ( state == State . Stopping ) ) {
14091411 if (work != null ) {
14101412 doCleanup = true ;
14111413 } else {
@@ -1414,8 +1416,6 @@ private void advanceStop(VMInstanceVO vm, boolean cleanUpEvenIfUnableToStop) thr
14141416 }
14151417 throw new CloudRuntimeException ("Work item not found, We cannot stop " + vm + " when it is in state " + vm .getState ());
14161418 }
1417- } else if (state == State .Stopping ) {
1418- doCleanup = true ;
14191419 }
14201420
14211421 if (doCleanup ) {
@@ -1619,8 +1619,9 @@ public void storageMigration(String vmUuid, StoragePool destPool) {
16191619 try {
16201620 orchestrateStorageMigration (vmUuid , destPool );
16211621 } finally {
1622- if (VmJobEnabled . value ())
1622+ if (placeHolder != null ) {
16231623 _workJobDao .expunge (placeHolder .getId ());
1624+ }
16241625 }
16251626 } else {
16261627 Outcome <VirtualMachine > outcome = migrateVmStorageThroughJobQueue (vmUuid , destPool );
@@ -1711,8 +1712,9 @@ public void migrate(String vmUuid, long srcHostId, DeployDestination dest)
17111712 try {
17121713 orchestrateMigrate (vmUuid , srcHostId , dest );
17131714 } finally {
1714- if (VmJobEnabled . value ())
1715+ if (placeHolder != null ) {
17151716 _workJobDao .expunge (placeHolder .getId ());
1717+ }
17161718 }
17171719 } else {
17181720 Outcome <VirtualMachine > outcome = migrateVmThroughJobQueue (vmUuid , srcHostId , dest );
@@ -1993,8 +1995,9 @@ public void migrateWithStorage(String vmUuid, long srcHostId, long destHostId, M
19931995 try {
19941996 orchestrateMigrateWithStorage (vmUuid , srcHostId , destHostId , volumeToPool );
19951997 } finally {
1996- if (VmJobEnabled . value ())
1998+ if (placeHolder != null ) {
19971999 _workJobDao .expunge (placeHolder .getId ());
2000+ }
19982001 }
19992002
20002003 } else {
@@ -2289,8 +2292,9 @@ public void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object
22892292 try {
22902293 orchestrateReboot (vmUuid , params );
22912294 } finally {
2292- if (VmJobEnabled . value ())
2295+ if (placeHolder != null ) {
22932296 _workJobDao .expunge (placeHolder .getId ());
2297+ }
22942298 }
22952299 } else {
22962300 Outcome <VirtualMachine > outcome = rebootVmThroughJobQueue (vmUuid , params );
@@ -3104,12 +3108,11 @@ protected class AgentVmInfo {
31043108 public String platform ;
31053109
31063110
3107- @ SuppressWarnings ("unchecked" )
31083111 public AgentVmInfo (String name , VMInstanceVO vm , State state , String host , String platform ) {
31093112 this .name = name ;
31103113 this .state = state ;
31113114 this .vm = vm ;
3112- hostUuid = host ;
3115+ this . hostUuid = host ;
31133116 this .platform = platform ;
31143117
31153118 }
@@ -3224,8 +3227,9 @@ public NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile
32243227 try {
32253228 return orchestrateAddVmToNetwork (vm , network , requested );
32263229 } finally {
3227- if (VmJobEnabled . value ())
3230+ if (placeHolder != null ) {
32283231 _workJobDao .expunge (placeHolder .getId ());
3232+ }
32293233 }
32303234 } else {
32313235 Outcome <VirtualMachine > outcome = addVmToNetworkThroughJobQueue (vm , network , requested );
@@ -3235,7 +3239,7 @@ public NicProfile addVmToNetwork(VirtualMachine vm, Network network, NicProfile
32353239 } catch (InterruptedException e ) {
32363240 throw new RuntimeException ("Operation is interrupted" , e );
32373241 } catch (java .util .concurrent .ExecutionException e ) {
3238- throw new RuntimeException ("Execution excetion " , e );
3242+ throw new RuntimeException ("Execution exception " , e );
32393243 }
32403244
32413245 Object jobException = _jobMgr .unmarshallResultObject (outcome .getJob ());
@@ -3336,8 +3340,9 @@ public boolean removeNicFromVm(VirtualMachine vm, Nic nic)
33363340 try {
33373341 return orchestrateRemoveNicFromVm (vm , nic );
33383342 } finally {
3339- if (VmJobEnabled . value ())
3343+ if (placeHolder != null ) {
33403344 _workJobDao .expunge (placeHolder .getId ());
3345+ }
33413346 }
33423347
33433348 } else {
@@ -3583,8 +3588,9 @@ public void migrateForScale(String vmUuid, long srcHostId, DeployDestination des
35833588 try {
35843589 orchestrateMigrateForScale (vmUuid , srcHostId , dest , oldSvcOfferingId );
35853590 } finally {
3586- if (VmJobEnabled . value ())
3591+ if (placeHolder != null ) {
35873592 _workJobDao .expunge (placeHolder .getId ());
3593+ }
35883594 }
35893595 } else {
35903596 Outcome <VirtualMachine > outcome = migrateVmForScaleThroughJobQueue (vmUuid , srcHostId , dest , oldSvcOfferingId );
@@ -3842,8 +3848,9 @@ public VMInstanceVO reConfigureVm(String vmUuid, ServiceOffering oldServiceOffer
38423848 try {
38433849 return orchestrateReConfigureVm (vmUuid , oldServiceOffering , reconfiguringOnExistingHost );
38443850 } finally {
3845- if (VmJobEnabled . value ())
3851+ if (placeHolder != null ) {
38463852 _workJobDao .expunge (placeHolder .getId ());
3853+ }
38473854 }
38483855 } else {
38493856 Outcome <VirtualMachine > outcome = reconfigureVmThroughJobQueue (vmUuid , oldServiceOffering , reconfiguringOnExistingHost );
@@ -3894,7 +3901,7 @@ private VMInstanceVO orchestrateReConfigureVm(String vmUuid, ServiceOffering old
38943901 work .setStep (Step .Prepare );
38953902 work .setResourceType (ItWorkVO .ResourceType .Host );
38963903 work .setResourceId (vm .getHostId ());
3897- work = _workDao .persist (work );
3904+ _workDao .persist (work );
38983905 boolean success = false ;
38993906 try {
39003907 if (reconfiguringOnExistingHost ) {
@@ -3916,8 +3923,6 @@ private VMInstanceVO orchestrateReConfigureVm(String vmUuid, ServiceOffering old
39163923 } catch (AgentUnavailableException e ) {
39173924 throw e ;
39183925 } finally {
3919- // work.setStep(Step.Done);
3920- //_workDao.update(work.getId(), work);
39213926 if (!success ) {
39223927 _capacityMgr .releaseVmCapacity (vm , false , false , vm .getHostId ()); // release the new capacity
39233928 vm .setServiceOfferingId (oldServiceOffering .getId ());
0 commit comments