@@ -632,7 +632,7 @@ public ConsoleProxyVO start(long proxyId, long startEventId) throws Insufficient
632632 }
633633 }
634634 // to ensure atomic state transition to Starting state
635- if (!_consoleProxyDao . updateIf (proxy , com .cloud .vm .VirtualMachine .Event .StartRequested , routingHost .getId ())) {
635+ if (!_itMgr . stateTransitTo (proxy , com .cloud .vm .VirtualMachine .Event .StartRequested , routingHost .getId ())) {
636636 if (s_logger .isDebugEnabled ()) {
637637 ConsoleProxyVO temp = _consoleProxyDao .findById (proxyId );
638638 s_logger .debug ("Unable to start console proxy " + proxy .getHostName () + " because it is not in a startable state : "
@@ -664,7 +664,7 @@ public ConsoleProxyVO start(long proxyId, long startEventId) throws Insufficient
664664 String guestIpAddress = _dcDao .allocateLinkLocalIpAddress (proxy .getDataCenterId (), routingHost .getPodId (), proxy .getId (), null );
665665 proxy .setGuestIpAddress (guestIpAddress );
666666
667- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .OperationRetry , routingHost .getId ());
667+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .OperationRetry , routingHost .getId ());
668668 proxy = _consoleProxyDao .findById (proxy .getId ());
669669
670670 List <VolumeVO > vols = _storageMgr .prepare (proxy , routingHost );
@@ -768,7 +768,7 @@ public ConsoleProxyVO start(long proxyId, long startEventId) throws Insufficient
768768 throw new ExecutionException ("Couldn't find a routingHost to run console proxy" );
769769 }
770770
771- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .OperationSucceeded , routingHost .getId ());
771+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .OperationSucceeded , routingHost .getId ());
772772 if (s_logger .isDebugEnabled ()) {
773773 s_logger .debug ("Console proxy is now started, vm id : " + proxy .getId ());
774774 }
@@ -817,7 +817,7 @@ public ConsoleProxyVO start(long proxyId, long startEventId) throws Insufficient
817817 freePrivateIpAddress (privateIpAddress , proxy .getDataCenterId (), proxy .getId ());
818818 }
819819
820- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .OperationFailed , null );
820+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .OperationFailed , null );
821821 txn .commit ();
822822 } catch (Exception e ) {
823823 s_logger .error ("Caught exception during error recovery" );
@@ -1120,7 +1120,7 @@ protected ConsoleProxyVO allocProxyStorage(long dataCenterId, long proxyVmId) {
11201120 _consoleProxyDao .update (proxy .getId (), vo );
11211121
11221122 // kick the state machine
1123- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .OperationSucceeded , null );
1123+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .OperationSucceeded , null );
11241124
11251125 txn .commit ();
11261126 return proxy ;
@@ -1788,7 +1788,7 @@ public Command cleanup(ConsoleProxyVO vm, String vmName) {
17881788
17891789 @ Override
17901790 public void completeStartCommand (ConsoleProxyVO vm ) {
1791- _consoleProxyDao . updateIf (vm , VirtualMachine .Event .AgentReportRunning , vm .getHostId ());
1791+ _itMgr . stateTransitTo (vm , VirtualMachine .Event .AgentReportRunning , vm .getHostId ());
17921792 }
17931793
17941794 @ Override
@@ -1812,7 +1812,7 @@ protected void completeStopCommand(ConsoleProxyVO proxy, VirtualMachine.Event ev
18121812 _dcDao .releaseLinkLocalIpAddress (guestIpAddress , proxy .getDataCenterId (), proxy .getId ());
18131813 }
18141814
1815- if (!_consoleProxyDao . updateIf (proxy , ev , null )) {
1815+ if (!_itMgr . stateTransitTo (proxy , ev , null )) {
18161816 s_logger .debug ("Unable to update the console proxy" );
18171817 return ;
18181818 }
@@ -1969,7 +1969,7 @@ public boolean destroyProxy(long vmId, long startEventId) {
19691969 s_logger .debug ("Destroying console proxy vm " + vmId );
19701970 }
19711971
1972- if (!_consoleProxyDao . updateIf (vm , VirtualMachine .Event .DestroyRequested , null )) {
1972+ if (!_itMgr . stateTransitTo (vm , VirtualMachine .Event .DestroyRequested , null )) {
19731973 s_logger .debug ("Unable to destroy the vm because it is not in the correct state: " + vmId );
19741974 return false ;
19751975 }
@@ -2050,7 +2050,7 @@ public boolean destroyProxyDBOnly(long vmId) {
20502050
20512051 @ Override
20522052 public boolean stop (ConsoleProxyVO proxy , long startEventId ) throws AgentUnavailableException {
2053- if (!_consoleProxyDao . updateIf (proxy , VirtualMachine .Event .StopRequested , proxy .getHostId ())) {
2053+ if (!_itMgr . stateTransitTo (proxy , VirtualMachine .Event .StopRequested , proxy .getHostId ())) {
20542054 s_logger .debug ("Unable to stop console proxy: " + proxy .toString ());
20552055 return false ;
20562056 }
@@ -2129,7 +2129,7 @@ public boolean stop(ConsoleProxyVO proxy, long startEventId) throws AgentUnavail
21292129 public boolean migrate (ConsoleProxyVO proxy , HostVO host ) {
21302130 HostVO fromHost = _hostDao .findById (proxy .getId ());
21312131
2132- if (!_consoleProxyDao . updateIf (proxy , VirtualMachine .Event .MigrationRequested , proxy .getHostId ())) {
2132+ if (! _itMgr . stateTransitTo (proxy , VirtualMachine .Event .MigrationRequested , proxy .getHostId ())) {
21332133 s_logger .debug ("State for " + proxy .toString () + " has changed so migration can not take place." );
21342134 return false ;
21352135 }
@@ -2152,18 +2152,18 @@ public boolean completeMigration(ConsoleProxyVO proxy, HostVO host) throws Agent
21522152 CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer ) _agentMgr .send (host .getId (), cvm );
21532153 if (!answer .getResult ()) {
21542154 s_logger .debug ("Unable to complete migration for " + proxy .getId ());
2155- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .AgentReportStopped , null );
2155+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .AgentReportStopped , null );
21562156 return false ;
21572157 }
21582158
21592159 State state = answer .getState ();
21602160 if (state == State .Stopped ) {
21612161 s_logger .warn ("Unable to complete migration as we can not detect it on " + host .getId ());
2162- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .AgentReportStopped , null );
2162+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .AgentReportStopped , null );
21632163 return false ;
21642164 }
21652165
2166- _consoleProxyDao . updateIf (proxy , VirtualMachine .Event .OperationSucceeded , host .getId ());
2166+ _itMgr . stateTransitTo (proxy , VirtualMachine .Event .OperationSucceeded , host .getId ());
21672167 return true ;
21682168 }
21692169
0 commit comments