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));
}
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));
}
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));
}
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);
}
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;
}
Aggregations