Search in sources :

Example 26 with NetworkRuleConflictException

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

the class CreateRemoteAccessVpnCmd method create.

@Override
public void create() {
    try {
        RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), isDisplay());
        if (vpn != null) {
            setEntityId(vpn.getId());
            setEntityUuid(vpn.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create remote access vpn");
        }
    } catch (NetworkRuleConflictException e) {
        s_logger.info("Network rule conflict: " + e.getMessage());
        s_logger.trace("Network Rule Conflict: ", e);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 27 with NetworkRuleConflictException

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

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");
    }
    Ip privateIp = getVmSecondaryIp();
    if (privateIp != null) {
        if (!NetUtils.isValidIp(privateIp.toString())) {
            throw new InvalidParameterValueException("Invalid vm ip address");
        }
    }
    try {
        PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay());
        setEntityId(result.getId());
        setEntityUuid(result.getUuid());
    } catch (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(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Ip(com.cloud.utils.net.Ip) PortForwardingRule(com.cloud.network.rules.PortForwardingRule) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException)

Example 28 with NetworkRuleConflictException

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

the class CreateApplicationLoadBalancerCmd method create.

@Override
public void create() {
    try {
        ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(), getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getDisplay());
        this.setEntityId(result.getId());
        this.setEntityUuid(result.getUuid());
    } catch (NetworkRuleConflictException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    } catch (InsufficientAddressCapacityException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
    } catch (InsufficientVirtualNetworkCapacityException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) ApplicationLoadBalancerRule(org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException)

Example 29 with NetworkRuleConflictException

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

the class CreateEgressFirewallRuleCmd method create.

@Override
public void create() {
    if (getSourceCidrList() != null) {
        String guestCidr = _networkService.getNetwork(getNetworkId()).getCidr();
        for (String cidr : getSourceCidrList()) {
            if (!NetUtils.isValidCIDR(cidr)) {
                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Source cidrs formatting error " + cidr);
            }
            if (cidr.equals(NetUtils.ALL_CIDRS)) {
                continue;
            }
            if (!NetUtils.isNetworkAWithinNetworkB(cidr, guestCidr)) {
                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, cidr + " is not within the guest cidr " + guestCidr);
            }
        }
    }
    if (getProtocol().equalsIgnoreCase(NetUtils.ALL_PROTO)) {
        if (getSourcePortStart() != null && getSourcePortEnd() != null) {
            throw new InvalidParameterValueException("Do not pass ports to protocol ALL, protocol ALL do not require ports. Unable to create " + "firewall rule for the network id=" + networkId);
        }
    }
    if (getVpcId() != null) {
        throw new InvalidParameterValueException("Unable to create firewall rule for the network id=" + networkId + " as firewall egress rule can be created only for non vpc networks.");
    }
    try {
        FirewallRule result = _firewallService.createEgressFirewallRule(this);
        if (result != null) {
            setEntityId(result.getId());
            setEntityUuid(result.getUuid());
        }
    } catch (NetworkRuleConflictException ex) {
        s_logger.info("Network rule conflict: " + ex.getMessage());
        s_logger.trace("Network Rule Conflict: ", ex);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) FirewallRule(com.cloud.network.rules.FirewallRule) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException)

Example 30 with NetworkRuleConflictException

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

the class CreateLBStickinessPolicyCmd method create.

@Override
public void create() {
    try {
        StickinessPolicy result = _lbService.createLBStickinessPolicy(this);
        this.setEntityId(result.getId());
        this.setEntityUuid(result.getUuid());
    } catch (NetworkRuleConflictException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) StickinessPolicy(com.cloud.network.rules.StickinessPolicy)

Aggregations

NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)44 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)18 ServerApiException (org.apache.cloudstack.api.ServerApiException)14 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)12 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)12 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)12 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)12 Network (com.cloud.network.Network)10 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)9 IPAddressVO (com.cloud.network.dao.IPAddressVO)9 DB (com.cloud.utils.db.DB)8 TransactionStatus (com.cloud.utils.db.TransactionStatus)8 ServerApiException (com.cloud.api.ServerApiException)6 Account (com.cloud.user.Account)6 TransactionCallbackWithException (com.cloud.utils.db.TransactionCallbackWithException)6 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)5 ActionEvent (com.cloud.event.ActionEvent)4 IpAddress (com.cloud.network.IpAddress)4 FirewallRule (com.cloud.network.rules.FirewallRule)4