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; }
@Override public LoadBalancer expected() { Metadata metadata = new Metadata(); metadata.put("color", "red"); metadata.putId("color", 1); metadata.put("label", "web-load-balancer"); metadata.putId("label", 2); return LoadBalancer.builder() .region("DFW") .id(2000) .name("sample-loadbalancer") .protocol("HTTP") .port(80) .algorithm(Algorithm.RANDOM) .status(Status.ACTIVE) .connectionLogging(true) .contentCaching(true) .nodeCount(2) .halfClosed(false) .healthMonitor( HealthMonitor.builder() .type(Type.CONNECT) .delay(10) .timeout(5) .attemptsBeforeDeactivation(2) .build()) .sslTermination( SSLTermination.builder().enabled(true).secureTrafficOnly(false).securePort(443).build()) .sourceAddresses( SourceAddresses.builder() .ipv6Public("2001:4800:7901::5/64") .ipv4Public("174.143.139.137") .ipv4Servicenet("10.183.250.137") .build()) .connectionThrottle( ConnectionThrottle.builder() .maxConnections(100) .minConnections(10) .maxConnectionRate(50) .rateInterval(60) .build()) .accessRules( ImmutableSet.of( new AccessRuleWithId(22215, "1.2.3.4/32", AccessRule.Type.DENY), new AccessRuleWithId(22217, "12.0.0.0/8", AccessRule.Type.ALLOW))) .virtualIPs( ImmutableSet.of( new VirtualIPWithId( VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 1000, "206.10.10.210"), new VirtualIPWithId( VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV6, 1001, "2001:4800:7901:0000:9a32:3c2a:0000:0001"))) .nodes( ImmutableSet.of( Node.builder() .id(1041) .address("10.1.1.1") .port(80) .condition(Node.Condition.ENABLED) .status(Node.Status.ONLINE) .build(), Node.builder() .id(1411) .address("10.1.1.2") .port(80) .condition(Node.Condition.ENABLED) .status(Node.Status.ONLINE) .build())) .sessionPersistenceType(SessionPersistence.HTTP_COOKIE) .clusterName("c1.dfw1") .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")) .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")) .metadata(metadata) .uri( URI.create( "https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000")) .build(); }
@Override public Integer apply(Node node) { return node.getId(); }