Search in sources :

Example 1 with GuestOSResponse

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

the class ListGuestOsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends GuestOS>, Integer> result = _mgr.listGuestOSByCriteria(this);
    ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
    List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
    for (GuestOS guestOS : result.first()) {
        GuestOSResponse guestOSResponse = _responseGenerator.createGuestOSResponse(guestOS);
        osResponses.add(guestOSResponse);
    }
    response.setResponses(osResponses, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse)

Example 2 with GuestOSResponse

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

the class AddGuestOsCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Guest OS Id: " + getEntityId());
    GuestOS guestOs = _mgr.getAddedGuestOs(getEntityId());
    if (guestOs != null) {
        GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse)

Example 3 with GuestOSResponse

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

the class ApiResponseHelper method createGuestOSResponse.

@Override
public GuestOSResponse createGuestOSResponse(GuestOS guestOS) {
    GuestOSResponse response = new GuestOSResponse();
    response.setDescription(guestOS.getDisplayName());
    response.setId(guestOS.getUuid());
    response.setIsUserDefined(Boolean.valueOf(guestOS.getIsUserDefined()).toString());
    GuestOSCategoryVO category = ApiDBUtils.findGuestOsCategoryById(guestOS.getCategoryId());
    if (category != null) {
        response.setOsCategoryId(category.getUuid());
    }
    response.setObjectName("ostype");
    return response;
}
Also used : GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse)

Example 4 with GuestOSResponse

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

the class UpdateGuestOsCmd method execute.

@Override
public void execute() {
    GuestOS guestOs = _mgr.updateGuestOs(this);
    if (guestOs != null) {
        GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS type");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse)

Aggregations

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