Search in sources :

Example 1 with VlanIpRangeResponse

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

the class CreateVlanIpRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    try {
        Vlan result = _configService.createVlanAndPublicIpRange(this);
        if (result != null) {
            VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create vlan ip range");
        }
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
    } catch (InsufficientCapacityException ex) {
        s_logger.info(ex);
        throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
}
Also used : VlanIpRangeResponse(com.cloud.api.response.VlanIpRangeResponse) ServerApiException(com.cloud.api.ServerApiException) Vlan(com.cloud.dc.Vlan) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 2 with VlanIpRangeResponse

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

the class ListVlanIpRangesCmd method execute.

@Override
public void execute() {
    List<? extends Vlan> vlans = _mgr.searchForVlans(this);
    ListResponse<VlanIpRangeResponse> response = new ListResponse<VlanIpRangeResponse>();
    List<VlanIpRangeResponse> vlanResponses = new ArrayList<VlanIpRangeResponse>();
    for (Vlan vlan : vlans) {
        VlanIpRangeResponse vlanResponse = _responseGenerator.createVlanIpRangeResponse(vlan);
        vlanResponse.setObjectName("vlaniprange");
        vlanResponses.add(vlanResponse);
    }
    response.setResponses(vlanResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VlanIpRangeResponse(com.cloud.api.response.VlanIpRangeResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) Vlan(com.cloud.dc.Vlan)

Aggregations

VlanIpRangeResponse (com.cloud.api.response.VlanIpRangeResponse)2 Vlan (com.cloud.dc.Vlan)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 ArrayList (java.util.ArrayList)1