use of com.emc.storageos.model.block.BlockSnapshotSessionList in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroupSnapshotSessionsByCopySet.
/**
* List snapshot sessions in a session set for a volume group.
*
* @param volumeGroupId The URI of the volume group
* @param param the VolumeGroupCopySetParam containing set name
* @return BlockSnapshotSessionList
* @brief List snapshot sessions in session set for a volume group
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessionsByCopySet(@PathParam("id") final URI volumeGroupId, final VolumeGroupCopySetParam param) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
// query volume group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
// validate snap session set name
String sessionsetName = param.getCopySetName();
ArgValidator.checkFieldNotNull(sessionsetName, COPY_SET_NAME_FIELD);
// get the snapshot sessions for the given set name in the volume group
BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
// validate that the provided set name actually belongs to this Application
VolumeGroupCopySetList copySetList = getVolumeGroupSnapsetSessionSets(volumeGroup);
if (copySetList.getCopySets().contains(sessionsetName)) {
// get the snapshot sessions for the volume group
List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
for (BlockSnapshotSession session : volumeGroupSessions) {
if (sessionsetName.equals(session.getSessionSetName())) {
snapshotSessionList.getSnapSessionRelatedResourceList().add(toNamedRelatedResource(session));
}
}
}
return snapshotSessionList;
}
use of com.emc.storageos.model.block.BlockSnapshotSessionList in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroupSnapshotSessions.
/**
* List snapshot sessions for a volume group
*
* @param volumeGroupId The URI of the volume group.
* @brief List snapshot session for a volume group
* @return BlockSnapshotSessionList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessions(@PathParam("id") final URI volumeGroupId) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
// query volume group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
// get the snapshot sessions for each CG in the volume group
BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
// get all snapshot sessions for the volume group
List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
for (BlockSnapshotSession session : volumeGroupSessions) {
snapshotSessionList.getSnapSessionRelatedResourceList().add(toNamedRelatedResource(session));
}
return snapshotSessionList;
}
use of com.emc.storageos.model.block.BlockSnapshotSessionList in project coprhd-controller by CoprHD.
the class BlockProvider method getLinkedSnapshotsForApplicationSnapshotSessionVolumeNew.
@Asset("linkedSnapshotsForApplicationSnapshotSessionLinkService")
@AssetDependencies({ "application", "applicationSnapshotSessionCopySets" })
public List<AssetOption> getLinkedSnapshotsForApplicationSnapshotSessionVolumeNew(AssetOptionsContext ctx, URI application, String selectedCopySet) {
ViPRCoreClient client = api(ctx);
List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
Set<String> replicationGroups = getReplicationGroupsForApplicationSnapshotSession(client, application, selectedCopySet);
Set<String> copySets = client.application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
List<BlockSnapshotSessionRestRep> snapshotSessions = Lists.newArrayList();
for (String copySet : copySets) {
VolumeGroupCopySetParam param = new VolumeGroupCopySetParam();
param.setCopySetName(copySet);
BlockSnapshotSessionList snapshotSessionList = client.application().getVolumeGroupSnapshotSessionsByCopySet(application, param);
List<BlockSnapshotSessionRestRep> snapshotSessionsTmp = client.blockSnapshotSessions().getByRefs(snapshotSessionList.getSnapSessionRelatedResourceList());
snapshotSessions.addAll(snapshotSessionsTmp);
for (BlockSnapshotSessionRestRep session : snapshotSessionsTmp) {
if (replicationGroups.contains(BlockStorageUtils.stripRPTargetFromReplicationGroup(session.getReplicationGroupInstance()))) {
for (RelatedResourceRep target : session.getLinkedTarget()) {
BlockSnapshotRestRep blockSnapshot = client.blockSnapshots().get(target);
snapshots.add(blockSnapshot);
}
}
}
}
return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionList in project coprhd-controller by CoprHD.
the class BlockProvider method getLinkedSnapshotsForApplicationSnapshotSessionVolume.
@Asset("linkedSnapshotsForApplicationSnapshotSession")
@AssetDependencies({ "application", "applicationSnapshotSessionCopySets" })
public List<AssetOption> getLinkedSnapshotsForApplicationSnapshotSessionVolume(AssetOptionsContext ctx, URI application, String copySet) {
List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
VolumeGroupCopySetParam param = new VolumeGroupCopySetParam();
param.setCopySetName(copySet);
BlockSnapshotSessionList snapshotSessionList = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, param);
List<BlockSnapshotSessionRestRep> snapshotSessions = api(ctx).blockSnapshotSessions().getByRefs(snapshotSessionList.getSnapSessionRelatedResourceList());
for (BlockSnapshotSessionRestRep session : snapshotSessions) {
for (RelatedResourceRep target : session.getLinkedTarget()) {
BlockSnapshotRestRep blockSnapshot = api(ctx).blockSnapshots().get(target);
snapshots.add(blockSnapshot);
}
}
return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionList in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationSnapshotSessionCopySetsForRestore.
private Set<String> getApplicationSnapshotSessionCopySetsForRestore(AssetOptionsContext ctx, URI application) {
Set<String> restoreCopySets = new HashSet<String>();
Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
boolean isRP = false;
NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
isRP = BlockStorageUtils.isRPVolume(firstVol);
}
if (isRP) {
List<VolumeRestRep> applicationVolumes = api(ctx).blockVolumes().getByRefs(api(ctx).application().getVolumeByApplication(application).getVolumes());
Set<String> sourceRepGrpNames = new HashSet<String>();
for (VolumeRestRep volume : applicationVolumes) {
if (volume.getReplicationGroupInstance() != null && BlockStorageUtils.isRPSourceVolume(volume)) {
sourceRepGrpNames.add(volume.getReplicationGroupInstance());
}
}
for (String copySetName : copySetNames) {
VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
input.setCopySetName(copySetName);
BlockSnapshotSessionList sessions = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, input);
if (sessions != null && sessions.getSnapSessionRelatedResourceList() != null && !sessions.getSnapSessionRelatedResourceList().isEmpty()) {
BlockSnapshotSessionRestRep sessionRep = api(ctx).blockSnapshotSessions().get(sessions.getSnapSessionRelatedResourceList().get(0));
if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null && sourceRepGrpNames.contains(sessionRep.getReplicationGroupInstance())) {
restoreCopySets.add(copySetName);
}
}
}
} else {
restoreCopySets.addAll(copySetNames);
}
return restoreCopySets;
}
Aggregations