Search in sources :

Example 6 with NetworkACL

use of com.cloud.network.vpc.NetworkACL in project cloudstack by apache.

the class UpdateNetworkACLListCmd method execute.

@Override
public void execute() throws ResourceUnavailableException {
    NetworkACL acl = _networkACLService.updateNetworkACL(id, this.getCustomId(), getDisplay());
    NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl);
    setResponseObject(aclResponse);
    aclResponse.setResponseName(getCommandName());
}
Also used : NetworkACLResponse(org.apache.cloudstack.api.response.NetworkACLResponse) NetworkACL(com.cloud.network.vpc.NetworkACL)

Example 7 with NetworkACL

use of com.cloud.network.vpc.NetworkACL in project cloudstack by apache.

the class CreateNetworkACLListCmd method execute.

@Override
public void execute() throws ResourceUnavailableException {
    NetworkACL acl = _networkACLService.getNetworkACL(getEntityId());
    if (acl != null) {
        NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl);
        setResponseObject(aclResponse);
        aclResponse.setResponseName(getCommandName());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network ACL");
    }
}
Also used : NetworkACLResponse(org.apache.cloudstack.api.response.NetworkACLResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkACL(com.cloud.network.vpc.NetworkACL)

Example 8 with NetworkACL

use of com.cloud.network.vpc.NetworkACL in project cloudstack by apache.

the class ApiResponseHelper method createNetworkACLItemResponse.

@Override
public NetworkACLItemResponse createNetworkACLItemResponse(NetworkACLItem aclItem) {
    NetworkACLItemResponse response = new NetworkACLItemResponse();
    response.setId(aclItem.getUuid());
    response.setProtocol(aclItem.getProtocol());
    if (aclItem.getSourcePortStart() != null) {
        response.setStartPort(Integer.toString(aclItem.getSourcePortStart()));
    }
    if (aclItem.getSourcePortEnd() != null) {
        response.setEndPort(Integer.toString(aclItem.getSourcePortEnd()));
    }
    response.setCidrList(StringUtils.join(aclItem.getSourceCidrList(), ","));
    response.setTrafficType(aclItem.getTrafficType().toString());
    NetworkACLItem.State state = aclItem.getState();
    String stateToSet = state.toString();
    if (state.equals(NetworkACLItem.State.Revoke)) {
        stateToSet = "Deleting";
    }
    response.setIcmpCode(aclItem.getIcmpCode());
    response.setIcmpType(aclItem.getIcmpType());
    response.setState(stateToSet);
    response.setNumber(aclItem.getNumber());
    response.setAction(aclItem.getAction().toString());
    response.setForDisplay(aclItem.isDisplay());
    NetworkACL acl = ApiDBUtils.findByNetworkACLId(aclItem.getAclId());
    if (acl != null) {
        response.setAclId(acl.getUuid());
    }
    //set tag information
    List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.NetworkACL, aclItem.getId());
    List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
    for (ResourceTag tag : tags) {
        ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
        CollectionUtils.addIgnoreNull(tagResponses, tagResponse);
    }
    response.setTags(tagResponses);
    response.setObjectName("networkacl");
    return response;
}
Also used : NetworkACLItem(com.cloud.network.vpc.NetworkACLItem) ResourceTag(com.cloud.server.ResourceTag) ArrayList(java.util.ArrayList) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) NetworkACL(com.cloud.network.vpc.NetworkACL) NetworkACLItemResponse(org.apache.cloudstack.api.response.NetworkACLItemResponse)

Aggregations

NetworkACL (com.cloud.network.vpc.NetworkACL)8 ArrayList (java.util.ArrayList)3 NetworkACLResponse (org.apache.cloudstack.api.response.NetworkACLResponse)3 DataCenter (com.cloud.dc.DataCenter)2 Vpc (com.cloud.network.vpc.Vpc)2 ResourceTag (com.cloud.server.ResourceTag)2 HashMap (java.util.HashMap)2 Domain (com.cloud.domain.Domain)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)1 Capability (com.cloud.network.Network.Capability)1 Service (com.cloud.network.Network.Service)1 NetworkProfile (com.cloud.network.NetworkProfile)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1