Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 private LoadBalancer newLoadBalancer(Integer id, String name) {
   List<Node> nodes = new ArrayList<Node>();
   List<VirtualIp> vips = new ArrayList<VirtualIp>();
   List<NetworkItem> accessList = new ArrayList<NetworkItem>();
   LoadBalancer lb = new LoadBalancer();
   Created created = new Created();
   Updated updated = new Updated();
   created.setTime(Calendar.getInstance());
   updated.setTime(Calendar.getInstance());
   ConnectionThrottle ct = new ConnectionThrottle();
   Cluster cl = new Cluster();
   ConnectionLogging cnl = new ConnectionLogging();
   cnl.setEnabled(Boolean.TRUE);
   ct.setMaxConnectionRate(100);
   ct.setMaxConnections(200);
   ct.setMinConnections(300);
   ct.setRateInterval(60);
   cl.setName("TestCluster");
   lb.setName(name);
   lb.setAlgorithm("RANDOM");
   lb.setCluster(cl);
   lb.setConnectionLogging(cnl);
   lb.setConnectionThrottle(ct);
   lb.setPort(80);
   lb.setProtocol("HTTP");
   lb.setStatus("BUILD");
   lb.setCreated(created);
   lb.setUpdated(updated);
   nodes.add(newNode(1, 80, "127.0.0.10"));
   nodes.add(newNode(1, 443, "127.0.0.20"));
   vips.add(newVip(1, "127.0.0.1"));
   vips.add(newVip(2, "127.0.0.2"));
   lb.setVirtualIps(vips);
   lb.setNodes(nodes);
   SessionPersistence sp = new SessionPersistence();
   sp.setPersistenceType(PersistenceType.HTTP_COOKIE);
   lb.setSessionPersistence(sp);
   accessList.add(newNetworkItem(1, "10.0.0.0/8"));
   accessList.add(newNetworkItem(2, "192.168.0.0/24"));
   lb.setAccessList(accessList);
   LoadBalancerUsage lu = new LoadBalancerUsage();
   lu.setLoadBalancerId(id);
   lu.setLoadBalancerName(name);
   lu.getLoadBalancerUsageRecords().add(newLoadBalancerUsageRecord(1));
   lu.getLoadBalancerUsageRecords().add(newLoadBalancerUsageRecord(2));
   lb.setLoadBalancerUsage(lu);
   return lb;
 }