Search in sources :

Example 21 with AssetDependencies

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

the class BlockProvider method getVolumesByType.

@Asset("blockVolumeByType")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVolumesByType(AssetOptionsContext ctx, URI project, String type) {
    debug("getting volumes (project=%s)", project);
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(type)) {
        return createVolumeOptions(client, listVolumesWithoutConsistencyGroup(client, project));
    } 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) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 22 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies 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 23 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies 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 24 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies 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 25 with AssetDependencies

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

the class ComputeProvider method getComputeVirtualPoolForVirtualArray.

@Asset("computeVirtualPool")
@AssetDependencies({ "blockVirtualArray" })
public List<AssetOption> getComputeVirtualPoolForVirtualArray(AssetOptionsContext ctx, URI virtualArray) {
    debug("getting compute virtual pools");
    Collection<ComputeVirtualPoolRestRep> computeVirtualPools = api(ctx).computeVpools().getByVirtualArrayAndTenant(virtualArray, ctx.getTenant());
    List<AssetOption> options = Lists.newArrayList();
    for (ComputeVirtualPoolRestRep value : computeVirtualPools) {
        options.add(createComputeVirtualPoolOption(ctx, value));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) 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