Search in sources :

Example 1 with InvalidParameterValueException

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());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NetworkDeviceResponse(com.cloud.api.response.NetworkDeviceResponse) Host(com.cloud.host.Host)

Example 2 with InvalidParameterValueException

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");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Cluster(com.cloud.org.Cluster) ClusterResponse(com.cloud.api.response.ClusterResponse)

Example 3 with InvalidParameterValueException

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;
}
Also used : InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) HostDetails(com.cloud.api.ApiConstants.HostDetails) ArrayList(java.util.ArrayList)

Example 4 with InvalidParameterValueException

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");
    }
}
Also used : Account(com.cloud.user.Account) User(com.cloud.user.User) ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Network(com.cloud.network.Network) NetworkResponse(com.cloud.api.response.NetworkResponse)

Example 5 with InvalidParameterValueException

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;
}
Also used : Capability(com.cloud.network.Network.Capability) HashMap(java.util.HashMap) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Iterator(java.util.Iterator) Collection(java.util.Collection)

Aggregations

InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)478 Account (com.cloud.user.Account)199 ActionEvent (com.cloud.event.ActionEvent)151 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)146 ArrayList (java.util.ArrayList)104 DB (com.cloud.utils.db.DB)97 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)72 List (java.util.List)61 TransactionStatus (com.cloud.utils.db.TransactionStatus)57 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)53 ServerApiException (com.cloud.api.ServerApiException)46 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)44 Network (com.cloud.network.Network)40 Pair (com.cloud.utils.Pair)36 HashMap (java.util.HashMap)36 ConfigurationException (javax.naming.ConfigurationException)36 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)33 NetworkVO (com.cloud.network.dao.NetworkVO)31 HostVO (com.cloud.host.HostVO)30 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)30