Search in sources :

Example 1 with SecurityGroupResponse

use of com.cloud.api.response.SecurityGroupResponse in project CloudStack-archive by CloudStack-extras.

the class CreateSecurityGroupCmd method execute.

@Override
public void execute() {
    SecurityGroup group = _securityGroupService.createSecurityGroup(this);
    if (group != null) {
        SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create security group");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) SecurityGroupResponse(com.cloud.api.response.SecurityGroupResponse) SecurityGroup(com.cloud.network.security.SecurityGroup)

Example 2 with SecurityGroupResponse

use of com.cloud.api.response.SecurityGroupResponse in project CloudStack-archive by CloudStack-extras.

the class AuthorizeSecurityGroupIngressCmd method execute.

@Override
public void execute() {
    if (cidrList != null) {
        for (String cidr : cidrList) {
            if (!NetUtils.isValidCIDR(cidr)) {
                throw new ServerApiException(BaseCmd.PARAM_ERROR, cidr + " is an Invalid CIDR ");
            }
        }
    }
    List<? extends SecurityRule> ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this);
    if (ingressRules != null && !ingressRules.isEmpty()) {
        SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules);
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to authorize security group ingress rule(s)");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) SecurityGroupResponse(com.cloud.api.response.SecurityGroupResponse)

Example 3 with SecurityGroupResponse

use of com.cloud.api.response.SecurityGroupResponse in project CloudStack-archive by CloudStack-extras.

the class AuthorizeSecurityGroupEgressCmd method execute.

@Override
public void execute() {
    List<? extends SecurityRule> egressRules = _securityGroupService.authorizeSecurityGroupEgress(this);
    if (egressRules != null && !egressRules.isEmpty()) {
        SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(egressRules);
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to authorize security group egress rule(s)");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) SecurityGroupResponse(com.cloud.api.response.SecurityGroupResponse)

Aggregations

ServerApiException (com.cloud.api.ServerApiException)3 SecurityGroupResponse (com.cloud.api.response.SecurityGroupResponse)3 SecurityGroup (com.cloud.network.security.SecurityGroup)1