Search in sources :

Example 1 with GuestVlan

use of com.cloud.network.GuestVlan in project cloudstack by apache.

the class ListDedicatedGuestVlanRangesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
    ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
    List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
    for (GuestVlan vlan : vlans.first()) {
        GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan);
        guestVlanResponse.setObjectName("dedicatedguestvlanrange");
        guestVlanResponses.add(guestVlanResponse);
    }
    response.setResponses(guestVlanResponses, vlans.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : GuestVlanRangeResponse(org.apache.cloudstack.api.response.GuestVlanRangeResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) GuestVlan(com.cloud.network.GuestVlan) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with GuestVlan

use of com.cloud.network.GuestVlan in project cloudstack by apache.

the class DedicateGuestVlanRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    GuestVlan result = _networkService.dedicateGuestVlanRange(this);
    if (result != null) {
        GuestVlanRangeResponse response = _responseGenerator.createDedicatedGuestVlanRangeResponse(result);
        response.setResponseName(getCommandName());
        response.setObjectName("dedicatedguestvlanrange");
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate guest vlan range");
    }
}
Also used : GuestVlanRangeResponse(org.apache.cloudstack.api.response.GuestVlanRangeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) GuestVlan(com.cloud.network.GuestVlan)

Aggregations

GuestVlan (com.cloud.network.GuestVlan)2 GuestVlanRangeResponse (org.apache.cloudstack.api.response.GuestVlanRangeResponse)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1