Search in sources :

Example 16 with InvalidParameterValueException

use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.

the class DeleteEventsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    if (ids == null && type == null && endDate == null) {
        throw new InvalidParameterValueException("either ids, type or enddate must be specified");
    } else if (startDate != null && endDate == null) {
        throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
    }
    final boolean result = _mgr.deleteEvents(this);
    if (result) {
        final SuccessResponse response = new SuccessResponse(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Events, one or more parameters has invalid values");
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException)

Example 17 with InvalidParameterValueException

use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.

the class CreateEgressFirewallRuleCmd method getVpcId.

public Long getVpcId() {
    final Network network = _networkService.getNetwork(getNetworkId());
    if (network == null) {
        throw new InvalidParameterValueException("Invalid networkId is given");
    }
    final Long vpcId = network.getVpcId();
    return vpcId;
}
Also used : InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Network(com.cloud.network.Network)

Example 18 with InvalidParameterValueException

use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.

the class CreatePortForwardingRuleCmd method create.

@Override
public void create() {
    // cidr list parameter is deprecated
    if (cidrlist != null) {
        throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
    }
    final Ip privateIp = getVmSecondaryIp();
    if (privateIp != null) {
        if (!NetUtils.isValidIp4(privateIp.toString())) {
            throw new InvalidParameterValueException("Invalid vm ip address");
        }
    }
    try {
        final PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay());
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } catch (final NetworkRuleConflictException ex) {
        s_logger.info("Network rule conflict: ", ex);
        s_logger.trace("Network Rule Conflict: ", ex);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) Ip(com.cloud.utils.net.Ip) PortForwardingRule(com.cloud.network.rules.PortForwardingRule) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException)

Example 19 with InvalidParameterValueException

use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.

the class CreatePortForwardingRuleCmd method getNetworkId.

@Override
public long getNetworkId() {
    final IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
    Long ntwkId = null;
    if (ip.getAssociatedWithNetworkId() != null) {
        ntwkId = ip.getAssociatedWithNetworkId();
    } else {
        ntwkId = networkId;
    }
    if (ntwkId == null) {
        throw new InvalidParameterValueException("Unable to create port forwarding rule for ip address with ID = " + getIpAddressUuid() + " as this ip address is not associated with any network. Please add networkId parameter.");
    }
    return ntwkId;
}
Also used : InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) IpAddress(com.cloud.network.IpAddress)

Example 20 with InvalidParameterValueException

use of com.cloud.utils.exception.InvalidParameterValueException in project cosmic by MissionCriticalCloud.

the class ResizeVolumeCmdByAdmin method execute.

@Override
public void execute() throws ResourceAllocationException {
    Volume volume = null;
    try {
        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
        volume = _volumeService.resizeVolume(this);
    } catch (final InvalidParameterValueException ex) {
        s_logger.info(ex.getMessage());
        throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
    }
    if (volume != null) {
        final VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
        // FIXME - have to be moved to ApiResponseHelper
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) VolumeResponse(com.cloud.api.response.VolumeResponse) Volume(com.cloud.storage.Volume) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException)

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