Search in sources :

Example 6 with RelatedResourceRep

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);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) ArrayList(java.util.ArrayList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with RelatedResourceRep

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);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) ArrayList(java.util.ArrayList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 8 with RelatedResourceRep

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;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) HashMap(java.util.HashMap) URI(java.net.URI)

Example 9 with RelatedResourceRep

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);
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)

Example 10 with RelatedResourceRep

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));
    }
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)41 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)25 ArrayList (java.util.ArrayList)19 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)14 URI (java.net.URI)12 Asset (com.emc.sa.asset.annotation.Asset)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)5 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 StoragePortList (com.emc.storageos.model.ports.StoragePortList)4 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)3