Search in sources :

Example 86 with ViPRCoreClient

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

Example 87 with ViPRCoreClient

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

the class BlockProvider method getVirtualArrayByConsistencyGroup.

@Asset("virtualArrayByConsistencyGroup")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getVirtualArrayByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
    ViPRCoreClient client = api(ctx);
    List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
    List<AssetOption> targets = Lists.newArrayList();
    if (!volumes.isEmpty()) {
        RelatedResourceRep varrayId = client.blockVolumes().get(volumes.get(0)).getVirtualArray();
        VirtualArrayRestRep virtualArray = client.varrays().get(varrayId);
        targets.add(createBaseResourceOption(virtualArray));
    }
    return targets;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 88 with ViPRCoreClient

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

the class BlockProvider method getLocalSnapshotBlockVolumes.

@Asset("localSnapshotBlockVolume")
@AssetDependencies({ "project" })
public List<AssetOption> getLocalSnapshotBlockVolumes(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 (isLocalSnapshotSupported(detail.vpool)) {
            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)

Example 89 with ViPRCoreClient

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

the class FileProvider method getFileWithContinuousCopies.

@Asset("fileWithContinuousCopies")
@AssetDependencies("project")
public List<AssetOption> getFileWithContinuousCopies(AssetOptionsContext ctx, URI project) {
    final ViPRCoreClient client = api(ctx);
    List<FileShareRestRep> fileShares = client.fileSystems().findByProject(project, new SourceTargetFileSystemsFilter() {

        @Override
        public boolean acceptId(URI id) {
            return !client.fileSystems().getFileContinuousCopies(id).isEmpty();
        }
    });
    return createFilesystemOptions(fileShares);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) SourceTargetFileSystemsFilter(com.emc.vipr.client.core.filters.SourceTargetFileSystemsFilter) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 90 with ViPRCoreClient

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

the class FileProvider method getFileTargetVirtualPools.

@Asset("fileTargetVirtualPool")
@AssetDependencies({ "fileFilePolicy" })
public List<AssetOption> getFileTargetVirtualPools(AssetOptionsContext ctx, URI filePolicy) {
    List<AssetOption> options = Lists.newArrayList();
    ViPRCoreClient client = api(ctx);
    FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
    List<FileVirtualPoolRestRep> vpoolChanges = client.fileVpools().getByTenant(ctx.getTenant());
    for (FileVirtualPoolRestRep vpool : vpoolChanges) {
        if (vpool.getProtection() != null) {
            if ((policyRest.getType().equals("file_snapshot") && vpool.getProtection().getScheduleSnapshots()) || (policyRest.getType().equals("file_replication") && vpool.getProtection().getReplicationSupported())) {
                options.add(new AssetOption(vpool.getId(), vpool.getName()));
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) 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