mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
bug 5747: Added action events for system Vms commands
status 5747: resolved fixed
This commit is contained in:
parent
44d60576f9
commit
0b9fa1cc8a
@ -49,9 +49,15 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_START;
|
||||
VirtualMachine.Type type = _mgr.findSystemVMTypeById(getId());
|
||||
if(type == VirtualMachine.Type.ConsoleProxy){
|
||||
return EventTypes.EVENT_PROXY_DESTROY;
|
||||
}
|
||||
else{
|
||||
return EventTypes.EVENT_SSVM_DESTROY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "destroying system vm: " + getId();
|
||||
@ -69,6 +75,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Vm Id: "+getId());
|
||||
VirtualMachine instance = _mgr.destroySystemVM(this);
|
||||
if (instance != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
|
||||
|
||||
@ -75,7 +75,13 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_REBOOT;
|
||||
VirtualMachine.Type type = _mgr.findSystemVMTypeById(getId());
|
||||
if(type == VirtualMachine.Type.ConsoleProxy){
|
||||
return EventTypes.EVENT_PROXY_REBOOT;
|
||||
}
|
||||
else{
|
||||
return EventTypes.EVENT_SSVM_REBOOT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,6 +99,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Vm Id: "+getId());
|
||||
VirtualMachine result = _mgr.rebootSystemVM(this);
|
||||
if (result != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||
|
||||
@ -79,7 +79,13 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_START;
|
||||
VirtualMachine.Type type = _mgr.findSystemVMTypeById(getId());
|
||||
if(type == VirtualMachine.Type.ConsoleProxy){
|
||||
return EventTypes.EVENT_PROXY_START;
|
||||
}
|
||||
else{
|
||||
return EventTypes.EVENT_SSVM_START;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,6 +103,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Vm Id: "+getId());
|
||||
VirtualMachine instance = _mgr.startSystemVM(this);
|
||||
if (instance != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
|
||||
|
||||
@ -80,7 +80,13 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SSVM_STOP;
|
||||
VirtualMachine.Type type = _mgr.findSystemVMTypeById(getId());
|
||||
if(type == VirtualMachine.Type.ConsoleProxy){
|
||||
return EventTypes.EVENT_PROXY_STOP;
|
||||
}
|
||||
else{
|
||||
return EventTypes.EVENT_SSVM_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,6 +110,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
UserContext.current().setEventDetails("Vm Id: "+getId());
|
||||
VirtualMachine result = _mgr.stopSystemVM(this);
|
||||
if (result != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||
|
||||
@ -105,6 +105,7 @@ import com.cloud.user.UserAccount;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
|
||||
/**
|
||||
* Hopefull this is temporary.
|
||||
@ -425,4 +426,6 @@ public interface ManagementService {
|
||||
*/
|
||||
String getVMPassword(GetVMPasswordCmd cmd);
|
||||
|
||||
Type findSystemVMTypeById(long instanceId);
|
||||
|
||||
}
|
||||
|
||||
@ -30,8 +30,11 @@ import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
@ -365,7 +368,7 @@ public interface ManagementServer extends ManagementService {
|
||||
|
||||
ConsoleProxyInfo getConsoleProxy(long dataCenterId, long userVmId);
|
||||
ConsoleProxyVO startConsoleProxy(long instanceId);
|
||||
ConsoleProxyVO stopConsoleProxy(long instanceId);
|
||||
ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
ConsoleProxyVO rebootConsoleProxy(long instanceId);
|
||||
String getConsoleAccessUrlRoot(long vmId);
|
||||
ConsoleProxyVO findConsoleProxyById(long instanceId);
|
||||
|
||||
@ -2721,23 +2721,29 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return _consoleProxyMgr.assignProxy(dataCenterId, userVmId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_PROXY_START, eventDescription="starting console proxy Vm", async=true)
|
||||
public ConsoleProxyVO startConsoleProxy(long instanceId) {
|
||||
return _consoleProxyMgr.startProxy(instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO stopConsoleProxy(long instanceId) {
|
||||
_consoleProxyMgr.stopProxy(instanceId);
|
||||
return _consoleProxyDao.findById(instanceId);
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_PROXY_STOP, eventDescription="stopping console proxy Vm", async=true)
|
||||
public ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
|
||||
User caller = _userDao.findById(UserContext.current().getCallerUserId());
|
||||
|
||||
if (_itMgr.advanceStop(systemVm, isForced, caller, UserContext.current().getCaller())) {
|
||||
return _consoleProxyDao.findById(systemVm.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_PROXY_REBOOT, eventDescription="rebooting console proxy Vm", async=true)
|
||||
public ConsoleProxyVO rebootConsoleProxy(long instanceId) {
|
||||
_consoleProxyMgr.rebootProxy(instanceId);
|
||||
return _consoleProxyDao.findById(instanceId);
|
||||
}
|
||||
|
||||
@ActionEvent (eventType=EventTypes.EVENT_PROXY_DESTROY, eventDescription="destroying console proxy Vm", async=true)
|
||||
public ConsoleProxyVO destroyConsoleProxy(long instanceId) {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(instanceId);
|
||||
|
||||
@ -3881,20 +3887,29 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return _domainDao.isChildDomain(parentId, childId);
|
||||
}
|
||||
|
||||
@ActionEvent (eventType=EventTypes.EVENT_SSVM_START, eventDescription="starting secondary storage Vm", async=true)
|
||||
public SecondaryStorageVmVO startSecondaryStorageVm(long instanceId) {
|
||||
return _secStorageVmMgr.startSecStorageVm(instanceId);
|
||||
}
|
||||
|
||||
public SecondaryStorageVmVO stopSecondaryStorageVm(long instanceId) {
|
||||
_secStorageVmMgr.stopSecStorageVm(instanceId);
|
||||
return _secStorageVmDao.findById(instanceId);
|
||||
@ActionEvent (eventType=EventTypes.EVENT_SSVM_STOP, eventDescription="stopping secondary storage Vm", async=true)
|
||||
public SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
|
||||
User caller = _userDao.findById(UserContext.current().getCallerUserId());
|
||||
|
||||
if (_itMgr.advanceStop(systemVm, isForced, caller, UserContext.current().getCaller())) {
|
||||
return _secStorageVmDao.findById(systemVm.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ActionEvent (eventType=EventTypes.EVENT_SSVM_REBOOT, eventDescription="rebooting secondary storage Vm", async=true)
|
||||
public SecondaryStorageVmVO rebootSecondaryStorageVm(long instanceId) {
|
||||
_secStorageVmMgr.rebootSecStorageVm(instanceId);
|
||||
return _secStorageVmDao.findById(instanceId);
|
||||
}
|
||||
|
||||
@ActionEvent (eventType=EventTypes.EVENT_SSVM_DESTROY, eventDescription="destroying secondary storage Vm", async=true)
|
||||
public SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) {
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(instanceId);
|
||||
if(_secStorageVmMgr.destroySecStorageVm(instanceId)) {
|
||||
@ -3986,6 +4001,15 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
return _secStorageVmDao.findById(instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine.Type findSystemVMTypeById(long instanceId) {
|
||||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(instanceId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if(systemVm == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a system vm: " + instanceId);
|
||||
}
|
||||
return systemVm.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine startSystemVM(StartSystemVMCmd cmd) {
|
||||
@ -4019,16 +4043,12 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
throw new InvalidParameterValueException("unable to find a system vm with id " + id);
|
||||
}
|
||||
|
||||
User caller = _userDao.findById(UserContext.current().getCallerUserId());
|
||||
|
||||
try {
|
||||
if (_itMgr.advanceStop(systemVm, cmd.isForced(), caller, UserContext.current().getCaller())) {
|
||||
if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
return _consoleProxyDao.findById(systemVm.getId());
|
||||
} else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
return _secStorageVmDao.findById(systemVm.getId());
|
||||
}
|
||||
}
|
||||
if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
return stopConsoleProxy(systemVm, cmd.isForced());
|
||||
} else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
return stopSecondaryStorageVm(systemVm, cmd.isForced());
|
||||
}
|
||||
return null;
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Unable to stop " + systemVm, e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user