@Override public boolean isSameScope(Scope scope) { return this.getScopeType() == scope.getScopeType() && this.getScopeId().equals(scope.getScopeId()); } }
if (storeForNewStoreScope.getScopeType() == ScopeType.ZONE) { return false; if (storeForExistingStoreScope.getScopeType() != storeForNewStoreScope.getScopeType()) { if (storeForNewStoreScope.getScopeType() == ScopeType.CLUSTER) { Long vmClusterId = null; if (storeForExistingStoreScope.getScopeType() == ScopeType.HOST) { HostScope hs = (HostScope)storeForExistingStoreScope; vmClusterId = hs.getClusterId(); } else if (storeForExistingStoreScope.getScopeType() == ScopeType.ZONE) { Long hostId = _vmInstanceDao.findById(existingVolume.getInstanceId()).getHostId(); if (hostId != null) { if (storeForNewStoreScope.getScopeId().equals(vmClusterId)) { return false; } else { return true; } else if (storeForNewStoreScope.getScopeType() == ScopeType.HOST && (storeForExistingStoreScope.getScopeType() == ScopeType.CLUSTER || storeForExistingStoreScope.getScopeType() == ScopeType.ZONE)) { Long hostId = _vmInstanceDao.findById(existingVolume.getInstanceId()).getHostId(); if (storeForNewStoreScope.getScopeId().equals(hostId)) { return false; throw new InvalidParameterValueException("Can't move volume between scope: " + storeForNewStoreScope.getScopeType() + " and " + storeForExistingStoreScope.getScopeType()); return !storeForExistingStoreScope.isSameScope(storeForNewStoreScope);
private Scope pickCacheScopeForCopy(DataObject srcData, DataObject destData) { Scope srcScope = srcData.getDataStore().getScope(); Scope destScope = destData.getDataStore().getScope(); Scope selectedScope = null; if (srcScope.getScopeId() != null) { selectedScope = getZoneScope(srcScope); } else if (destScope.getScopeId() != null) { selectedScope = getZoneScope(destScope); } else { LOGGER.warn("Cannot find a zone-wide scope for movement that needs a cache storage"); } return selectedScope; }
protected EndPoint findEndPointForImageMove(DataStore srcStore, DataStore destStore) { // find any xenserver/kvm host in the scope Scope srcScope = srcStore.getScope(); Scope destScope = destStore.getScope(); Scope selectedScope = null; Long poolId = null; // assumption, at least one of scope should be zone, find the least // scope if (srcScope.getScopeType() != ScopeType.ZONE) { selectedScope = srcScope; poolId = srcStore.getId(); } else if (destScope.getScopeType() != ScopeType.ZONE) { selectedScope = destScope; poolId = destStore.getId(); } else { // if both are zone scope if (srcStore.getRole() == DataStoreRole.Primary) { selectedScope = srcScope; poolId = srcStore.getId(); } else if (destStore.getRole() == DataStoreRole.Primary) { selectedScope = destScope; poolId = destStore.getId(); } } return findEndPointInScope(selectedScope, findOneHostOnPrimaryStorage, poolId); }
private Scope pickCacheScopeForCopy(DataObject srcData, DataObject destData) { Scope srcScope = srcData.getDataStore().getScope(); Scope destScope = destData.getDataStore().getScope(); Scope selectedScope = null; if (srcScope.getScopeId() != null) { selectedScope = getZoneScope(srcScope); } else if (destScope.getScopeId() != null) { selectedScope = getZoneScope(destScope); } else { s_logger.warn("Cannot find a zone-wide scope for movement that needs a cache storage"); } return selectedScope; }
} else if (plan.getDataCenterId() == exstPoolDcId) { DataStore dataStore = dataStoreMgr.getPrimaryDataStore(pool.getId()); if (dataStore != null && dataStore.getScope() != null && dataStore.getScope().getScopeType() == ScopeType.ZONE) { canReusePool = true;
@Override public boolean isRegionStore(DataStore store) { if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null) return true; else return false; }
@Override public void downloadBootstrapSysTemplate(DataStore store) { Set<VMTemplateVO> toBeDownloaded = new HashSet(); List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates(); for (VMTemplateVO rtngTmplt : rtngTmplts) { toBeDownloaded.add(rtngTmplt); } List<HypervisorType> availHypers = _clusterDao.getAvailableHypervisorInZone(store.getScope().getScopeId()); if (availHypers.isEmpty()) { /* * This is for cloudzone, local secondary storage resource started * before cluster created */ availHypers.add(HypervisorType.KVM); } /* Baremetal need not to download any template */ availHypers.remove(HypervisorType.BareMetal); availHypers.add(HypervisorType.None); // bug 9809: resume ISO // download. for (VMTemplateVO template : toBeDownloaded) { if (availHypers.contains(template.getHypervisorType())) { // only download sys template applicable for current hypervisor TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId()); if (tmpltHost == null || tmpltHost.getState() != ObjectInDataStoreStateMachine.State.Ready) { TemplateInfo tmplt = _templateFactory.getTemplate(template.getId(), DataStoreRole.Image); createTemplateAsync(tmplt, store, null); } } } }
if (result.isSuccess()) { if (imageStore.getScope().getScopeType() == ScopeType.REGION) { associateTemplateToZone(templateId, null); } else if (imageStore.getScope().getScopeType() == ScopeType.ZONE) { Long zoneId = ((ImageStoreEntity)imageStore).getDataCenterId(); VMTemplateZoneVO templateZone = new VMTemplateZoneVO(zoneId, templateId, new Date());
@Override public DataStore getCacheStore(Scope scope) { if (scope.getScopeType() != ScopeType.ZONE) { s_logger.debug("Can only support zone wide cache storage"); return null; } List<DataStore> cacheStores = dataStoreMgr.getImageCacheStores(scope); if ((cacheStores == null) || (cacheStores.size() <= 0)) { s_logger.debug("Can't find staging storage in zone: " + scope.getScopeId()); return null; } return imageStoreMgr.getImageStore(cacheStores); }
Long zoneId = imageStore.getScope().getScopeId(); if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId);
if (store.getScope().getScopeType() == ScopeType.REGION) { if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED && volumeHost.getInstallPath() == null) { s_logger.info("Skip sync volume for migration of previous NFS to object store");
protected EndPoint findEndpointForImageStorage(DataStore store) { Long dcId = null; Scope storeScope = store.getScope(); if (storeScope.getScopeType() == ScopeType.ZONE) { dcId = storeScope.getScopeId(); } // find ssvm that can be used to download data to store. For zone-wide // image store, use SSVM for that zone. For region-wide store, // we can arbitrarily pick one ssvm to do that task List<HostVO> ssAHosts = listUpAndConnectingSecondaryStorageVmHost(dcId); if (ssAHosts == null || ssAHosts.isEmpty()) { return null; } Collections.shuffle(ssAHosts); HostVO host = ssAHosts.get(0); return RemoteHostEndPoint.getHypervisorHostEndPoint(host); }
if (dsScope.getScopeId() != null) { UsageEventUtils.publishUsageEvent(etype, template.getAccountId(), dsScope.getScopeId(), template.getId(), template.getName(), null, null, physicalSize, template.getSize(), VirtualMachineTemplate.class.getName(), template.getUuid()); } else {
@Override public List<DataStore> listImageCacheStores(Scope scope) { if (scope.getScopeType() != ScopeType.ZONE) { s_logger.debug("only support zone wide image cache stores"); return null; } List<ImageStoreVO> stores = dataStoreDao.findImageCacheByScope(new ZoneScope(scope.getScopeId())); List<DataStore> imageStores = new ArrayList<DataStore>(); for (ImageStoreVO store : stores) { imageStores.add(getImageStore(store.getId())); } return imageStores; }
Long zoneId_is = imageStore.getScope().getScopeId(); if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId_is);
if (scope.getScopeType() == ScopeType.HOST) { sbuilder.append(" and h.id = "); sbuilder.append(scope.getScopeId()); } else if (scope.getScopeType() == ScopeType.CLUSTER) { sbuilder.append(" and h.cluster_id = "); sbuilder.append(scope.getScopeId()); } else if (scope.getScopeType() == ScopeType.ZONE) { sbuilder.append(" and h.data_center_id = "); sbuilder.append(scope.getScopeId());
ImageStoreEntity imageStore = (ImageStoreEntity)dataStoreMgr.getImageStore(destScope.getScopeId()); if (!imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) { s_logger.debug("can't find a nfs (or cifs) image store to satisfy the need for a staging store");
@Override public DataObject createCacheObject(DataObject data, Scope scope) { DataStore cacheStore = getCacheStorage(scope); if (cacheStore == null) { String errMsg = "No cache DataStore in scope id " + scope.getScopeId() + " type " + scope.getScopeType().toString(); throw new CloudRuntimeException(errMsg); } return this.createCacheObject(data, cacheStore); }
if (syncLock.lock(3)) { try { Long zoneId = store.getScope().getScopeId();