Search in sources :

Example 61 with Asset

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

the class BlockProvider method getBlockVolumes.

@Asset("unassignedBlockVolume")
@AssetDependencies({ "host", "project", "blockStorageType" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId, String blockStorageType) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    // get varray IDs for host/cluster
    List<VirtualArrayRestRep> varrays = new ArrayList<>();
    if (EXCLUSIVE_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Host.class)) {
        varrays = client.varrays().findByConnectedHost(hostOrClusterId);
    } else if (SHARED_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Cluster.class)) {
        varrays = client.varrays().findByConnectedCluster(hostOrClusterId);
    }
    List<URI> varrayIds = new ArrayList<>();
    for (VirtualArrayRestRep varray : varrays) {
        varrayIds.add(varray.getId());
    }
    // remove volumes not in hosts/cluster's varray
    Iterator<VolumeRestRep> itr = volumes.iterator();
    while (itr.hasNext()) {
        if (!varrayIds.contains(itr.next().getVirtualArray().getId())) {
            itr.remove();
        }
    }
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 62 with Asset

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

the class BlockProvider method getBlockSnapshotType.

@Asset("blockSnapshotType")
@AssetDependencies({ "blockVolumeOrConsistencyType", "snapshotBlockVolume" })
public List<AssetOption> getBlockSnapshotType(AssetOptionsContext ctx, String storageType, URI blockVolumeOrCG) {
    // These are hard coded values for now. In the future, this may be available through an API
    List<AssetOption> options = Lists.newArrayList();
    if (isConsistencyGroupType(blockVolumeOrCG)) {
        options.add(CG_SNAPSHOT_TYPE_OPTION);
        // Only add cg session option if the CG selected supports it
        ViPRCoreClient client = api(ctx);
        BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(blockVolumeOrCG);
        if (isSnapshotSessionSupportedForCG(cg)) {
            options.add(CG_SNAPSHOT_SESSION_TYPE_OPTION);
        }
    } else {
        debug("getting blockSnapshotTypes (blockVolume=%s)", blockVolumeOrCG);
        ViPRCoreClient client = api(ctx);
        VolumeRestRep volume = client.blockVolumes().get(blockVolumeOrCG);
        BlockVirtualPoolRestRep virtualPool = client.blockVpools().get(volume.getVirtualPool());
        if (isLocalSnapshotSupported(virtualPool)) {
            options.add(LOCAL_ARRAY_SNAPSHOT_TYPE_OPTION);
        }
        if (isRPSourceVolume(volume)) {
            options.add(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_OPTION);
        }
        if (isSnapshotSessionSupportedForVolume(volume)) {
            options.add(SNAPSHOT_SESSION_TYPE_OPTION);
        }
    }
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 63 with Asset

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

the class BlockProvider method getAddMobilityGroupResources.

@Asset("addMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getAddMobilityGroupResources(AssetOptionsContext ctx, final URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        // VPLEX volumes that don't have reference to this mobility group
        List<URI> volumeIds = client.blockVolumes().listBulkIds();
        final ResourceFilter<VolumeRestRep> vplexFilter = new VplexVolumeFilter();
        List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, new ResourceFilter<VolumeRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(VolumeRestRep item) {
                boolean accept = (item.getVolumeGroups() == null || !contains(item, mobilityGroupId)) && vplexFilter.accept(item);
                if (accept) {
                    boolean rpProtection = (item.getProtection() != null && item.getProtection().getRpRep() != null && item.getProtection().getRpRep().getPersonality() != null);
                    if (rpProtection) {
                        // If RP+VPLEX protection specified, only allow RP SOURCE volumes to be listed
                        // as candidates for mobility groups. Exclude TARGETs and JOURNALs.
                        String personality = item.getProtection().getRpRep().getPersonality();
                        if (Volume.PersonalityTypes.TARGET.name().equals(personality) || Volume.PersonalityTypes.METADATA.name().equals(personality)) {
                            accept = false;
                        }
                    }
                }
                return accept;
            }

            private boolean contains(VolumeRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(volumes);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        List<URI> hostIds = client.hosts().listBulkIds();
        List<HostRestRep> hosts = client.hosts().getByIds(hostIds, new ResourceFilter<HostRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(HostRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(HostRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(hosts);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        List<URI> clusterIds = client.clusters().listBulkIds();
        List<ClusterRestRep> clusters = client.clusters().getByIds(clusterIds, new ResourceFilter<ClusterRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(ClusterRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(ClusterRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(clusters);
    } else {
        return Lists.newArrayList();
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ResourceFilter(com.emc.vipr.client.core.filters.ResourceFilter) HostRestRep(com.emc.storageos.model.host.HostRestRep) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 64 with Asset

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

the class BlockProvider method getApplicationReplicationGroupsForCopy.

@Asset("copyReplicationGroup")
@AssetDependencies({ "application", "restoreFullCopyName" })
public List<AssetOption> getApplicationReplicationGroupsForCopy(AssetOptionsContext ctx, URI applicationId, String copyName) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeRestRep> allCopyVols = client.blockVolumes().getByRefs(client.application().getFullCopiesByApplication(applicationId).getVolumes());
    return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(groupFullCopyByApplicationSubGroup(ctx, filterByCopyName(allCopyVols, copyName)).keySet()));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 65 with Asset

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

the class BlockProvider method getSnapshotSessionBlockVolumes.

@Asset("snapshotSessionBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotSessionBlockVolumes(AssetOptionsContext context, URI project, String storageType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(storageType)) {
        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) {
            boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
            boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
            boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
            boolean isInConsistencyGroup = !StringUtils.isEmpty(detail.volume.getReplicationGroupInstance());
            boolean isSnapshotSessionSupported = isSnapshotSessionSupportedForVolume(detail.volume);
            debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s, isXio3XVolume=%s ]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup, isSnapshotSessionSupported);
            if (isSnapshotSessionSupported && localSnapSupported && !isInConsistencyGroup) {
                options.add(createVolumeOption(client, null, detail.volume, volumeNames));
            }
        }
        return options;
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) 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)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