public DataStoreRole getDataStoreRole(Snapshot snapshot) { SnapshotDataStoreVO snapshotStore = _snapshotDataStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
private static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) { SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) { SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore == null) { return DataStoreRole.Image; } long storagePoolId = snapshotStore.getDataStoreId(); DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); if (dataStore == null) { return DataStoreRole.Image; } Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); if (mapCapabilities != null) { String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); Boolean supportsStorageSystemSnapshots = new Boolean(value); if (supportsStorageSystemSnapshots) { return DataStoreRole.Primary; } } return DataStoreRole.Image; }
@Override public void create() throws ResourceAllocationException { Snapshot snapshot = this._volumeService.allocSnapshotForVm(getVmId(), getVolumeId(), getSnapshotName()); if (snapshot != null) { this.setEntityId(snapshot.getId()); this.setEntityUuid(snapshot.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot from vm snapshot"); } }
@Override public void create() throws ResourceAllocationException { Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId(), getSnapshotName(), getLocationType()); if (snapshot != null) { setEntityId(snapshot.getId()); setEntityUuid(snapshot.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot"); } }
DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); DataStoreRole dataStoreRole = getDataStoreRole(snapshot); SnapshotInfo snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), dataStoreRole); snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), DataStoreRole.Primary); throw new CloudRuntimeException("Cannot find snapshot " + snapshot.getId()); snapInfo = snapshotFactory.getSnapshot(snapshot.getId(), dataStoreRole); if (snapInfo == null) { throw new CloudRuntimeException("Cannot find snapshot " + snapshot.getId() + " on secondary and could not create backup");
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image); snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); boolean usingBackendSnapshot = usingBackendSnapshotFor(snapshot.getId());
@Override public List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long snapshotId, Long volumeId, boolean readyOnly) { Long zoneId = null; if (snapshotId != null) { Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId); VolumeVO volume = findVolumeById(snapshot.getVolumeId()); // it seems that the volume can actually be removed from the DB at some point if it's deleted // if volume comes back null, use another technique to try to discover the zone if (volume == null) { SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary); if (snapshotStore != null) { long storagePoolId = snapshotStore.getDataStoreId(); StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); if (storagePool != null) { zoneId = storagePool.getDataCenterId(); } } } else { zoneId = volume.getDataCenterId(); } } else { VolumeVO volume = findVolumeById(volumeId); zoneId = volume.getDataCenterId(); } if (zoneId == null) { throw new CloudRuntimeException("Unable to determine the zone ID"); } return createTemplateResponses(view, templateId, zoneId, readyOnly); }
snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId())); snapshotResponse.setState(snapshot.getState()); snapshotResponse.setLocationType(ApiDBUtils.getSnapshotLocationType(snapshot.getId())); DataStoreRole dataStoreRole = getDataStoreRole(snapshot, _snapshotStoreDao, _dataStoreMgr); snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(), dataStoreRole); List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.Snapshot, snapshot.getId()); List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>(); for (ResourceTag tag : tags) {
@Override public void create() throws ResourceAllocationException { final Snapshot snapshot = this._volumeService.allocSnapshotForVm(getVmId(), getVolumeId(), getSnapshotName()); if (snapshot != null) { this.setEntityId(snapshot.getId()); this.setEntityUuid(snapshot.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot from vm snapshot"); } }
@Override public void create() throws ResourceAllocationException { final Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId(), getSnapshotName()); if (snapshot != null) { setEntityId(snapshot.getId()); setEntityUuid(snapshot.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot"); } }