Search in sources :

Example 76 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class BlockProvider method getBlockVolumes.

@Asset("unassignedVplexBlockVolume")
@AssetDependencies({ "project", "host", "virtualArray" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, final URI projectId, URI hostOrClusterId, URI virtualArrayId) {
    // get a list of all 'source' volumes that :
    // - are in this project and not exported to the given host/cluster
    // - are a 'source' volume
    // - are vplex volumes
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, virtualArrayId);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    VplexVolumeFilter vplexVolumeFilter = new VplexVolumeFilter();
    CachedResources<BlockVirtualPoolRestRep> blockVpools = new CachedResources<>(client.blockVpools());
    VplexVolumeVirtualPoolFilter virtualPoolFilter = new VplexVolumeVirtualPoolFilter(blockVpools);
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    FilterChain<VolumeRestRep> filter = sourceTargetVolumesFilter.and(unexportedFilter).and(bootVolumeFilter.not()).and(vplexVolumeFilter.or(virtualPoolFilter));
    // perform the query and apply the filter
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, filter);
    // get a list of all volumes from our list that are in the target VArray, or use the target VArray for protection
    List<BlockObjectRestRep> acceptedVolumes = getVPlexVolumesInTargetVArray(client, virtualArrayId, volumes);
    return createVolumeOptions(client, acceptedVolumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) CachedResources(com.emc.vipr.client.core.util.CachedResources) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 77 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPortGroups.

@Asset("exportChangePortGroup")
@AssetDependencies({ "host", "exportPathStorageSystem", "exportPathVirtualArray", "exportCurrentPortGroup" })
public List<AssetOption> getExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI storageSystemId, URI varrayId, URI exportCurrentPortGroupId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(varrayId, null, storageSystemId, null, null, true);
        // Get a handle of the actual port group list
        List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
        // Filter out the current port group as we do not want the user to see this an a valid option
        ResourceFilter<StoragePortGroupRestRep> filterExistingPG = new DefaultResourceFilter<StoragePortGroupRestRep>() {

            @Override
            public boolean accept(StoragePortGroupRestRep pg) {
                return !pg.getId().equals(exportCurrentPortGroupId);
            }
        };
        ResourceUtils.applyFilter(portGroups, filterExistingPG);
        return createPortGroupOptions(portGroups);
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 78 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class BlockProvider method listTargetVirtualPools.

/**
 * Returns a list of virtual pools where volume can be moved
 */
protected List<BlockVirtualPoolRestRep> listTargetVirtualPools(AssetOptionsContext ctx, URI volumeId, ResourceFilter<BlockVirtualPoolRestRep> filter) {
    ViPRCoreClient client = api(ctx);
    List<VirtualPoolChangeRep> vpoolChanges = client.blockVolumes().listVirtualPoolChangeCandidates(volumeId);
    List<URI> vpoolIds = Lists.newArrayList();
    for (VirtualPoolChangeRep change : vpoolChanges) {
        if (change.getAllowed()) {
            vpoolIds.add(change.getId());
        }
    }
    return client.blockVpools().getByIds(vpoolIds, filter);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) URI(java.net.URI)

Example 79 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class BlockProvider method getVolumesWithContinuousCopies.

@Asset("volumeWithContinuousCopies")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithContinuousCopies(AssetOptionsContext ctx, URI project) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, new SourceTargetVolumesFilter() {

        @Override
        public boolean accept(VolumeRestRep volume) {
            if (volume.getProtection() == null) {
                return false;
            }
            MirrorRestRep mirrors = volume.getProtection().getMirrorRep();
            if (mirrors == null || mirrors.getMirrors() == null || mirrors.getMirrors().isEmpty()) {
                return false;
            }
            return true;
        }
    });
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) MirrorRestRep(com.emc.storageos.model.block.VolumeRestRep.MirrorRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 80 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient 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)

Aggregations

ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)225 Asset (com.emc.sa.asset.annotation.Asset)72 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)66 URI (java.net.URI)66 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)49 FlashException (controllers.util.FlashException)48 AssetOption (com.emc.vipr.model.catalog.AssetOption)41 ArrayList (java.util.ArrayList)34 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)29 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)27 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)24 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)20 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)15 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)15 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)13 HashSet (java.util.HashSet)13 Task (com.emc.vipr.client.Task)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8