return cfgResponse;
}
@Override
public SnapshotResponse createSnapshotResponse(Snapshot snapshot) {
SnapshotResponse snapshotResponse = new SnapshotResponse();
snapshotResponse.setId(snapshot.getUuid());
populateOwner(snapshotResponse, snapshot);
VolumeVO volume = findVolumeById(snapshot.getVolumeId());
String snapshotTypeStr = snapshot.getRecurringType().name();
snapshotResponse.setSnapshotType(snapshotTypeStr);
if (volume != null) {
snapshotResponse.setVolumeId(volume.getUuid());
snapshotResponse.setVolumeName(volume.getName());
snapshotResponse.setVolumeType(volume.getVolumeType().name());
}
snapshotResponse.setCreated(snapshot.getCreated());
snapshotResponse.setName(snapshot.getName());
snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId()));
snapshotResponse.setState(snapshot.getState());
SnapshotInfo snapshotInfo = null;
if (!(snapshot instanceof SnapshotInfo)) {
snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(), DataStoreRole.Image);
} else {
snapshotInfo = (SnapshotInfo)snapshot;
}
if (snapshotInfo == null) {
s_logger.debug("Unable to find info for image store snapshot with uuid "+snapshot.getUuid());
snapshotResponse.setRevertable(false);
}else{
snapshotResponse.setRevertable(snapshotInfo.isRevertable());
}
// set tag information
List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.Snapshot, snapshot.getId());
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
for (ResourceTag tag : tags) {
ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
tagResponses.add(tagResponse);
}
snapshotResponse.setTags(tagResponses);
snapshotResponse.setObjectName("snapshot");
return snapshotResponse;
}