use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class UpdateNodes 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.getCondition().equals(Node.Condition.DISABLED)) {
nodes.add(node);
}
}
return nodes;
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class AddNodes method addNodesToLoadBalancer.
/**
* If you try to visit the IPv4 address of the Load Balancer itself, you will see a "Service Unavailable" message
* because the nodes from the createNodeRequests() don't really exist.
*
* To see an example of creating Cloud Servers and a Load Balancer at the same time see
* CreateLoadBalancerWithNewServers.
*/
private void addNodesToLoadBalancer(Set<AddNode> addNodes, LoadBalancer loadBalancer) throws TimeoutException {
System.out.println("Add Nodes");
NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
Set<Node> nodes = nodeApi.add(addNodes);
// /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);
}
for (Node node : nodes) {
System.out.println(" " + node);
}
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class DeleteLoadBalancers method deleteLoadBalancers.
/**
* This method will delete all Load Balancers starting with Constants.NAME.
*/
private void deleteLoadBalancers() throws TimeoutException {
System.out.println("Delete Load Balancers");
for (LoadBalancer loadBalancer : lbApi.list().concat()) {
if (loadBalancer.getName().startsWith(Constants.NAME)) {
lbApi.delete(loadBalancer.getId());
// /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
if (!LoadBalancerPredicates.awaitDeleted(lbApi).apply(loadBalancer)) {
throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer);
}
System.out.println(" " + loadBalancer);
}
}
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class ListLoadBalancers method listLoadBalancers.
private void listLoadBalancers() {
System.out.println("List Load Balancers");
for (String zone : clb.getConfiguredZones()) {
System.out.println(" " + zone);
LoadBalancerApi lbApi = clb.getLoadBalancerApiForZone(zone);
for (LoadBalancer loadBalancer : lbApi.list().concat()) {
System.out.println(" " + loadBalancer);
}
}
}
use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer in project legacy-jclouds-examples by jclouds.
the class RemoveNodes 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) {
RemoveNodes removeNodes = new RemoveNodes();
try {
removeNodes.init(args);
LoadBalancer loadBalancer = removeNodes.getLoadBalancer();
Set<Node> nodes = removeNodes.getNodes(loadBalancer);
removeNodes.removeNodesFromLoadBalancer(nodes, loadBalancer);
} catch (Exception e) {
e.printStackTrace();
} finally {
removeNodes.close();
}
}
Aggregations