Search in sources :

Example 1 with GuestVlanRangeResponse

use of com.cloud.api.response.GuestVlanRangeResponse in project cosmic by MissionCriticalCloud.

the class ListDedicatedGuestVlanRangesCmd method execute.

@Override
public void execute() {
    final Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
    final ListResponse<GuestVlanRangeResponse> response = new ListResponse<>();
    final List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<>();
    for (final GuestVlan vlan : vlans.first()) {
        final 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(com.cloud.api.response.GuestVlanRangeResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) GuestVlan(com.cloud.network.GuestVlan) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with GuestVlanRangeResponse

use of com.cloud.api.response.GuestVlanRangeResponse in project cosmic by MissionCriticalCloud.

the class DedicateGuestVlanRangeCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    final GuestVlan result = _networkService.dedicateGuestVlanRange(this);
    if (result != null) {
        final 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(com.cloud.api.response.GuestVlanRangeResponse) ServerApiException(com.cloud.api.ServerApiException) GuestVlan(com.cloud.network.GuestVlan)

Example 3 with GuestVlanRangeResponse

use of com.cloud.api.response.GuestVlanRangeResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createDedicatedGuestVlanRangeResponse.

@Override
public GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(final GuestVlan vlan) {
    final GuestVlanRangeResponse guestVlanRangeResponse = new GuestVlanRangeResponse();
    guestVlanRangeResponse.setId(vlan.getUuid());
    final Long accountId = ApiDBUtils.getAccountIdForGuestVlan(vlan.getId());
    final Account owner = ApiDBUtils.findAccountById(accountId);
    if (owner != null) {
        populateAccount(guestVlanRangeResponse, owner.getId());
        populateDomain(guestVlanRangeResponse, owner.getDomainId());
    }
    guestVlanRangeResponse.setGuestVlanRange(vlan.getGuestVlanRange());
    guestVlanRangeResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
    final PhysicalNetworkVO physicalNetwork = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
    guestVlanRangeResponse.setZoneId(physicalNetwork.getDataCenterId());
    return guestVlanRangeResponse;
}
Also used : UserAccount(com.cloud.legacymodel.user.UserAccount) Account(com.cloud.legacymodel.user.Account) GuestVlanRangeResponse(com.cloud.api.response.GuestVlanRangeResponse) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO)

Aggregations

GuestVlanRangeResponse (com.cloud.api.response.GuestVlanRangeResponse)3 GuestVlan (com.cloud.network.GuestVlan)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 Account (com.cloud.legacymodel.user.Account)1 UserAccount (com.cloud.legacymodel.user.UserAccount)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1