protected EndPoint findEndpointForPrimaryStorage(DataStore store) { return findEndPointInScope(store.getScope(), findOneHostOnPrimaryStorage, store.getId()); }
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); }
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; }
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; }
@Override public EndPoint select(DataObject object) { DataStore store = object.getDataStore(); EndPoint ep = select(store); if (ep != null) { return ep; } if (object instanceof TemplateInfo) { TemplateInfo tmplInfo = (TemplateInfo)object; if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null && tmplInfo.getTemplateType() == TemplateType.SYSTEM) { return LocalHostEndpoint.getEndpoint(); // for bootstrap system vm template downloading to region image store } } return null; }
@Override public List<EndPoint> selectAll(DataStore store) { List<EndPoint> endPoints = new ArrayList<EndPoint>(); if (store.getScope().getScopeType() == ScopeType.HOST) { HostVO host = hostDao.findById(store.getScope().getScopeId()); endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host)); } else if (store.getScope().getScopeType() == ScopeType.CLUSTER) { QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getClusterId(), Op.EQ, store.getScope().getScopeId()); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); List<HostVO> hosts = sc.list(); for (HostVO host : hosts) { endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host)); } } else { throw new CloudRuntimeException("shouldn't use it for other scope"); } return endPoints; } }
@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); } } } }
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); }
Long zoneId = imageStore.getScope().getScopeId(); if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId);
needCache = true; SnapshotInfo snapshot = (SnapshotInfo) srcData; srcData = cacheSnapshotChain(snapshot, snapshot.getDataStore().getScope());
Long zoneId_is = imageStore.getScope().getScopeId(); if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId_is);
int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue())); Scope destScope = getZoneScope(destData.getDataStore().getScope()); DataStore cacheStore = cacheMgr.getCacheStorage(destScope); if (cacheStore == 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());
" at the end of registering template!"); Scope dsScope = ds.getScope(); if (dsScope.getScopeId() != null) { UsageEventUtils.publishUsageEvent(etype, template.getAccountId(), dsScope.getScopeId(), template.getId(), template.getName(), null, null,
DataStore storeForNewVol = dataStoreMgr.getPrimaryDataStore(newVolume.getPoolId()); Scope storeForExistingStoreScope = storeForExistingVol.getScope(); if (storeForExistingStoreScope == null) { throw new CloudRuntimeException("Can't get scope of data store: " + storeForExistingVol.getId()); Scope storeForNewStoreScope = storeForNewVol.getScope(); if (storeForNewStoreScope == null) { throw new CloudRuntimeException("Can't get scope of data store: " + storeForNewVol.getId());
" at the end of registering template!"); Scope dsScope = ds.getScope(); if (dsScope.getScopeType() == ScopeType.ZONE) { if (dsScope.getScopeId() != null) {
@Override public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); VirtualMachineTemplate tmpl = _templateDao.findById(data.getId()); DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope()); DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes); dcmd.setCacheStore(cacheStore.getTO()); dcmd.setProxy(getHttpProxy()); EndPoint ep = _epSelector.select(data); if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data); AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this); caller.setContext(context); if (data.getType() == DataObjectType.TEMPLATE) { caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null)); } else if (data.getType() == DataObjectType.VOLUME) { caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null)); } ep.sendMessageAsync(dcmd, caller); }
s_logger.warn("No entry found in volume_store_ref for volume id: " + vo.getId() + " and image store id: " + ds.getId() + " at the end of uploading volume!"); Scope dsScope = ds.getScope(); if (dsScope.getScopeType() == ScopeType.ZONE) { if (dsScope.getScopeId() != null) {