use of com.cloud.storage.GuestOSCategoryVO in project cloudstack by apache.
the class FirstFitAllocator method getTemplateGuestOSCategory.
protected String getTemplateGuestOSCategory(VMTemplateVO template) {
long guestOSId = template.getGuestOSId();
GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
long guestOSCategoryId = guestOS.getCategoryId();
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
return guestOSCategory.getName();
}
use of com.cloud.storage.GuestOSCategoryVO 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;
}
use of com.cloud.storage.GuestOSCategoryVO in project cloudstack by apache.
the class ManagementServerImpl method listGuestOSCategoriesByCriteria.
@Override
public Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(final ListGuestOsCategoriesCmd cmd) {
final Filter searchFilter = new Filter(GuestOSCategoryVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
final Long id = cmd.getId();
final String name = cmd.getName();
final String keyword = cmd.getKeyword();
final SearchCriteria<GuestOSCategoryVO> sc = _guestOSCategoryDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
if (name != null) {
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
}
if (keyword != null) {
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}
final Pair<List<GuestOSCategoryVO>, Integer> result = _guestOSCategoryDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOsCategory>, Integer>(result.first(), result.second());
}
use of com.cloud.storage.GuestOSCategoryVO 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((String) key), false);
}
}
return guestOsPersisted;
}
use of com.cloud.storage.GuestOSCategoryVO in project cloudstack by apache.
the class FirstFitAllocator method getHostGuestOSCategory.
protected String getHostGuestOSCategory(Host host) {
DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
if (hostDetail != null) {
String guestOSCategoryIdString = hostDetail.getValue();
long guestOSCategoryId;
try {
guestOSCategoryId = Long.parseLong(guestOSCategoryIdString);
} catch (Exception e) {
return null;
}
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
if (guestOSCategory != null) {
return guestOSCategory.getName();
} else {
return null;
}
} else {
return null;
}
}
Aggregations