Search in sources :

Example 6 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node 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();
    }
}
Also used : Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) LoadBalancer(org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class UpdateNodes 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) {
    UpdateNodes updateNodes = new UpdateNodes();
    try {
        updateNodes.init(args);
        LoadBalancer loadBalancer = updateNodes.getLoadBalancer();
        Set<Node> nodes = updateNodes.getNodes(loadBalancer);
        updateNodes.updateNodesInLoadBalancer(nodes, loadBalancer);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        updateNodes.close();
    }
}
Also used : Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) UpdateNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode) LoadBalancer(org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer) TimeoutException(java.util.concurrent.TimeoutException)

Example 8 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class CreateLoadBalancerWithNewServers method createNodeRequests.

/**
    * AddNodes specify the nodes (Cloud Servers) that requests will be sent to by the Load Balancer.
    */
private Set<AddNode> createNodeRequests(Set<? extends NodeMetadata> nodes) {
    Set<AddNode> addNodes = Sets.newHashSet();
    for (NodeMetadata node : nodes) {
        String privateAddress = node.getPrivateAddresses().iterator().next();
        AddNode addNode = AddNode.builder().address(privateAddress).condition(Node.Condition.ENABLED).port(80).weight(20).build();
        addNodes.add(addNode);
    }
    return addNodes;
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) AddNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode)

Aggregations

Node (org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node)6 TimeoutException (java.util.concurrent.TimeoutException)5 NodeApi (org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi)5 UpdateNode (org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode)3 AddNode (org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode)2 LoadBalancer (org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1