use of org.apache.cloudstack.api.response.GuestVlanRangeResponse 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);
}
use of org.apache.cloudstack.api.response.GuestVlanRangeResponse 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");
}
}
use of org.apache.cloudstack.api.response.GuestVlanRangeResponse in project cloudstack by apache.
the class ApiResponseHelper method createDedicatedGuestVlanRangeResponse.
@Override
public GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan vlan) {
GuestVlanRangeResponse guestVlanRangeResponse = new GuestVlanRangeResponse();
guestVlanRangeResponse.setId(vlan.getUuid());
Long accountId = ApiDBUtils.getAccountIdForGuestVlan(vlan.getId());
Account owner = ApiDBUtils.findAccountById(accountId);
if (owner != null) {
populateAccount(guestVlanRangeResponse, owner.getId());
populateDomain(guestVlanRangeResponse, owner.getDomainId());
}
guestVlanRangeResponse.setGuestVlanRange(vlan.getGuestVlanRange());
guestVlanRangeResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
PhysicalNetworkVO physicalNetwork = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
guestVlanRangeResponse.setZoneId(physicalNetwork.getDataCenterId());
return guestVlanRangeResponse;
}
Aggregations