@Override public VMInstanceVO rebootSystemVM(final RebootSystemVmCmd cmd) { final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); ex.addProxyObject(cmd.getId().toString(), "vmId"); throw ex; } if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_REBOOT, "rebooting console proxy Vm"); return rebootConsoleProxy(cmd.getId()); } else { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_REBOOT, "rebooting secondary storage Vm"); return rebootSecondaryStorageVm(cmd.getId()); } }
@Override @ActionEvent(eventType = "", eventDescription = "", async = true) public VMInstanceVO destroySystemVM(final DestroySystemVmCmd cmd) { final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); ex.addProxyObject(cmd.getId().toString(), "vmId"); throw ex; } if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_DESTROY, "destroying console proxy Vm"); return destroyConsoleProxy(cmd.getId()); } else { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_DESTROY, "destroying secondary storage Vm"); return destroySecondaryStorageVm(cmd.getId()); } }
@Override @ActionEvent(eventType = "", eventDescription = "", async = true) public VirtualMachine startSystemVM(final long vmId) { final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); ex.addProxyObject(String.valueOf(vmId), "vmId"); throw ex; } if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_START, "starting console proxy Vm"); return startConsoleProxy(vmId); } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_START, "starting secondary storage Vm"); return startSecondaryStorageVm(vmId); } else { final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm with specified vmId"); ex.addProxyObject(systemVm.getUuid(), "vmId"); throw ex; } }
@Override @ActionEvent(eventType = "", eventDescription = "", async = true) public VMInstanceVO stopSystemVM(final StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException { final Long id = cmd.getId(); // verify parameters final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); if (systemVm == null) { final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId"); ex.addProxyObject(id.toString(), "vmId"); throw ex; } try { if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_STOP, "stopping console proxy Vm"); return stopConsoleProxy(systemVm, cmd.isForced()); } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) { ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm"); return stopSecondaryStorageVm(systemVm, cmd.isForced()); } return null; } catch (final OperationTimedoutException e) { throw new CloudRuntimeException("Unable to stop " + systemVm, e); } }