Search in sources :

Example 1 with PortableIpRangeResponse

use of org.apache.cloudstack.api.response.PortableIpRangeResponse in project cloudstack by apache.

the class CreatePortableIpRangeCmd method execute.

@Override
public void execute() {
    PortableIpRange portableIpRange = _entityMgr.findById(PortableIpRange.class, getEntityId());
    if (portableIpRange != null) {
        PortableIpRangeResponse response = _responseGenerator.createPortableIPRangeResponse(portableIpRange);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    }
}
Also used : PortableIpRangeResponse(org.apache.cloudstack.api.response.PortableIpRangeResponse) PortableIpRange(org.apache.cloudstack.region.PortableIpRange)

Example 2 with PortableIpRangeResponse

use of org.apache.cloudstack.api.response.PortableIpRangeResponse in project cloudstack by apache.

the class ApiResponseHelper method createPortableIPRangeResponse.

@Override
public PortableIpRangeResponse createPortableIPRangeResponse(PortableIpRange ipRange) {
    PortableIpRangeResponse response = new PortableIpRangeResponse();
    response.setId(ipRange.getUuid());
    String ipRangeStr = ipRange.getIpRange();
    if (ipRangeStr != null) {
        String[] range = ipRangeStr.split("-");
        response.setStartIp(range[0]);
        response.setEndIp(range[1]);
    }
    response.setVlan(ipRange.getVlanTag());
    response.setGateway(ipRange.getGateway());
    response.setNetmask(ipRange.getNetmask());
    response.setRegionId(ipRange.getRegionId());
    response.setObjectName("portableiprange");
    return response;
}
Also used : PortableIpRangeResponse(org.apache.cloudstack.api.response.PortableIpRangeResponse)

Example 3 with PortableIpRangeResponse

use of org.apache.cloudstack.api.response.PortableIpRangeResponse in project cloudstack by apache.

the class ListPortableIpRangesCmd method execute.

@Override
public void execute() {
    ListResponse<PortableIpRangeResponse> response = new ListResponse<PortableIpRangeResponse>();
    List<PortableIpRangeResponse> responses = new ArrayList<PortableIpRangeResponse>();
    List<? extends PortableIpRange> portableIpRanges = _configService.listPortableIpRanges(this);
    if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
        for (PortableIpRange range : portableIpRanges) {
            PortableIpRangeResponse rangeResponse = _responseGenerator.createPortableIPRangeResponse(range);
            List<? extends PortableIp> portableIps = _configService.listPortableIps(range.getId());
            if (portableIps != null && !portableIps.isEmpty()) {
                List<PortableIpResponse> portableIpResponses = new ArrayList<PortableIpResponse>();
                for (PortableIp portableIP : portableIps) {
                    PortableIpResponse portableIpresponse = _responseGenerator.createPortableIPResponse(portableIP);
                    portableIpResponses.add(portableIpresponse);
                }
                rangeResponse.setPortableIpResponses(portableIpResponses);
            }
            responses.add(rangeResponse);
        }
        response.setResponses(responses, portableIpRanges.size());
    }
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : PortableIpRangeResponse(org.apache.cloudstack.api.response.PortableIpRangeResponse) PortableIpResponse(org.apache.cloudstack.api.response.PortableIpResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) PortableIp(org.apache.cloudstack.region.PortableIp) ArrayList(java.util.ArrayList) PortableIpRange(org.apache.cloudstack.region.PortableIpRange)

Aggregations

PortableIpRangeResponse (org.apache.cloudstack.api.response.PortableIpRangeResponse)3 PortableIpRange (org.apache.cloudstack.region.PortableIpRange)2 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 PortableIpResponse (org.apache.cloudstack.api.response.PortableIpResponse)1 PortableIp (org.apache.cloudstack.region.PortableIp)1