Search in sources :

Example 1 with GuestOSCategoryVO

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();
}
Also used : GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) GuestOSVO(com.cloud.storage.GuestOSVO)

Example 2 with GuestOSCategoryVO

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;
}
Also used : GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse)

Example 3 with GuestOSCategoryVO

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());
}
Also used : Filter(com.cloud.utils.db.Filter) GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 4 with GuestOSCategoryVO

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;
}
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 5 with GuestOSCategoryVO

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;
    }
}
Also used : DetailVO(com.cloud.host.DetailVO) GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

GuestOSCategoryVO (com.cloud.storage.GuestOSCategoryVO)6 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 DetailVO (com.cloud.host.DetailVO)2 GuestOSVO (com.cloud.storage.GuestOSVO)2 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)1 ActionEvent (com.cloud.event.ActionEvent)1 HostVO (com.cloud.host.HostVO)1 GuestOS (com.cloud.storage.GuestOS)1 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)1 SSHKeyPair (com.cloud.user.SSHKeyPair)1 Pair (com.cloud.utils.Pair)1 DB (com.cloud.utils.db.DB)1 Filter (com.cloud.utils.db.Filter)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConfigurationException (javax.naming.ConfigurationException)1 GuestOSResponse (org.apache.cloudstack.api.response.GuestOSResponse)1