Search in sources :

Example 16 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationReplicationGroups.

@Asset("replicationGroup")
@AssetDependencies({ "application", "applicationSnapshotVirtualArray" })
public List<AssetOption> getApplicationReplicationGroups(AssetOptionsContext ctx, URI applicationId, String virtualArrayParameter) {
    ViPRCoreClient client = api(ctx);
    boolean isTarget = false;
    URI virtualArray = null;
    if (virtualArrayParameter != null && StringUtils.split(virtualArrayParameter, ':')[0].equals("tgt")) {
        virtualArray = URI.create(StringUtils.substringAfter(virtualArrayParameter, ":"));
        isTarget = true;
    } else {
        isTarget = false;
    }
    Set<String> subGroups = Sets.newHashSet();
    NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
    for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
        VolumeRestRep volume = client.blockVolumes().get(volumeId);
        VolumeRestRep parentVolume = volume;
        if (volume.getHaVolumes() != null && !volume.getHaVolumes().isEmpty()) {
            volume = BlockStorageUtils.getVPlexSourceVolume(client, volume);
        }
        if (volume != null && volume.getReplicationGroupInstance() != null) {
            if (isTarget) {
                if (volume.getVirtualArray().getId().equals(virtualArray)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            } else {
                if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            }
        }
    }
    return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(subGroups));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) 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)

Example 17 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class BlockProvider method getVplexSnapshotVolumes.

@Asset("vplexVolumeWithSnapshots")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVplexSnapshotVolumes(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        Set<URI> volIdSet = new HashSet<>();
        List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
        for (BlockSnapshotRestRep s : snapshots) {
            volIdSet.add(s.getParent().getId());
        }
        // Have to get volumes just as it needs vol's mount point which snapshot doesn't have.
        List<VolumeRestRep> volumes = getVolumesByIds(client, volIdSet);
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep vol : volumes) {
            if (vol.getHaVolumes() != null && !vol.getHaVolumes().isEmpty() && !isInConsistencyGroup(vol)) {
                filteredVols.add(vol);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().findByProject(project, new DefaultResourceFilter<BlockConsistencyGroupRestRep>() {

            @Override
            public boolean accept(BlockConsistencyGroupRestRep cg) {
                if (cg.getTypes() != null && cg.getTypes().contains(Types.VPLEX.name())) {
                    return true;
                } else {
                    return false;
                }
            }
        });
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 18 with Asset

use of com.emc.sa.asset.annotation.Asset 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 19 with Asset

use of com.emc.sa.asset.annotation.Asset 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 20 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class BlockProvider method getApplications.

@Asset("application")
public List<AssetOption> getApplications(AssetOptionsContext ctx) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeGroupRestRep> volumeGroups = client.application().getApplications(new DefaultResourceFilter<VolumeGroupRestRep>() {

        @Override
        public boolean accept(VolumeGroupRestRep volumeGroup) {
            if (volumeGroup.getRoles() != null && volumeGroup.getRoles().contains(VolumeGroup.VolumeGroupRole.COPY.name())) {
                return true;
            } else {
                return false;
            }
        }
    });
    return createBaseResourceOptions(volumeGroups);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

Asset (com.emc.sa.asset.annotation.Asset)119 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)102 AssetOption (com.emc.vipr.model.catalog.AssetOption)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)72 URI (java.net.URI)47 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)35 ArrayList (java.util.ArrayList)23 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)17 HashSet (java.util.HashSet)15 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)13 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)8 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6