private boolean startNewVM(long vmId) { try { CallContext.current().setEventDetails("Vm Id: " + vmId); _userVmManager.startVirtualMachine(vmId, null, null, null); } catch (final ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); if (ex instanceof InsufficientServerCapacityException) { if (((InsufficientServerCapacityException)ex).isAffinityApplied()) { message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); } } s_logger.info(ex); s_logger.info(message.toString(), ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); } return true; }
public boolean add(InsufficientCapacityException e) { Class<?> scope = e.getScope(); if (scope == null) { return false; } if (Host.class.isAssignableFrom(scope)) { addHost(e.getId()); } else if (Pod.class.isAssignableFrom(scope)) { addPod(e.getId()); } else if (DataCenter.class.isAssignableFrom(scope)) { addDataCenter(e.getId()); } else if (Cluster.class.isAssignableFrom(scope)) { addCluster(e.getId()); } else if (StoragePool.class.isAssignableFrom(scope)) { addPool(e.getId()); } else { return false; } return true; }
@Override public Map<String,Object> deployNetscalerServiceVm(DeployNetscalerVpxCmd cmd) { DataCenter zone = _dcDao.findById(cmd.getZoneId()); DeployDestination dest = new DeployDestination(zone, null, null, null); Map<String,Object> resp = new HashMap<String, Object>(); Long templateId = cmd.getTemplateId(); Long serviceOfferingId = cmd.getServiceOfferingId(); DeploymentPlan plan = new DataCenterDeployment(dest.getDataCenter().getId()); try { resp = _netScalerVMManager.deployNsVpx(cmd.getAccount(), dest, plan, serviceOfferingId, templateId); } catch (InsufficientCapacityException e) { e.printStackTrace(); } return resp; }
@Override public Map<String,Object> deployNetscalerServiceVm(DeployNetscalerVpxCmd cmd) { DataCenter zone = _dcDao.findById(cmd.getZoneId()); DeployDestination dest = new DeployDestination(zone, null, null, null); VMInstanceVO vmvo = null; Map<String,Object> resp = new HashMap<String, Object>(); Long templateId = cmd.getTemplateId(); Long serviceOfferingId = cmd.getServiceOfferingId(); DeploymentPlan plan = new DataCenterDeployment(dest.getDataCenter().getId()); try { resp = deployNsVpx(cmd.getAccount(), dest, plan, serviceOfferingId, templateId); } catch (InsufficientCapacityException e) { e.printStackTrace(); } return resp; }
@Override public void create() throws ResourceAllocationException { try { UserVm vm = _userVmService.createVirtualMachine(this); if (vm != null) { setEntityId(vm.getId()); setEntityUuid(vm.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm"); } } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex.getMessage(), ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (ResourceAllocationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage()); } } }
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); if (ex instanceof InsufficientServerCapacityException) { if (((InsufficientServerCapacityException) ex).isAffinityApplied()) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); if (ex instanceof InsufficientServerCapacityException) { if (((InsufficientServerCapacityException)ex).isAffinityApplied()) {
@Override public void execute() throws ResourceUnavailableException, ResourceAllocationException { try { Vlan result = _configService.createVlanAndPublicIpRange(this); if (result != null) { VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vlan ip range"); } } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } } }
@Override public void execute() { try { final boolean result = _vpcService.restartVpc(getId(), getCleanup(), getMakeredundant()); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart VPC"); } } 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 InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } }
throw new ServerApiException(ApiErrorCode.ACCOUNT_RESOURCE_LIMIT_ERROR, ex.getMessage(), ex); } catch (final InsufficientCapacityException ex) { s_logger.info(ex.getMessage()); String errorMsg = ex.getMessage(); if (!accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); if (ex instanceof InsufficientServerCapacityException) { if(((InsufficientServerCapacityException)ex).isAffinityApplied()){
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { StringBuilder message = new StringBuilder(ex.getMessage()); if (ex instanceof InsufficientServerCapacityException) { if (((InsufficientServerCapacityException)ex).isAffinityApplied()) {
@Override public void execute() { Vpc vpc = null; try { if (isStart()) { _vpcService.startVpc(getEntityId(), true); } else { s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API"); } vpc = _entityMgr.findById(Vpc.class, getEntityId()); } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } if (vpc != null) { VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC"); } }
s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
@Override public void create() throws ResourceAllocationException { PrivateGateway result = null; try { result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(), getBroadcastUri(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getNetworkOfferingId(), getIsSourceNat(), getAclId()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } if (result != null) { setEntityId(result.getId()); setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway"); } }
s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
s_logger.trace(ex.getMessage(), ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex);