use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class AddNetworkDeviceCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
try {
final Host device = nwDeviceMgr.addNetworkDevice(this);
final NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
response.setObjectName("networkdevice");
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (final InvalidParameterValueException ipve) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (final CloudRuntimeException cre) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class UpdateClusterCmd method execute.
@Override
public void execute() {
final Cluster cluster = _resourceService.getCluster(getId());
if (cluster == null) {
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
}
final Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate());
if (result != null) {
final ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
clusterResponse.setResponseName(getCommandName());
this.setResponseObject(clusterResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update cluster");
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class ListHostsCmd method getDetails.
public EnumSet<HostDetails> getDetails() throws InvalidParameterValueException {
final EnumSet<HostDetails> dv;
if (viewDetails == null || viewDetails.size() <= 0) {
dv = EnumSet.of(HostDetails.all);
} else {
try {
final ArrayList<HostDetails> dc = new ArrayList<>();
for (final String detail : viewDetails) {
dc.add(HostDetails.valueOf(detail));
}
dv = EnumSet.copyOf(dc);
} catch (final IllegalArgumentException e) {
throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(HostDetails.class));
}
}
return dv;
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class UpdateNetworkCmdByAdmin method execute.
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException {
final User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId());
final Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId());
final Network network = _networkService.getNetwork(id);
if (network == null) {
throw new InvalidParameterValueException("Couldn't find network by id");
}
final Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId(), getDns1(), getDns2(), getIpExclusionList());
if (result != null) {
final NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network");
}
}
use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.
the class CreateNetworkOfferingCmd method getServiceCapabilities.
public Map<Capability, String> getServiceCapabilities(final Service service) {
Map<Capability, String> capabilityMap = null;
if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
capabilityMap = new HashMap<>();
final Collection serviceCapabilityCollection = serviceCapabilitystList.values();
final Iterator iter = serviceCapabilityCollection.iterator();
while (iter.hasNext()) {
final HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
Capability capability = null;
final String svc = svcCapabilityMap.get("service");
final String capabilityName = svcCapabilityMap.get("capabilitytype");
final String capabilityValue = svcCapabilityMap.get("capabilityvalue");
if (capabilityName != null) {
capability = Capability.getCapability(capabilityName);
}
if ((capability == null) || (capabilityName == null) || (capabilityValue == null)) {
throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
}
if (svc.equalsIgnoreCase(service.getName())) {
capabilityMap.put(capability, capabilityValue);
} else {
// throw new InvalidParameterValueException("Service is not equal ")
}
}
}
return capabilityMap;
}
Aggregations