Search in sources :

Example 1 with AssetDependencies

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

the class BlockProvider method getRemoveMobilityGroupResources.

@Asset("removeMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getRemoveMobilityGroupResources(AssetOptionsContext ctx, URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        return createNamedResourceOptions(client.application().listVolumes(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        return createNamedResourceOptions(client.application().getHosts(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        return createNamedResourceOptions(client.application().getClusters(mobilityGroupId));
    } else {
        return Lists.newArrayList();
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 2 with AssetDependencies

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

the class BlockProvider method getVolumesWithFullCopies.

@Asset("volumeWithFullCopies")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVolumesWithFullCopies(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        List<VolumeRestRep> volumes = findVolumesByProject(client, project);
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep vol : volumes) {
            if (vol.getProtection() == null || vol.getProtection().getFullCopyRep() == null || vol.getProtection().getFullCopyRep().getFullCopyVolumes() == null || vol.getProtection().getFullCopyRep().getFullCopyVolumes().isEmpty() || !StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
                continue;
            }
            filteredVols.add(vol);
        }
        log.info("Got volumes with full copies: [{}]", filteredVols.size());
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = api(ctx).blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with AssetDependencies

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

the class BlockProvider method getBlockVolumesWithSnapshot.

@Asset("blockVolumeWithSnapshot")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getBlockVolumesWithSnapshot(AssetOptionsContext context, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(volumeOrConsistencyType)) {
        Set<URI> volIdSet = new HashSet<>();
        List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
        for (BlockSnapshotRestRep snapshot : snapshots) {
            volIdSet.add(snapshot.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 (StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
                filteredVols.add(vol);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        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) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with AssetDependencies

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

the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.

@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
    if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
        warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
        return new ArrayList<AssetOption>();
    }
    List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
    List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    } else {
        snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    }
    return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ArrayList(java.util.ArrayList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with AssetDependencies

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

the class BlockProvider method getRemoteSnapshotBlockVolumes.

@Asset("remoteSnapshotBlockVolume")
@AssetDependencies({ "project" })
public List<AssetOption> getRemoteSnapshotBlockVolumes(AssetOptionsContext context, URI project) {
    final ViPRCoreClient client = api(context);
    List<VolumeRestRep> volumes = listVolumes(client, project);
    List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
    Map<URI, VolumeRestRep> volumeNames = ResourceUtils.mapById(volumes);
    List<AssetOption> options = Lists.newArrayList();
    for (VolumeDetail detail : volumeDetails) {
        if (isRemoteSnapshotSupported(detail.volume)) {
            options.add(createVolumeOption(client, null, detail.volume, volumeNames));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) 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

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