Search in sources :

Example 1 with DefaultResourceFilter

use of com.emc.vipr.client.core.filters.DefaultResourceFilter in project coprhd-controller by CoprHD.

the class HostClusters method availableHostJson.

public static void availableHostJson(String id) {
    final URI clusterId = uri(id);
    ClusterRestRep cluster = ClusterUtils.getCluster(clusterId);
    List<HostRestRep> hosts = null;
    DefaultResourceFilter<HostRestRep> defaultHostResourceFilter = new DefaultResourceFilter<HostRestRep>() {

        @Override
        public boolean accept(HostRestRep hostRestRep) {
            return hostRestRep.getCluster() == null || !hostRestRep.getCluster().getId().equals(clusterId);
        }
    };
    // If we have existing hosts in the cluster, limit to that host type
    List<HostRestRep> existingHosts = ClusterUtils.getHosts(uri(id));
    if (!existingHosts.isEmpty()) {
        FilterChain<HostRestRep> hostTypeFilter = new FilterChain<HostRestRep>(new HostTypeFilter(existingHosts.get(0).getType()));
        hosts = getViprClient().hosts().getByTenant(cluster.getTenant().getId(), hostTypeFilter.and(defaultHostResourceFilter));
    } else {
        hosts = getViprClient().hosts().getByTenant(cluster.getTenant().getId(), defaultHostResourceFilter);
    }
    renderJSON(DataTablesSupport.createJSON(hosts, params));
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) FilterChain(com.emc.vipr.client.core.filters.FilterChain) URI(java.net.URI) HostTypeFilter(com.emc.vipr.client.core.filters.HostTypeFilter)

Example 2 with DefaultResourceFilter

use of com.emc.vipr.client.core.filters.DefaultResourceFilter in project coprhd-controller by CoprHD.

the class BlockExportGroups method availableClustersJson.

public static void availableClustersJson(String exportGroupId) {
    List<ClusterRestRep> availableClusters = Lists.newArrayList();
    ExportGroupRestRep exportGroup = getViprClient().blockExports().get(uri(exportGroupId));
    List<URI> allClusterIds = getViprClient().clusters().listBulkIds();
    final List<URI> exportGroupClusters = ResourceUtils.ids(exportGroup.getClusters());
    availableClusters = getViprClient().clusters().getByIds(allClusterIds, new DefaultResourceFilter<ClusterRestRep>() {

        @Override
        public boolean accept(ClusterRestRep item) {
            return !exportGroupClusters.contains(item.getId());
        }
    });
    renderJSON(DataTablesSupport.createJSON(availableClusters, params));
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) URI(java.net.URI)

Example 3 with DefaultResourceFilter

use of com.emc.vipr.client.core.filters.DefaultResourceFilter in project coprhd-controller by CoprHD.

the class BlockExportGroups method availableHostsJson.

public static void availableHostsJson(String exportGroupId) {
    List<HostRestRep> availableHosts = Lists.newArrayList();
    ExportGroupRestRep exportGroup = getViprClient().blockExports().get(uri(exportGroupId));
    final List<URI> exportGroupHosts = ResourceUtils.ids(exportGroup.getHosts());
    List<URI> hostIds = getValidHosts(exportGroup);
    if (!hostIds.isEmpty()) {
        availableHosts = getViprClient().hosts().getByIds(hostIds, new DefaultResourceFilter<HostRestRep>() {

            @Override
            public boolean accept(HostRestRep item) {
                return !exportGroupHosts.contains(item.getId());
            }
        });
    }
    renderJSON(DataTablesSupport.createJSON(availableHosts, params));
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) URI(java.net.URI)

Example 4 with DefaultResourceFilter

use of com.emc.vipr.client.core.filters.DefaultResourceFilter in project coprhd-controller by CoprHD.

the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.

@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
    if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
        warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
        return new ArrayList<AssetOption>();
    }
    List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
    List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    } else {
        snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
        snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
    }
    return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ArrayList(java.util.ArrayList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with DefaultResourceFilter

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

Aggregations

DefaultResourceFilter (com.emc.vipr.client.core.filters.DefaultResourceFilter)5 URI (java.net.URI)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)2 HostRestRep (com.emc.storageos.model.host.HostRestRep)2 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)1 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)1 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)1 StoragePortGroupRestRep (com.emc.storageos.model.portgroup.StoragePortGroupRestRep)1 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)1 FilterChain (com.emc.vipr.client.core.filters.FilterChain)1 HostTypeFilter (com.emc.vipr.client.core.filters.HostTypeFilter)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 ArrayList (java.util.ArrayList)1