Search in sources :

Example 1 with GuestOsMappingResponse

use of org.apache.cloudstack.api.response.GuestOsMappingResponse in project cloudstack by apache.

the class ApiResponseHelper method createGuestOSMappingResponse.

@Override
public GuestOsMappingResponse createGuestOSMappingResponse(GuestOSHypervisor guestOSHypervisor) {
    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());
    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(org.apache.cloudstack.api.response.GuestOsMappingResponse)

Example 2 with GuestOsMappingResponse

use of org.apache.cloudstack.api.response.GuestOsMappingResponse in project cloudstack by apache.

the class UpdateGuestOsMappingCmd method execute.

@Override
public void execute() {
    GuestOSHypervisor guestOsMapping = _mgr.updateGuestOsMapping(this);
    if (guestOsMapping != null) {
        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(org.apache.cloudstack.api.ServerApiException) GuestOsMappingResponse(org.apache.cloudstack.api.response.GuestOsMappingResponse)

Example 3 with GuestOsMappingResponse

use of org.apache.cloudstack.api.response.GuestOsMappingResponse in project cloudstack by apache.

the class AddGuestOsMappingCmd method execute.

@Override
public void execute() {
    GuestOSHypervisor guestOsMapping = _mgr.getAddedGuestOsMapping(getEntityId());
    if (guestOsMapping != null) {
        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(org.apache.cloudstack.api.ServerApiException) GuestOsMappingResponse(org.apache.cloudstack.api.response.GuestOsMappingResponse)

Example 4 with GuestOsMappingResponse

use of org.apache.cloudstack.api.response.GuestOsMappingResponse in project cloudstack by apache.

the class ListGuestOsMappingCmd method execute.

@Override
public void execute() {
    Pair<List<? extends GuestOSHypervisor>, Integer> result = _mgr.listGuestOSMappingByCriteria(this);
    ListResponse<GuestOsMappingResponse> response = new ListResponse<GuestOsMappingResponse>();
    List<GuestOsMappingResponse> osMappingResponses = new ArrayList<GuestOsMappingResponse>();
    for (GuestOSHypervisor guestOSHypervisor : result.first()) {
        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(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) GuestOsMappingResponse(org.apache.cloudstack.api.response.GuestOsMappingResponse)

Aggregations

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