@Override public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) { // get all elgible image stores List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imgStores != null) { for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status); if (sRes != null && sRes.size() > 0) { Collections.shuffle(sRes); return sRes.get(0); } } } return null; }
@Override public TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId) { List<DataStore> imgStores = null; imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imgStores != null) { Collections.shuffle(imgStores); for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreStatus(templateId, store.getId(), State.Ready); if (sRes != null && sRes.size() > 0) { return sRes.get(0); } } } return null; }
@Override public List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId) { // find all eligible image stores for this zone scope List<DataStore> imageStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imageStores == null || imageStores.size() == 0) { return null; } List<DataStore> stores = new ArrayList<DataStore>(); for (DataStore store : imageStores) { // check if the template is stored there List<TemplateDataStoreVO> storeTmpl = _tmplStoreDao.listByTemplateStore(templateId, store.getId()); if (storeTmpl != null && storeTmpl.size() > 0) { stores.add(store); } } return stores; }
@Override public List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) { // get all elgible image stores List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imgStores != null) { List<TemplateDataStoreVO> result = new ArrayList<TemplateDataStoreVO>(); for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId, store.getId(), status); if (sRes != null && sRes.size() > 0) { result.addAll(sRes); } } return result; } return null; }
@Override public TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role) { // get all elgible image stores List<DataStore> imgStores = null; if (role == DataStoreRole.Image) { imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); } else if (role == DataStoreRole.ImageCache) { imgStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId)); } if (imgStores != null) { for (DataStore store : imgStores) { List<TemplateDataStoreVO> sRes = listByTemplateStore(templateId, store.getId()); if (sRes != null && sRes.size() > 0) { return sRes.get(0); } } } return null; }
@Override public void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId) { Set<VMTemplateVO> toBeDownloaded = new HashSet<VMTemplateVO>(); List<DataStore> stores = _storeMgr.getImageStoresByScope(new ZoneScope(dcId)); if (stores == null || stores.isEmpty()) { return;
List<DataStore> imageStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(null)); for (DataStore store : imageStores) { try {
@Override public CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId) { SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria(); if (zoneId != null) { sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId); } List<Long> hosts = new ArrayList<Long>(); if (hostId != null) { hosts.add(hostId); } else { List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (stores != null) { for (DataStore store : stores) { hosts.add(store.getId()); } } } CapacityVO capacity = new CapacityVO(hostId, zoneId, null, null, 0, 0, Capacity.CAPACITY_TYPE_SECONDARY_STORAGE); for (Long id : hosts) { StorageStats stats = ApiDBUtils.getSecondaryStorageStatistics(id); if (stats == null) { continue; } capacity.setUsedCapacity(stats.getByteUsed() + capacity.getUsedCapacity()); capacity.setTotalCapacity(stats.getCapacityBytes() + capacity.getTotalCapacity()); } return capacity; }
private void createTemplateWithinZone(Long zId, TemplateProfile profile, VMTemplateVO template) { List<DataStore> imageStores = storeMgr.getImageStoresByScope(new ZoneScope(zId)); if (imageStores == null || imageStores.size() == 0) { throw new CloudRuntimeException("Unable to find image store to download template " + profile.getTemplate());
List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId())); for (DataStore store : imageStores) { _volumeSrv.handleVolumeSync(store);
List<DataStore> ssHosts = dataStoreMgr.getImageStoresByScope(new ZoneScope(dcId)); for (DataStore ssHost : ssHosts) { String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
List<DataStore> imageStores = storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); if (imageStores == null || imageStores.size() == 0) { throw new CloudRuntimeException("Unable to find image store to download template " + profile.getTemplate());
long dstZoneId = dstZone.getId(); List<DataStore> dstSecStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(dstZoneId)); if (dstSecStores == null || dstSecStores.isEmpty()) { throw new StorageUnavailableException("Destination zone is not ready, no image store associated", DataCenter.class, dstZone.getId());
List<DataStore> ssStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(null));