Search in sources :

Example 1 with GuestOSHypervisor

use of com.cloud.storage.GuestOSHypervisor in project cloudstack by apache.

the class AddGuestOsMappingCmd method create.

@Override
public void create() {
    GuestOSHypervisor guestOsMapping = _mgr.addGuestOsMapping(this);
    if (guestOsMapping != null) {
        setEntityId(guestOsMapping.getId());
        setEntityUuid(guestOsMapping.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping entity");
    }
}
Also used : GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 2 with GuestOSHypervisor

use of com.cloud.storage.GuestOSHypervisor in project cloudstack by apache.

the class ManagementServerImpl method removeGuestOsMapping.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_REMOVE, eventDescription = "removing guest OS mapping", async = true)
public boolean removeGuestOsMapping(final RemoveGuestOsMappingCmd cmd) {
    final Long id = cmd.getId();
    //check if mapping exists
    final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id);
    if (guestOsHypervisorHandle == null) {
        throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping");
    }
    if (!guestOsHypervisorHandle.getIsUserDefined()) {
        throw new InvalidParameterValueException("Unable to remove system defined Guest OS mapping");
    }
    return _guestOSHypervisorDao.removeGuestOsMapping(id);
}
Also used : GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 3 with GuestOSHypervisor

use of com.cloud.storage.GuestOSHypervisor 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 4 with GuestOSHypervisor

use of com.cloud.storage.GuestOSHypervisor 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 5 with GuestOSHypervisor

use of com.cloud.storage.GuestOSHypervisor 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

GuestOSHypervisor (com.cloud.storage.GuestOSHypervisor)6 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 GuestOsMappingResponse (org.apache.cloudstack.api.response.GuestOsMappingResponse)3 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 DB (com.cloud.utils.db.DB)2 GuestOSHypervisorVO (com.cloud.storage.GuestOSHypervisorVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1