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;
}
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;
}
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);
}
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");
}
}
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;
}
Aggregations