Search in sources :

Example 6 with GuestOS

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

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

the class ManagementServerImpl method addGuestOs.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_ADD, eventDescription = "Adding new guest OS type", create = true)
public GuestOS addGuestOs(final AddGuestOsCmd cmd) {
    final Long categoryId = cmd.getOsCategoryId();
    final String displayName = cmd.getOsDisplayName();
    final String name = cmd.getOsName();
    final GuestOSCategoryVO guestOsCategory = ApiDBUtils.findGuestOsCategoryById(categoryId);
    if (guestOsCategory == null) {
        throw new InvalidParameterValueException("Guest OS category not found. Please specify a valid Guest OS category");
    }
    final GuestOS guestOs = ApiDBUtils.findGuestOSByDisplayName(displayName);
    if (guestOs != null) {
        throw new InvalidParameterValueException("The specified Guest OS name : " + displayName + " already exists. Please specify a unique name");
    }
    s_logger.debug("GuestOSDetails");
    final GuestOSVO guestOsVo = new GuestOSVO();
    guestOsVo.setCategoryId(categoryId.longValue());
    guestOsVo.setDisplayName(displayName);
    guestOsVo.setName(name);
    guestOsVo.setIsUserDefined(true);
    final GuestOS guestOsPersisted = _guestOSDao.persist(guestOsVo);
    if (cmd.getDetails() != null && !cmd.getDetails().isEmpty()) {
        Map<String, String> detailsMap = cmd.getDetails();
        for (Object key : detailsMap.keySet()) {
            _guestOsDetailsDao.addDetail(guestOsPersisted.getId(), (String) key, detailsMap.get(key), false);
        }
    }
    return guestOsPersisted;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) GuestOS(com.cloud.storage.GuestOS) GuestOSVO(com.cloud.storage.GuestOSVO) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 8 with GuestOS

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

the class ManagementServerImpl method removeGuestOs.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_REMOVE, eventDescription = "removing guest OS type", async = true)
public boolean removeGuestOs(final RemoveGuestOsCmd cmd) {
    final Long id = cmd.getId();
    // check if guest OS exists
    final GuestOS guestOs = ApiDBUtils.findGuestOSById(id);
    if (guestOs == null) {
        throw new InvalidParameterValueException("Guest OS not found. Please specify a valid ID for the Guest OS");
    }
    if (!guestOs.getIsUserDefined()) {
        throw new InvalidParameterValueException("Unable to remove system defined guest OS");
    }
    return _guestOSDao.remove(id);
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) GuestOS(com.cloud.storage.GuestOS) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 9 with GuestOS

use of com.cloud.storage.GuestOS 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 10 with GuestOS

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

GuestOS (com.cloud.storage.GuestOS)26 ActionEvent (com.cloud.event.ActionEvent)8 DB (com.cloud.utils.db.DB)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 ArrayList (java.util.ArrayList)6 Account (com.cloud.user.Account)5 GuestOSResponse (com.cloud.api.response.GuestOSResponse)4 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)4 GuestOSVO (com.cloud.storage.GuestOSVO)4 VMTemplateVO (com.cloud.storage.VMTemplateVO)4 UserVO (com.cloud.user.UserVO)4 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)4 ServerApiException (org.apache.cloudstack.api.ServerApiException)4 ServerApiException (com.cloud.api.ServerApiException)3 DataCenter (com.cloud.dc.DataCenter)3 DataCenterVO (com.cloud.dc.DataCenterVO)3 ImageFormat (com.cloud.storage.Storage.ImageFormat)3 TemplateProfile (com.cloud.storage.TemplateProfile)3 ListResponse (com.cloud.api.response.ListResponse)2 HostVO (com.cloud.host.HostVO)2