@Override public void postSnapshotCreation(SnapshotInfo snapshot) { updateLocationTypeInDb(snapshot); if (snapshot.getLocationType() == Snapshot.LocationType.SECONDARY) { // remove the snapshot on primary storage try { snapshotSvr.deleteSnapshot(snapshot); } catch (Exception e) { s_logger.warn("Failed to clean up snapshot '" + snapshot.getId() + "' on primary storage: " + e.getMessage()); } } }
private void verifyLocationType(SnapshotInfo snapshotInfo) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume(); if (snapshotInfo.getLocationType() == Snapshot.LocationType.SECONDARY && volumeInfo.getFormat() != ImageFormat.VHD) { throw new CloudRuntimeException("Only the '" + ImageFormat.VHD + "' image type can be used when 'LocationType' is set to 'SECONDARY'."); } }
@Override public SnapshotInfo backupSnapshot(SnapshotInfo snapshotInfo) { Preconditions.checkArgument(snapshotInfo != null, "'snapshotInfo' cannot be 'null'."); if (snapshotInfo.getLocationType() != Snapshot.LocationType.SECONDARY) { markAsBackedUp((SnapshotObject)snapshotInfo); return snapshotInfo; } // At this point, the snapshot is either taken as a native // snapshot on the storage or exists as a volume on the storage (clone). // If archive flag is passed in, we should copy this snapshot to secondary // storage and delete it from primary storage. HostVO host = getHost(snapshotInfo.getVolumeId()); boolean canStorageSystemCreateVolumeFromSnapshot = canStorageSystemCreateVolumeFromSnapshot(snapshotInfo.getBaseVolume().getPoolId()); if (!canStorageSystemCreateVolumeFromSnapshot) { String msg = "Cannot archive snapshot: 'canStorageSystemCreateVolumeFromSnapshot' was false."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(host.getClusterId()); if (!computeClusterSupportsResign) { String msg = "Cannot archive snapshot: 'computeClusterSupportsResign' was false."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } return snapshotSvr.backupSnapshot(snapshotInfo); }
Snapshot.LocationType locationType = snapshotInfo.getLocationType();