private Set<Node> getNodes(LoadBalancer loadBalancer) { NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId()); Set<Node> nodes = Sets.newHashSet(); for (Node node : nodeApi.list().concat()) { if (node.getAddress().startsWith("10.180.1")) { nodes.add(node); } } return nodes; }
private void removeNodesFromLoadBalancer(Set<Node> nodes, LoadBalancer loadBalancer) throws TimeoutException { System.out.println("Remove Nodes"); NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId()); Iterable<Integer> nodeIds = Iterables.transform(nodes, new NodeToInteger()); nodeApi.remove(nodeIds); // Wait for the Load Balancer to become Active before moving on // If you want to know what's happening during the polling, enable logging. See // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java if (!LoadBalancerPredicates.awaitAvailable(lbApi).apply(loadBalancer)) { throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer); } System.out.println(" " + nodeIds); }