public static Hosts rndHosts(int max) { int nhosts = rndInt(0, max); Hosts hosts = new Hosts(); hosts.setSticky((Boolean) StubFactory.rndChoice((new Boolean[] {true, false}))); for (int i = nhosts; i <= StubFactory.rndInt(1, 5); i++) { Host h = StubFactory.rndHostPost(); h.setId(rndInt(0, 10000)); hosts.getHosts().add(h); } return hosts; }
public static LoadBalancer rndLoadBalancer() { int ri = rndInt(0, 10000); LoadBalancer l = new LoadBalancer(); l.setAlgorithm((String) rndChoice(AlgorithmType.values())); org.openstack.atlas.docs.loadbalancers.api.v1.Cluster c; c = new org.openstack.atlas.docs.loadbalancers.api.v1.Cluster(); c.setName(String.format("Cluster for LB.%d", ri)); l.setCluster(c); ConnectionThrottle cl = rndConnectionThrottle(); l.setConnectionThrottle(cl); ConnectionLogging conLog = new ConnectionLogging(); conLog.setEnabled(true); l.setConnectionLogging(conLog); Created created = new Created(); created.setTime(Calendar.getInstance()); l.setCreated(created); // l.getCurrentUsage().add(rndCurrentUsage()); // l.setHosts(rndHosts(3)); l.setId(rndInt(0, 10000)); l.setName(String.format("LB.%d", l.getId())); l.getNodes().addAll(StubFactory.rndNodes(10).getNodes()); l.setPort(rndInt(0, 32000)); List<String> protocolNames = ProtocolPortBindings.getKeys(); l.setProtocol((String) rndChoice(protocolNames)); l.setRateLimit(rndRateLimit()); l.setSessionPersistence(rndSessionPersistance()); l.setStatus((String) rndChoice(LoadBalancerStatus.values())); l.setTotalActiveConnections(rndInt(0, 10000)); return l; }