use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class RemoveNodes method getNodes.
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;
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class RemoveNodes method removeNodesFromLoadBalancer.
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);
// /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);
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class UpdateLoadBalancers method updateLoadBalancer.
private void updateLoadBalancer(LoadBalancer loadBalancer) throws TimeoutException {
System.out.println("Update Load Balancer");
UpdateLoadBalancer updateLB = UpdateLoadBalancer.builder().name(Constants.NAME + "-update").protocol("HTTPS").port(443).algorithm(LoadBalancer.Algorithm.RANDOM).build();
lbApi.update(loadBalancer.getId(), updateLB);
// /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(" " + true);
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class UpdateLoadBalancers method main.
/**
* To get a username and API key see http://www.jclouds.org/documentation/quickstart/rackspace/
*
* The first argument (args[0]) must be your username
* The second argument (args[1]) must be your API key
*/
public static void main(String[] args) {
UpdateLoadBalancers updateLoadBalancers = new UpdateLoadBalancers();
try {
updateLoadBalancers.init(args);
LoadBalancer loadBalancer = updateLoadBalancers.getLoadBalancer();
updateLoadBalancers.updateLoadBalancer(loadBalancer);
} catch (Exception e) {
e.printStackTrace();
} finally {
updateLoadBalancers.close();
}
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class UpdateNodes method updateNodesInLoadBalancer.
private void updateNodesInLoadBalancer(Set<Node> nodes, LoadBalancer loadBalancer) throws TimeoutException {
System.out.println("Update Nodes");
NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
UpdateNode updateNode = UpdateNode.builder().condition(Node.Condition.ENABLED).weight(20).build();
for (Node node : nodes) {
nodeApi.update(node.getId(), updateNode);
System.out.println(" " + node.getId() + " " + updateNode);
}
// /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);
}
}
Aggregations