@Override public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) { if (SnapshotOperation.REVERT.equals(op)) { long volumeId = snapshot.getVolumeId(); VolumeVO volumeVO = volumeDao.findById(volumeId); if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat())) { return StrategyPriority.DEFAULT; } return StrategyPriority.CANT_HANDLE; } return StrategyPriority.DEFAULT; }
@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); }
VolumeVO volume = findVolumeById(snapshot.getVolumeId()); String snapshotTypeStr = snapshot.getRecurringType().name(); snapshotResponse.setSnapshotType(snapshotTypeStr);
long volumeId = snapshot.getVolumeId();