Search in sources :

Example 11 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project CloudStack-archive by CloudStack-extras.

the class CreateNetworkOfferingCmd method getServiceCapabilities.

public Map<Capability, String> getServiceCapabilities(Service service) {
    Map<Capability, String> capabilityMap = null;
    if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
        capabilityMap = new HashMap<Capability, String>();
        Collection serviceCapabilityCollection = serviceCapabilitystList.values();
        Iterator iter = serviceCapabilityCollection.iterator();
        while (iter.hasNext()) {
            HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
            Capability capability = null;
            String svc = (String) svcCapabilityMap.get("service");
            String capabilityName = (String) svcCapabilityMap.get("capabilitytype");
            String capabilityValue = (String) 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.exception.InvalidParameterValueException) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 12 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project CloudStack-archive by CloudStack-extras.

the class CreateIpForwardingRuleCmd 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");
    }
    try {
        StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
        this.setEntityId(rule.getId());
    } catch (NetworkRuleConflictException e) {
        s_logger.info("Unable to create Static Nat Rule due to ", e);
        throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) StaticNatRule(com.cloud.network.rules.StaticNatRule) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException)

Example 13 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project CloudStack-archive by CloudStack-extras.

the class DeleteLBStickinessPolicyCmd method getSyncObjId.

@Override
public Long getSyncObjId() {
    StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class, getId());
    if (policy == null) {
        throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
    }
    LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
    if (lb == null) {
        throw new InvalidParameterValueException("Unable to find load balancer rule for stickiness rule: " + id);
    }
    return lb.getNetworkId();
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LoadBalancer(com.cloud.network.rules.LoadBalancer) StickinessPolicy(com.cloud.network.rules.StickinessPolicy)

Example 14 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class DeleteEventsCmd method execute.

@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");
    }
    boolean result = _mgr.deleteEvents(this);
    if (result) {
        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(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 15 with InvalidParameterValueException

use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.

the class CreateFirewallRuleCmd method getNetworkId.

@Override
public long getNetworkId() {
    IpAddress ip = _entityMgr.findById(IpAddress.class, getIpAddressId());
    Long ntwkId = null;
    if (ip.getAssociatedWithNetworkId() != null) {
        ntwkId = ip.getAssociatedWithNetworkId();
    }
    if (ntwkId == null) {
        throw new InvalidParameterValueException("Unable to create firewall rule for the IP address ID=" + ipAddressId + " as IP is not associated with any network and no networkId is passed in");
    }
    return ntwkId;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) IpAddress(com.cloud.network.IpAddress)

Aggregations

InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)725 Account (com.cloud.user.Account)242 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)229 ArrayList (java.util.ArrayList)186 ActionEvent (com.cloud.event.ActionEvent)171 DB (com.cloud.utils.db.DB)139 ServerApiException (org.apache.cloudstack.api.ServerApiException)110 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)94 TransactionStatus (com.cloud.utils.db.TransactionStatus)88 List (java.util.List)80 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)69 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)63 Network (com.cloud.network.Network)58 HashMap (java.util.HashMap)58 ConfigurationException (javax.naming.ConfigurationException)53 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)52 Pair (com.cloud.utils.Pair)50 HostVO (com.cloud.host.HostVO)46 NetworkVO (com.cloud.network.dao.NetworkVO)46 DataCenterVO (com.cloud.dc.DataCenterVO)44