use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class ScaleSystemVMCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("SystemVm Id: " + getId());
final ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
}
VirtualMachine result = null;
try {
result = _mgr.upgradeSystemVM(this);
} catch (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (final ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (final ManagementServerException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (final VirtualMachineMigrationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (result != null) {
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class MigrateSystemVMCmd method execute.
@Override
public void execute() {
final Host destinationHost = _resourceService.getHost(getHostId());
if (destinationHost == null) {
throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
}
try {
CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: " + getHostId());
// FIXME : Should not be calling UserVmService to migrate all types of VMs - need a generic VM layer
final VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
if (migratedVm != null) {
// return the generic system VM instance response
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(migratedVm);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm");
}
} catch (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (final ConcurrentOperationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (final ManagementServerException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (final VirtualMachineMigrationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class GetUserCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final UserAccount result = _accountService.getUserByApiKey(getApiKey());
if (result != null) {
final UserResponse response = _responseGenerator.createUserResponse(result);
if (StringUtils.isNotBlank(response.getSecretKey())) {
response.setSecretKey("SecretKey only visible when generating a new key");
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new InvalidParameterValueException("User with specified API key does not exist");
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class StartRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = null;
final VirtualRouter router = _routerService.findRouter(getId());
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
throw new InvalidParameterValueException("Can't find router by id");
} else {
result = _routerService.startRouter(getId());
}
if (result != null) {
final DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
setResponseObject(routerResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class StopRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = null;
final VirtualRouter router = _routerService.findRouter(getId());
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
throw new InvalidParameterValueException("Can't find router by id");
} else {
result = _routerService.stopRouter(getId(), isForced());
}
if (result != null) {
final DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
}
}
Aggregations