Search in sources :

Example 41 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep 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 42 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method constructSnapshotSessionOptions.

protected List<AssetOption> constructSnapshotSessionOptions(ViPRCoreClient client, URI project, List<BlockSnapshotSessionRestRep> snapshotSessions) {
    List<AssetOption> options = Lists.newArrayList();
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
        options.add(new AssetOption(snapshotSession.getId(), getBlockObjectLabel(client, snapshotSession, volumeNames)));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 43 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep 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 44 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getReplicationGroupsForApplicationSnapshot.

protected Set<String> getReplicationGroupsForApplicationSnapshot(ViPRCoreClient client, URI applicationId, String copySet) {
    Set<String> options = Sets.newHashSet();
    VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
    input.setCopySetName(copySet);
    SnapshotList sessions = client.application().getVolumeGroupSnapshotsForSet(applicationId, input);
    for (NamedRelatedResourceRep snap : sessions.getSnapList()) {
        BlockSnapshotRestRep snapRep = client.blockSnapshots().get(snap);
        // TODO get replication group from parent. should the snapshot already contain this?
        VolumeRestRep parentVolume = client.blockVolumes().get(snapRep.getParent());
        if (parentVolume != null && parentVolume.getReplicationGroupInstance() != null) {
            options.add(parentVolume.getReplicationGroupInstance());
        }
    }
    return BlockStorageUtils.stripRPTargetFromReplicationGroup(options);
}
Also used : SnapshotList(com.emc.storageos.model.SnapshotList) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 45 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSourceVolumes.

@Asset("sourceBlockVolumeForAddToApplication")
@AssetDependencies({ "consistencyGroupAll" })
public List<AssetOption> getApplicationSourceVolumes(AssetOptionsContext ctx, URI cg) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupList applications = client.application().getApplications();
    List<URI> applicationIds = new ArrayList<URI>();
    for (NamedRelatedResourceRep volumeGroup : applications.getVolumeGroups()) {
        VolumeGroupRestRep vg = client.application().getApplication(volumeGroup.getId());
        if (vg.getRoles().contains("COPY")) {
            applicationIds.add(volumeGroup.getId());
        }
    }
    ResourceFilter<VolumeRestRep> cgFilter = new BlockVolumeConsistencyGroupFilter(cg, false);
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<VolumeRestRep> volumes = new ArrayList<VolumeRestRep>();
    for (ProjectRestRep project : projects) {
        volumes.addAll(listSourceVolumes(api(ctx), project.getId(), cgFilter));
    }
    List<VolumeRestRep> volumesNotInApplication = new ArrayList<VolumeRestRep>();
    for (VolumeRestRep volume : volumes) {
        if (volume.getVolumeGroups() != null && !volume.getVolumeGroups().isEmpty()) {
            boolean volumeIsInApplication = false;
            for (RelatedResourceRep rep : volume.getVolumeGroups()) {
                if (applicationIds.contains(rep.getId())) {
                    volumeIsInApplication = true;
                    break;
                }
            }
            if (!volumeIsInApplication) {
                volumesNotInApplication.add(volume);
            }
        } else {
            volumesNotInApplication.add(volume);
        }
    }
    return createVolumeOptions(null, volumesNotInApplication);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) BlockVolumeConsistencyGroupFilter(com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)136 URI (java.net.URI)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)49 Asset (com.emc.sa.asset.annotation.Asset)35 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)35 ArrayList (java.util.ArrayList)25 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)23 AssetOption (com.emc.vipr.model.catalog.AssetOption)20 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)13 HashSet (java.util.HashSet)13 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)12 Test (org.junit.Test)12 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)11 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)9 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)7 List (java.util.List)7 SnapshotList (com.emc.storageos.model.SnapshotList)6