@@ -2721,23 +2721,29 @@ public ConsoleProxyInfo getConsoleProxy(long dataCenterId, long userVmId) {
27212721 return _consoleProxyMgr .assignProxy (dataCenterId , userVmId );
27222722 }
27232723
2724- @ Override
2724+ @ Override @ ActionEvent ( eventType = EventTypes . EVENT_PROXY_START , eventDescription = "starting console proxy Vm" , async = true )
27252725 public ConsoleProxyVO startConsoleProxy (long instanceId ) {
27262726 return _consoleProxyMgr .startProxy (instanceId );
27272727 }
27282728
2729- @ Override
2730- public ConsoleProxyVO stopConsoleProxy (long instanceId ) {
2731- _consoleProxyMgr .stopProxy (instanceId );
2732- return _consoleProxyDao .findById (instanceId );
2729+ @ Override @ ActionEvent (eventType =EventTypes .EVENT_PROXY_STOP , eventDescription ="stopping console proxy Vm" , async =true )
2730+ public ConsoleProxyVO stopConsoleProxy (VMInstanceVO systemVm , boolean isForced ) throws ResourceUnavailableException , OperationTimedoutException , ConcurrentOperationException {
2731+
2732+ User caller = _userDao .findById (UserContext .current ().getCallerUserId ());
2733+
2734+ if (_itMgr .advanceStop (systemVm , isForced , caller , UserContext .current ().getCaller ())) {
2735+ return _consoleProxyDao .findById (systemVm .getId ());
2736+ }
2737+ return null ;
27332738 }
27342739
2735- @ Override
2740+ @ Override @ ActionEvent ( eventType = EventTypes . EVENT_PROXY_REBOOT , eventDescription = "rebooting console proxy Vm" , async = true )
27362741 public ConsoleProxyVO rebootConsoleProxy (long instanceId ) {
27372742 _consoleProxyMgr .rebootProxy (instanceId );
27382743 return _consoleProxyDao .findById (instanceId );
27392744 }
27402745
2746+ @ ActionEvent (eventType =EventTypes .EVENT_PROXY_DESTROY , eventDescription ="destroying console proxy Vm" , async =true )
27412747 public ConsoleProxyVO destroyConsoleProxy (long instanceId ) {
27422748 ConsoleProxyVO proxy = _consoleProxyDao .findById (instanceId );
27432749
@@ -3881,20 +3887,29 @@ public boolean isChildDomain(Long parentId, Long childId) {
38813887 return _domainDao .isChildDomain (parentId , childId );
38823888 }
38833889
3890+ @ ActionEvent (eventType =EventTypes .EVENT_SSVM_START , eventDescription ="starting secondary storage Vm" , async =true )
38843891 public SecondaryStorageVmVO startSecondaryStorageVm (long instanceId ) {
38853892 return _secStorageVmMgr .startSecStorageVm (instanceId );
38863893 }
38873894
3888- public SecondaryStorageVmVO stopSecondaryStorageVm (long instanceId ) {
3889- _secStorageVmMgr .stopSecStorageVm (instanceId );
3890- return _secStorageVmDao .findById (instanceId );
3895+ @ ActionEvent (eventType =EventTypes .EVENT_SSVM_STOP , eventDescription ="stopping secondary storage Vm" , async =true )
3896+ public SecondaryStorageVmVO stopSecondaryStorageVm (VMInstanceVO systemVm , boolean isForced ) throws ResourceUnavailableException , OperationTimedoutException , ConcurrentOperationException {
3897+
3898+ User caller = _userDao .findById (UserContext .current ().getCallerUserId ());
3899+
3900+ if (_itMgr .advanceStop (systemVm , isForced , caller , UserContext .current ().getCaller ())) {
3901+ return _secStorageVmDao .findById (systemVm .getId ());
3902+ }
3903+ return null ;
38913904 }
38923905
3906+ @ ActionEvent (eventType =EventTypes .EVENT_SSVM_REBOOT , eventDescription ="rebooting secondary storage Vm" , async =true )
38933907 public SecondaryStorageVmVO rebootSecondaryStorageVm (long instanceId ) {
38943908 _secStorageVmMgr .rebootSecStorageVm (instanceId );
38953909 return _secStorageVmDao .findById (instanceId );
38963910 }
38973911
3912+ @ ActionEvent (eventType =EventTypes .EVENT_SSVM_DESTROY , eventDescription ="destroying secondary storage Vm" , async =true )
38983913 public SecondaryStorageVmVO destroySecondaryStorageVm (long instanceId ) {
38993914 SecondaryStorageVmVO secStorageVm = _secStorageVmDao .findById (instanceId );
39003915 if (_secStorageVmMgr .destroySecStorageVm (instanceId )) {
@@ -3986,6 +4001,15 @@ public VMInstanceVO findSystemVMById(long instanceId) {
39864001 }
39874002 return _secStorageVmDao .findById (instanceId );
39884003 }
4004+
4005+ @ Override
4006+ public VirtualMachine .Type findSystemVMTypeById (long instanceId ) {
4007+ VMInstanceVO systemVm = _vmInstanceDao .findByIdTypes (instanceId , VirtualMachine .Type .ConsoleProxy , VirtualMachine .Type .SecondaryStorageVm );
4008+ if (systemVm == null ) {
4009+ throw new InvalidParameterValueException ("Unable to find a system vm: " + instanceId );
4010+ }
4011+ return systemVm .getType ();
4012+ }
39894013
39904014 @ Override
39914015 public VirtualMachine startSystemVM (StartSystemVMCmd cmd ) {
@@ -4019,16 +4043,12 @@ public VMInstanceVO stopSystemVM(StopSystemVmCmd cmd) throws ResourceUnavailable
40194043 throw new InvalidParameterValueException ("unable to find a system vm with id " + id );
40204044 }
40214045
4022- User caller = _userDao .findById (UserContext .current ().getCallerUserId ());
4023-
40244046 try {
4025- if (_itMgr .advanceStop (systemVm , cmd .isForced (), caller , UserContext .current ().getCaller ())) {
4026- if (systemVm .getType () == VirtualMachine .Type .ConsoleProxy ) {
4027- return _consoleProxyDao .findById (systemVm .getId ());
4028- } else if (systemVm .getType () == VirtualMachine .Type .SecondaryStorageVm ) {
4029- return _secStorageVmDao .findById (systemVm .getId ());
4030- }
4031- }
4047+ if (systemVm .getType () == VirtualMachine .Type .ConsoleProxy ) {
4048+ return stopConsoleProxy (systemVm , cmd .isForced ());
4049+ } else if (systemVm .getType () == VirtualMachine .Type .SecondaryStorageVm ) {
4050+ return stopSecondaryStorageVm (systemVm , cmd .isForced ());
4051+ }
40324052 return null ;
40334053 } catch (OperationTimedoutException e ) {
40344054 throw new CloudRuntimeException ("Unable to stop " + systemVm , e );
0 commit comments