public static String[] toString(ResourceState... states) { String[] strs = new String[states.length]; for (int i = 0; i < states.length; i++) { strs[i] = states[i].toString(); } return strs; }
private HostVO getHostInCluster(long clusterId) { List<HostVO> hosts = _hostDao.findByClusterId(clusterId); if (hosts != null && hosts.size() > 0) { Collections.shuffle(hosts, RANDOM); for (HostVO host : hosts) { if (ResourceState.Enabled.equals(host.getResourceState())) { return host; } } } throw new CloudRuntimeException("Unable to locate a host"); }
@Override public boolean resourceStateTransitTo(final Host host, final ResourceState.Event event, final long msId) throws NoTransitionException { final ResourceState currentState = host.getResourceState(); final ResourceState nextState = currentState.getNextState(event); if (nextState == null) { throw new NoTransitionException("No next resource state found for current state = " + currentState + " event = " + event); } // TO DO - Make it more granular and have better conversion into capacity type if(host.getType() == Type.Routing){ final CapacityState capacityState = nextState == ResourceState.Enabled ? CapacityState.Enabled : CapacityState.Disabled; final short[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY}; _capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString(), capacityTypes); final StoragePoolVO storagePool = _storageMgr.findLocalStorageOnHost(host.getId()); if(storagePool != null){ final short[] capacityTypesLocalStorage = {Capacity.CAPACITY_TYPE_LOCAL_STORAGE}; _capacityDao.updateCapacityState(null, null, null, storagePool.getId(), capacityState.toString(), capacityTypesLocalStorage); } } return _hostDao.updateResourceState(currentState, event, nextState, host); }
hostResponse.setResourceState(host.getResourceState().toString());
private HostVO getHost(long zoneId, Long hostId) { Optional<HostVO> optHostVO = getHost(zoneId, true); if (optHostVO.isPresent()) { return optHostVO.get(); } HostVO hostVO = hostDao.findById(hostId); if (hostVO != null && ResourceState.Enabled.equals(hostVO.getResourceState())) { return hostVO; } optHostVO = getHost(zoneId, false); if (optHostVO.isPresent()) { return optHostVO.get(); } throw new CloudRuntimeException("Unable to locate an applicable host"); }
hostResponse.setResourceState(host.getResourceState().toString());
if (!ResourceState.Enabled.equals(host.getResourceState())) { continue;
@Override public List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), 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("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<HostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); 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); }
if (ResourceState.Enabled.equals(host.getResourceState())) { if (computeClusterMustSupportResign) { if (clusterDao.getSupportsResigning(cluster.getId())) {
@Override public List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ); SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder(); EngineHostVO 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("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<EngineHostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); 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); }
if (hostVo.getResourceState().equals(ResourceState.ErrorInMaintenance)) { UserVmDetailVO detailAddress = _userVmDetailsDao.findDetail(vm.getId(), "kvm.vnc.address"); UserVmDetailVO detailPort = _userVmDetailsDao.findDetail(vm.getId(), "kvm.vnc.port");
if (hostVO == null || !ResourceState.Enabled.equals(hostVO.getResourceState())) { Optional<HostVO> optHostVO = getHost(volumeInfo.getDataCenterId(), false);