protected boolean moveBetweenCacheAndImage(DataStore srcStore, DataStore destStore) { DataStoreRole srcRole = srcStore.getRole(); DataStoreRole destRole = destStore.getRole(); if (srcRole == DataStoreRole.Image && destRole == DataStoreRole.ImageCache || srcRole == DataStoreRole.ImageCache && destRole == DataStoreRole.Image) { return true; } else { return false; } }
protected boolean moveBetweenPrimaryImage(DataStore srcStore, DataStore destStore) { DataStoreRole srcRole = srcStore.getRole(); DataStoreRole destRole = destStore.getRole(); if ((srcRole == DataStoreRole.Primary && destRole.isImageStore()) || (srcRole.isImageStore() && destRole == DataStoreRole.Primary)) { return true; } else { return false; } }
@Override public Long getRefCount() { if (store == null) { return null; } if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) { SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId()); return store.getRefCnt(); } return null; }
@Override public Long getRefCount() { if (dataStore == null) { return null; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId()); return store.getRefCnt(); } return null; }
@Override public Long getRefCount() { if (dataStore == null) { return null; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); return store.getRefCnt(); } return null; }
@Override public void decRefCount() { if (store == null) { return; } if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) { SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId()); store.decrRefCnt(); store.setLastUpdated(new Date()); snapshotStoreDao.update(store.getId(), store); } }
@Override public void incRefCount() { if (store == null) { return; } if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) { SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId()); store.incrRefCnt(); store.setLastUpdated(new Date()); snapshotStoreDao.update(store.getId(), store); } }
@Override public void decRefCount() { if (dataStore == null) { return; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId()); store.decrRefCnt(); store.setLastUpdated(new Date()); templateStoreDao.update(store.getId(), store); } }
@Override public void decRefCount() { if (dataStore == null) { return; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); store.decrRefCnt(); store.setLastUpdated(new Date()); volumeStoreDao.update(store.getId(), store); } }
private void verifySnapshotType(SnapshotInfo snapshotInfo) { if (snapshotInfo.getHypervisorType() == HypervisorType.KVM && snapshotInfo.getDataStore().getRole() != DataStoreRole.Primary) { throw new CloudRuntimeException("For the KVM hypervisor type, you can only revert a volume to a snapshot state if the snapshot " + "resides on primary storage. For other snapshot types, create a volume from the snapshot to recover its data."); } }
@Override public void incRefCount() { if (dataStore == null) { return; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId()); store.incrRefCnt(); store.setLastUpdated(new Date()); templateStoreDao.update(store.getId(), store); } }
@Override public void incRefCount() { if (dataStore == null) { return; } if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); store.incrRefCnt(); store.setLastUpdated(new Date()); volumeStoreDao.update(store.getId(), store); } }
@Override public String getPath() { if (dataStore.getRole() == DataStoreRole.Primary) { return volumeVO.getPath(); } else { DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore); if (objInStore != null) { return objInStore.getInstallPath(); } else { return null; } } }
private void handleCopyAsyncForSnapshot(SnapshotInfo srcSnapshotInfo, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) { verifyFormat(srcSnapshotInfo); boolean canHandleSrc = canHandle(srcSnapshotInfo); if (canHandleSrc && (destData instanceof TemplateInfo || destData instanceof SnapshotInfo) && (destData.getDataStore().getRole() == DataStoreRole.Image || destData.getDataStore().getRole() == DataStoreRole.ImageCache)) { handleCopyAsyncToSecondaryStorage(srcSnapshotInfo, destData, callback); } else if (destData instanceof VolumeInfo) { handleCopyAsyncForSnapshotToVolume(srcSnapshotInfo, (VolumeInfo)destData, callback); } else { handleError(OPERATION_NOT_SUPPORTED, callback); } }
private boolean isVolumeOnManagedStorage(VolumeInfo volumeInfo) { DataStore dataStore = volumeInfo.getDataStore(); if (dataStore.getRole() == DataStoreRole.Primary) { long storagePooldId = dataStore.getId(); StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePooldId); return storagePoolVO.isManaged(); } return false; }
@Override public SnapshotInfo getParent() { SnapshotDataStoreVO snapStoreVO = snapshotStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshot.getId()); Long parentId = null; if (snapStoreVO != null) { parentId = snapStoreVO.getParentSnapshotId(); if (parentId != null && parentId != 0) { return snapshotFactory.getSnapshot(parentId, store); } } return null; }
@Override public DataStoreTO getStoreTO(DataStore store) { ImageStoreImpl nfsStore = (ImageStoreImpl)store; NfsTO nfsTO = new NfsTO(); nfsTO.setRole(store.getRole()); nfsTO.setUrl(nfsStore.getUri()); nfsTO.setNfsVersion(getNfsVersion(nfsStore.getId())); return nfsTO; }
@Override public String getUri() { if (dataStore == null) { throw new CloudRuntimeException("datastore must be set before using this object"); } DataObjectInStore obj = objectInStoreMgr.findObject(volumeVO.getId(), DataObjectType.VOLUME, dataStore.getId(), dataStore.getRole()); if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) { return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" + EncodingType.NAME + "=" + volumeVO.getName(); } else { return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath(); } }
@Override public SnapshotInfo getChild() { QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class); sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId()); sc.and(sc.entity().getRole(), Op.EQ, store.getRole()); sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error); sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId()); SnapshotDataStoreVO vo = sc.find(); if (vo == null) { return null; } return snapshotFactory.getSnapshot(vo.getId(), store); }