Search in sources :

Example 16 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(this);
    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 17 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());
        response.setAclName(acl.getName());
    }
    // 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.setReason(aclItem.getReason());
    response.setObjectName("networkacl");
    return response;
}
Also used : NetworkACLItem(com.cloud.network.vpc.NetworkACLItem) ResourceTag(com.cloud.server.ResourceTag) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) ArrayList(java.util.ArrayList) NetworkACL(com.cloud.network.vpc.NetworkACL) NetworkACLItemResponse(org.apache.cloudstack.api.response.NetworkACLItemResponse)

Aggregations

NetworkACL (com.cloud.network.vpc.NetworkACL)17 ArrayList (java.util.ArrayList)7 DataCenter (com.cloud.dc.DataCenter)5 Vpc (com.cloud.network.vpc.Vpc)5 ResourceTag (com.cloud.server.ResourceTag)5 HashMap (java.util.HashMap)4 NetworkACLResponse (com.cloud.api.response.NetworkACLResponse)3 PhysicalNetwork (com.cloud.network.PhysicalNetwork)3 NetworkVO (com.cloud.network.dao.NetworkVO)3 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)3 ResourceTagResponse (com.cloud.api.response.ResourceTagResponse)2 Domain (com.cloud.domain.Domain)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)2