Search in sources :

Example 1 with GuestOsMappingResponse

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

the class AddGuestOsMappingCmd method execute.

@Override
public void execute() {
    final GuestOSHypervisor guestOsMapping = _mgr.getAddedGuestOsMapping(getEntityId());
    if (guestOsMapping != null) {
        final GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping");
    }
}
Also used : GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) ServerApiException(com.cloud.api.ServerApiException) GuestOsMappingResponse(com.cloud.api.response.GuestOsMappingResponse)

Example 2 with GuestOsMappingResponse

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

the class ListGuestOsMappingCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Pair<List<? extends GuestOSHypervisor>, Integer> result = _mgr.listGuestOSMappingByCriteria(this);
    final ListResponse<GuestOsMappingResponse> response = new ListResponse<>();
    final List<GuestOsMappingResponse> osMappingResponses = new ArrayList<>();
    for (final GuestOSHypervisor guestOSHypervisor : result.first()) {
        final GuestOsMappingResponse guestOsMappingResponse = _responseGenerator.createGuestOSMappingResponse(guestOSHypervisor);
        osMappingResponses.add(guestOsMappingResponse);
    }
    response.setResponses(osMappingResponses, result.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GuestOsMappingResponse(com.cloud.api.response.GuestOsMappingResponse)

Example 3 with GuestOsMappingResponse

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

the class UpdateGuestOsMappingCmd method execute.

@Override
public void execute() {
    final GuestOSHypervisor guestOsMapping = _mgr.updateGuestOsMapping(this);
    if (guestOsMapping != null) {
        final GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS mapping");
    }
}
Also used : GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) ServerApiException(com.cloud.api.ServerApiException) GuestOsMappingResponse(com.cloud.api.response.GuestOsMappingResponse)

Example 4 with GuestOsMappingResponse

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

the class ApiResponseHelper method createGuestOSMappingResponse.

@Override
public GuestOsMappingResponse createGuestOSMappingResponse(final GuestOSHypervisor guestOSHypervisor) {
    final GuestOsMappingResponse response = new GuestOsMappingResponse();
    response.setId(guestOSHypervisor.getUuid());
    response.setHypervisor(guestOSHypervisor.getHypervisorType());
    response.setHypervisorVersion(guestOSHypervisor.getHypervisorVersion());
    response.setOsNameForHypervisor(guestOSHypervisor.getGuestOsName());
    response.setIsUserDefined(Boolean.valueOf(guestOSHypervisor.getIsUserDefined()).toString());
    final GuestOS guestOs = ApiDBUtils.findGuestOSById(guestOSHypervisor.getGuestOsId());
    if (guestOs != null) {
        response.setOsStdName(guestOs.getDisplayName());
        response.setOsTypeId(guestOs.getUuid());
    }
    response.setObjectName("guestosmapping");
    return response;
}
Also used : GuestOS(com.cloud.storage.GuestOS) GuestOsMappingResponse(com.cloud.api.response.GuestOsMappingResponse)

Aggregations

GuestOsMappingResponse (com.cloud.api.response.GuestOsMappingResponse)4 GuestOSHypervisor (com.cloud.storage.GuestOSHypervisor)3 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)1 GuestOS (com.cloud.storage.GuestOS)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1