bug 10557: made more feature enhancement instead of bug- added more stats parametes as global config

This commit is contained in:
Naredula Janardhana Reddy 2011-07-27 13:42:14 +05:30
parent 93680fdc9e
commit 3c66075b8b
4 changed files with 33 additions and 44 deletions

View File

@ -25,9 +25,11 @@ import com.cloud.agent.api.to.LoadBalancerTO;
*/
public class LoadBalancerConfigCommand extends NetworkElementCommand {
LoadBalancerTO[] loadBalancers;
public String lbStatsAccessbility;
public String lbStatsVisibility;
public String lbStatsIp; /* load balancer listen on this ip for stats */
public String lbStatsPort="8080"; /* load balancer listen on this ip for stats */
public String lbStatsPort = "8081"; /*TODO: need to open the firewall port, load balancer listen on this port for stats */
public String lbStatsAuth = "admin1:AdMiN123";
public String lbStatsUri = "/admin?stats";
protected LoadBalancerConfigCommand() {

View File

@ -50,11 +50,7 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
private static String [] statsSubrule = {
"\tmode http",
"\toption httpclose",
"\tstats enable",
"\tstats uri /admin?stats",
"\tstats realm Haproxy\\ Statistics",
"\tstats auth admin1:AdMiN123"
"\toption httpclose"
};
@ -65,28 +61,12 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
"\tretries 3",
"\toption redispatch",
"\toption forwardfor",
"\tstats enable",
"\tstats uri /admin?stats",
"\tstats realm Haproxy\\ Statistics",
"\tstats auth admin1:AdMiN123",
"\toption forceclose",
"\ttimeout connect 5000",
"\ttimeout client 50000",
"\ttimeout server 50000"
};
private static String [] defaultsSectionWithoutStats = {"defaults",
"\tlog global",
"\tmode tcp",
"\toption dontlognull",
"\tretries 3",
"\toption redispatch",
"\toption forwardfor",
"\toption forceclose",
"\ttimeout connect 5000",
"\ttimeout client 50000",
"\ttimeout server 50000"
};
private static String [] defaultListen = {"listen vmops 0.0.0.0:9",
"\toption transparent"
@ -223,29 +203,29 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
result.addAll(Arrays.asList(globalSection));
result.add(getBlankLine());
if (lbCmd.lbStatsAccessbility.equals("accessible"))
{
result.addAll(Arrays.asList(defaultsSection));
result.add(getBlankLine());
}
else
{
result.addAll(Arrays.asList(defaultsSectionWithoutStats));
result.add(getBlankLine());
if (lbCmd.lbStatsAccessbility.equals("only-to-guest"))
result.addAll(Arrays.asList(defaultsSection));
if (!lbCmd.lbStatsVisibility.equals("disabled"))
{
if (lbCmd.lbStatsVisibility.equals("guest-network"))
{
String rule="listen admin_page ";
rule=rule.concat(lbCmd.lbStatsIp);
rule=rule.concat(":");
rule=rule.concat(lbCmd.lbStatsPort);
result.add(getBlankLine());
/*listen admin_page guestip:8081 */
result.add(rule);
StringBuilder rule = new StringBuilder("listen admin_page ").append(lbCmd.lbStatsIp).append(":").append(lbCmd.lbStatsPort);
/*new rule : listen admin_page guestip:8081 */
result.add(rule.toString());
result.addAll(Arrays.asList(statsSubrule));
result.add(getBlankLine());
}
/* stats sub rule for both guest-network and global */
/* "\tstats enable",
"\tstats uri /admin?stats",
"\tstats realm Haproxy\\ Statistics",
"\tstats auth admin1:AdMiN123",
*/
StringBuilder subRule = new StringBuilder("\tstats enable\n\tstats uri ").append(lbCmd.lbStatsUri).append("\n\tstats realm Haproxy\\ Statistics\n\tstats auth ").append(lbCmd.lbStatsAuth);
result.add(subRule.toString());
}
result.add(getBlankLine());
if (lbCmd.getLoadBalancers().length == 0){
//haproxy cannot handle empty listen / frontend or backend, so add a dummy listener

View File

@ -56,7 +56,10 @@ public enum Config {
TotalRetries("Storage", AgentManager.class, Integer.class, "total.retries", "4", "The number of times each command sent to a host should be retried in case of failure.", null),
// Network
LoadBalancerStats("Network", ManagementServer.class, String.class, "loadbalancer.stats", "accessible", "lb stats accessibility, it can accessible,unaccessible or only-to-guest", null),
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, it can be global,guest-network,disabled", null),
NetworkLBHaproxyStatsUri("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.uri","/admin?stats","Load Balancer(haproxy) uri.",null),
NetworkLBHaproxyStatsAuth("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.auth","admin1:AdMiN123","Load Balancer(haproxy) authetication string in the format username:password",null),
NetworkLBHaproxyStatsPort("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.port","8081","Load Balancer(haproxy) stats port number.",null),
GuestVlanBits("Network", ManagementServer.class, Integer.class, "guest.vlan.bits", "12", "The number of bits to reserve for the VLAN identifier in the guest subnet.", null),
//MulticastThrottlingRate("Network", ManagementServer.class, Integer.class, "multicast.throttling.rate", "10", "Default multicast rate in megabits per second allowed.", null),
NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in network.", null),

View File

@ -1707,8 +1707,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs);
cmd.lbStatsAccessbility = _configDao.getValue(Config.LoadBalancerStats.key());
cmd.lbStatsIp = router.getGuestIpAddress();
cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key());
cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());