Search in sources :

Example 6 with DetailVO

use of com.cloud.host.DetailVO in project cloudstack by apache.

the class HostDaoImpl method listByHostCapability.

@Override
public List<HostVO> listByHostCapability(Type type, Long clusterId, Long podId, long dcId, String hostCapabilty) {
    SearchBuilder<DetailVO> hostCapabilitySearch = _detailsDao.createSearchBuilder();
    DetailVO tagEntity = hostCapabilitySearch.entity();
    hostCapabilitySearch.and("capability", tagEntity.getName(), SearchCriteria.Op.EQ);
    hostCapabilitySearch.and("value", tagEntity.getValue(), SearchCriteria.Op.EQ);
    SearchBuilder<HostVO> hostSearch = createSearchBuilder();
    HostVO entity = hostSearch.entity();
    hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ);
    hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ);
    hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ);
    hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ);
    hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ);
    hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ);
    hostSearch.join("hostCapabilitySearch", hostCapabilitySearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER);
    SearchCriteria<HostVO> sc = hostSearch.create();
    sc.setJoinParameters("hostCapabilitySearch", "value", Boolean.toString(true));
    sc.setJoinParameters("hostCapabilitySearch", "capability", hostCapabilty);
    sc.setParameters("type", type.toString());
    if (podId != null) {
        sc.setParameters("pod", podId);
    }
    if (clusterId != null) {
        sc.setParameters("cluster", clusterId);
    }
    sc.setParameters("dc", dcId);
    sc.setParameters("status", Status.Up.toString());
    sc.setParameters("resourceState", ResourceState.Enabled.toString());
    return listBy(sc);
}
Also used : DetailVO(com.cloud.host.DetailVO) HostVO(com.cloud.host.HostVO)

Example 7 with DetailVO

use of com.cloud.host.DetailVO in project cloudstack by apache.

the class DeploymentPlanningManagerImpl method checkVmProfileAndHost.

private boolean checkVmProfileAndHost(final VirtualMachineProfile vmProfile, final HostVO host) {
    ServiceOffering offering = vmProfile.getServiceOffering();
    if (offering.getHostTag() != null) {
        _hostDao.loadHostTags(host);
        if (!host.checkHostServiceOfferingTags(offering)) {
            s_logger.debug("Service Offering host tag does not match the last host of this VM");
            return false;
        }
    }
    long guestOSId = vmProfile.getTemplate().getGuestOSId();
    GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
    if (guestOS != null) {
        long guestOSCategoryId = guestOS.getCategoryId();
        DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id");
        if (hostDetail != null) {
            String guestOSCategoryIdString = hostDetail.getValue();
            if (String.valueOf(guestOSCategoryId) != guestOSCategoryIdString) {
                s_logger.debug("The last host has different guest.os.category.id than guest os category of VM, skipping");
                return false;
            }
        }
    }
    return true;
}
Also used : ServiceOffering(com.cloud.offering.ServiceOffering) DetailVO(com.cloud.host.DetailVO) GuestOSVO(com.cloud.storage.GuestOSVO)

Example 8 with DetailVO

use of com.cloud.host.DetailVO in project cloudstack by apache.

the class ResourceManagerImpl method getGuestOSCategoryId.

@Override
public Long getGuestOSCategoryId(final long hostId) {
    final HostVO host = _hostDao.findById(hostId);
    if (host == null) {
        return null;
    } else {
        _hostDao.loadDetails(host);
        final DetailVO detail = _hostDetailsDao.findDetail(hostId, "guest.os.category.id");
        if (detail == null) {
            return null;
        } else {
            return Long.parseLong(detail.getValue());
        }
    }
}
Also used : DetailVO(com.cloud.host.DetailVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO)

Example 9 with DetailVO

use of com.cloud.host.DetailVO in project cloudstack by apache.

the class ResourceManagerImpl method updateSupportsClonedVolumes.

private void updateSupportsClonedVolumes(HostVO host, boolean supportsClonedVolumes) {
    final String name = "supportsResign";
    DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), name);
    if (hostDetail != null) {
        if (supportsClonedVolumes) {
            hostDetail.setValue(Boolean.TRUE.toString());
            _hostDetailsDao.update(hostDetail.getId(), hostDetail);
        } else {
            _hostDetailsDao.remove(hostDetail.getId());
        }
    } else {
        if (supportsClonedVolumes) {
            hostDetail = new DetailVO(host.getId(), name, Boolean.TRUE.toString());
            _hostDetailsDao.persist(hostDetail);
        }
    }
    boolean clusterSupportsResigning = true;
    List<HostVO> hostVOs = _hostDao.findByClusterId(host.getClusterId());
    for (HostVO hostVO : hostVOs) {
        DetailVO hostDetailVO = _hostDetailsDao.findDetail(hostVO.getId(), name);
        if (hostDetailVO == null || Boolean.parseBoolean(hostDetailVO.getValue()) == false) {
            clusterSupportsResigning = false;
            break;
        }
    }
    ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(host.getClusterId(), name);
    if (clusterDetailsVO != null) {
        if (clusterSupportsResigning) {
            clusterDetailsVO.setValue(Boolean.TRUE.toString());
            _clusterDetailsDao.update(clusterDetailsVO.getId(), clusterDetailsVO);
        } else {
            _clusterDetailsDao.remove(clusterDetailsVO.getId());
        }
    } else {
        if (clusterSupportsResigning) {
            clusterDetailsVO = new ClusterDetailsVO(host.getClusterId(), name, Boolean.TRUE.toString());
            _clusterDetailsDao.persist(clusterDetailsVO);
        }
    }
}
Also used : DetailVO(com.cloud.host.DetailVO) ClusterDetailsVO(com.cloud.dc.ClusterDetailsVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO)

Example 10 with DetailVO

use of com.cloud.host.DetailVO in project cosmic by MissionCriticalCloud.

the class HostDetailsDaoImpl method findDetails.

@Override
public Map<String, String> findDetails(final long hostId) {
    final SearchCriteria<DetailVO> sc = HostSearch.create();
    sc.setParameters("hostId", hostId);
    final List<DetailVO> results = search(sc, null);
    final Map<String, String> details = new HashMap<>(results.size());
    for (final DetailVO result : results) {
        if ("password".equals(result.getName())) {
            details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue()));
        } else {
            details.put(result.getName(), result.getValue());
        }
    }
    return details;
}
Also used : DetailVO(com.cloud.host.DetailVO) HashMap(java.util.HashMap)

Aggregations

DetailVO (com.cloud.host.DetailVO)38 HostVO (com.cloud.host.HostVO)15 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)13 TransactionStatus (com.cloud.utils.db.TransactionStatus)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)13 ConfigurationException (javax.naming.ConfigurationException)13 HashMap (java.util.HashMap)12 Host (com.cloud.host.Host)9 DB (com.cloud.utils.db.DB)9 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)8 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)8 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)7 NetworkDevice (org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice)6 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)5 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)5 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)5 ServerResource (com.cloud.resource.ServerResource)5 UnableDeleteHostException (com.cloud.resource.UnableDeleteHostException)5 GuestOSCategoryVO (com.cloud.storage.GuestOSCategoryVO)4 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)4