use of com.emc.storageos.model.RelatedResourceRep 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.RelatedResourceRep 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.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotWithSnapshotSessionOptions.
protected List<AssetOption> constructSnapshotWithSnapshotSessionOptions(List<BlockSnapshotRestRep> snapshots, List<BlockSnapshotSessionRestRep> snapshotSessions) {
List<AssetOption> options = Lists.newArrayList();
// Create a map of linked target URIs to snapshot session names for convenience when creating
// the option labels.
Map<URI, String> linkedSnapshotToSnapshotSessionMap = new HashMap<URI, String>();
for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
for (RelatedResourceRep linkedTarget : snapshotSession.getLinkedTarget()) {
linkedSnapshotToSnapshotSessionMap.put(linkedTarget.getId(), snapshotSession.getName());
}
}
for (BlockSnapshotRestRep snapshot : snapshots) {
// Ignore RP Bookmarks for snapshot session options
boolean isRPSnapshot = (snapshot.getTechnologyType() != null && snapshot.getTechnologyType().equalsIgnoreCase(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_VALUE));
boolean validSnapshotOption = snapshot.getTechnologyType() == null || !isRPSnapshot;
if (validSnapshotOption) {
options.add(new AssetOption(snapshot.getId(), getBlockSnapshotLinkedLabel(snapshot, linkedSnapshotToSnapshotSessionMap)));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class VMWareProvider method listDatacentersByVCenterAndCluster.
protected List<VcenterDataCenterRestRep> listDatacentersByVCenterAndCluster(AssetOptionsContext context, URI vcenterId, URI clusterId) {
ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
if (vcenterDatacenter == null) {
// return all datacenters for this datacenter
return api(context).vcenterDataCenters().getByVcenter(vcenterId, context.getTenant());
} else {
// return the datacenter this vipr cluster is already associated with in vcenter
VcenterDataCenterRestRep vcenterDataCenterRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId());
return Arrays.asList(vcenterDataCenterRestRep);
}
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockJournalSize.
@Asset("blockJournalSize")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getBlockJournalSize(AssetOptionsContext ctx, URI consistencyGroup) {
String minimumSize = null;
BlockConsistencyGroupRestRep cg = api(ctx).blockConsistencyGroups().get(consistencyGroup);
// Get the first volume in the consistency group. All volumes will be source volumes
RelatedResourceRep vol = cg.getVolumes().get(0);
VolumeRestRep volume = api(ctx).blockVolumes().get(vol);
if (volume.getProtection() != null && volume.getProtection().getRpRep() != null && volume.getProtection().getRpRep().getProtectionSet() != null) {
RelatedResourceRep protectionSetId = volume.getProtection().getRpRep().getProtectionSet();
ProtectionSetRestRep protectionSet = api(ctx).blockVolumes().getProtectionSet(volume.getId(), protectionSetId.getId());
List<URI> protectionSetVolumeIds = new ArrayList<URI>();
for (RelatedResourceRep protectionVolume : protectionSet.getVolumes()) {
protectionSetVolumeIds.add(protectionVolume.getId());
}
List<VolumeRestRep> protectionSetVolumes = api(ctx).blockVolumes().withInternal(true).getByIds(protectionSetVolumeIds, null);
for (VolumeRestRep protectionVolume : protectionSetVolumes) {
if (protectionVolume.getProtection().getRpRep().getPersonality().equalsIgnoreCase("METADATA")) {
String capacity = protectionVolume.getCapacity();
if (minimumSize == null || Float.parseFloat(capacity) < Float.parseFloat(minimumSize)) {
minimumSize = capacity;
}
}
}
}
if (minimumSize == null) {
return Lists.newArrayList();
} else {
return Lists.newArrayList(newAssetOption(minimumSize, minimumSize));
}
}
Aggregations