Search in sources :

Example 1 with GuestOSResponse

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

the class UpdateGuestOsCmd method execute.

@Override
public void execute() {
    final GuestOS guestOs = _mgr.updateGuestOs(this);
    if (guestOs != null) {
        final 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(com.cloud.api.ServerApiException) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(com.cloud.api.response.GuestOSResponse)

Example 2 with GuestOSResponse

use of com.cloud.api.response.GuestOSResponse in project CloudStack-archive by CloudStack-extras.

the class ListGuestOsCmd method execute.

@Override
public void execute() {
    List<? extends GuestOS> result = _mgr.listGuestOSByCriteria(this);
    ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
    List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
    for (GuestOS guestOS : result) {
        GuestOSResponse guestOSResponse = new GuestOSResponse();
        guestOSResponse.setDescription(guestOS.getDisplayName());
        guestOSResponse.setId(guestOS.getId());
        guestOSResponse.setOsCategoryId(guestOS.getCategoryId());
        guestOSResponse.setObjectName("ostype");
        osResponses.add(guestOSResponse);
    }
    response.setResponses(osResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(com.cloud.api.response.GuestOSResponse)

Example 3 with GuestOSResponse

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

the class ApiResponseHelper method createGuestOSResponse.

@Override
public GuestOSResponse createGuestOSResponse(final GuestOS guestOS) {
    final GuestOSResponse response = new GuestOSResponse();
    response.setDescription(guestOS.getDisplayName());
    response.setId(guestOS.getUuid());
    response.setIsUserDefined(Boolean.valueOf(guestOS.getIsUserDefined()).toString());
    final 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(com.cloud.api.response.GuestOSResponse)

Example 4 with GuestOSResponse

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

the class ListGuestOsCmd method execute.

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

Example 5 with GuestOSResponse

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

the class AddGuestOsCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Guest OS Id: " + getEntityId());
    final GuestOS guestOs = _mgr.getAddedGuestOs(getEntityId());
    if (guestOs != null) {
        final 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(com.cloud.api.ServerApiException) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(com.cloud.api.response.GuestOSResponse)

Aggregations

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