mirror of https://github.com/apache/cloudstack.git
bug 11372:
Added two New values "all" and "default" to global config "network.loadbalancer.haproxy.stats.visibility" . With this change, it can take six possible value:
global - stats visible from public network.
guest-network - stats visible only to guestnetwork.
link-local - stats visible only to link local network(for xen and kvm).
disabled - stats disabled.
all - stats available on public,guest and link-local. (Newly added)
default - stats availble on the serving http port, this does need any specific http port.(Newly added)
Except default and disabled, all the rest of 4 need to configure the stats port.
This commit is contained in:
parent
17caf6ea25
commit
01ac82d9d6
|
|
@ -26,18 +26,22 @@ import com.cloud.agent.api.to.LoadBalancerTO;
|
|||
public class LoadBalancerConfigCommand extends NetworkElementCommand {
|
||||
LoadBalancerTO[] loadBalancers;
|
||||
public String lbStatsVisibility = "guest-network";
|
||||
public String lbStatsIp; /* load balancer listen on this ip for stats */
|
||||
public String lbStatsPublicIP; /* load balancer listen on this ips for stats */
|
||||
public String lbStatsPrivateIP; /* load balancer listen on this ips for stats */
|
||||
public String lbStatsGuestIP; /* load balancer listen on this ips for stats */
|
||||
public String lbStatsPort = "8081"; /*load balancer listen on this port for stats */
|
||||
public String lbStatsSrcCidrs = "0/0" ; /* TODO : currently there is no filtering based on the source ip */
|
||||
public String lbStatsAuth = "admin1:AdMiN123";
|
||||
public String lbStatsUri = "/admin?stats";
|
||||
|
||||
protected LoadBalancerConfigCommand() {
|
||||
|
||||
}
|
||||
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers) {
|
||||
public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp) {
|
||||
this.loadBalancers = loadBalancers;
|
||||
this.lbStatsPublicIP = PublicIp;
|
||||
this.lbStatsPrivateIP = PrivateIp;
|
||||
this.lbStatsGuestIP = GuestIp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,13 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
private String getBlankLine() {
|
||||
return new String("\t ");
|
||||
}
|
||||
|
||||
private String generateStatsRule(LoadBalancerConfigCommand lbCmd,String ruleName,String statsIp)
|
||||
{
|
||||
StringBuilder rule = new StringBuilder("\nlisten ").append(ruleName).append(" ").append(statsIp).append(":").append(lbCmd.lbStatsPort);
|
||||
rule.append("\n\tmode http\n\toption httpclose\n\tstats enable\n\tstats uri ").append(lbCmd.lbStatsUri).append("\n\tstats realm Haproxy\\ Statistics\n\tstats auth ").append(lbCmd.lbStatsAuth);
|
||||
rule.append("\n");
|
||||
return rule.toString();
|
||||
}
|
||||
@Override
|
||||
public String[] generateConfiguration(LoadBalancerConfigCommand lbCmd) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
|
|
@ -206,24 +212,29 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
result.addAll(Arrays.asList(defaultsSection));
|
||||
if (!lbCmd.lbStatsVisibility.equals("disabled"))
|
||||
{
|
||||
if (lbCmd.lbStatsVisibility.equals("guest-network") || lbCmd.lbStatsVisibility.equals("link-local"))
|
||||
/*new rule : listen admin_page guestip/link-local:8081 */
|
||||
if (lbCmd.lbStatsVisibility.equals("global"))
|
||||
{
|
||||
result.add(generateStatsRule(lbCmd,"stats_on_public",lbCmd.lbStatsPublicIP));
|
||||
}else if (lbCmd.lbStatsVisibility.equals("guest-network"))
|
||||
{
|
||||
result.add(getBlankLine());
|
||||
|
||||
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(generateStatsRule(lbCmd,"stats_on_guest",lbCmd.lbStatsGuestIP));
|
||||
}else if (lbCmd.lbStatsVisibility.equals("link-local"))
|
||||
{
|
||||
result.add(generateStatsRule(lbCmd,"stats_on_private",lbCmd.lbStatsPrivateIP));
|
||||
}else if (lbCmd.lbStatsVisibility.equals("all"))
|
||||
{
|
||||
result.add(generateStatsRule(lbCmd,"stats_on_public",lbCmd.lbStatsPublicIP));
|
||||
result.add(generateStatsRule(lbCmd,"stats_on_guest",lbCmd.lbStatsGuestIP));
|
||||
result.add(generateStatsRule(lbCmd,"stats_on_private",lbCmd.lbStatsPrivateIP));
|
||||
}else
|
||||
{
|
||||
/* stats will be available on the default http serving port, no special stats port */
|
||||
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());
|
||||
}
|
||||
/* 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());
|
||||
|
||||
|
|
@ -261,8 +272,22 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
|||
toRemove.add(lbRuleEntry);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(lbCmd.lbStatsIp).append(":").append(lbCmd.lbStatsPort).append(":").append(lbCmd.lbStatsSrcCidrs).append(":,");
|
||||
StringBuilder sb= new StringBuilder("");
|
||||
if (lbCmd.lbStatsVisibility.equals("guest-network"))
|
||||
{
|
||||
sb = new StringBuilder(lbCmd.lbStatsGuestIP).append(":").append(lbCmd.lbStatsPort).append(":").append(lbCmd.lbStatsSrcCidrs).append(":,");
|
||||
} else if (lbCmd.lbStatsVisibility.equals("link-local"))
|
||||
{
|
||||
sb = new StringBuilder(lbCmd.lbStatsPrivateIP).append(":").append(lbCmd.lbStatsPort).append(":").append(lbCmd.lbStatsSrcCidrs).append(":,");
|
||||
}else if (lbCmd.lbStatsVisibility.equals("global"))
|
||||
{
|
||||
sb = new StringBuilder(lbCmd.lbStatsPublicIP).append(":").append(lbCmd.lbStatsPort).append(":").append(lbCmd.lbStatsSrcCidrs).append(":,");
|
||||
}else if (lbCmd.lbStatsVisibility.equals("all"))
|
||||
{
|
||||
sb = new StringBuilder("0.0.0.0/0").append(":").append(lbCmd.lbStatsPort).append(":").append(lbCmd.lbStatsSrcCidrs).append(":,");
|
||||
}
|
||||
toStats.add(sb.toString());
|
||||
|
||||
toRemove.removeAll(toAdd);
|
||||
result[ADD] = toAdd.toArray(new String[toAdd.size()]);
|
||||
result[REMOVE] = toRemove.toArray(new String[toRemove.size()]);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public enum Config {
|
|||
BackupSnapshotWait("Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "10800", "In second, timeout for BackupSnapshotCommand", null),
|
||||
|
||||
// Network
|
||||
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, it can take the following four parameters : global,guest-network,link-local,disabled", null),
|
||||
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", 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),
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ public class F5BigIpManagerImpl extends ExternalNetworkManagerImpl implements Ex
|
|||
if (loadBalancersToApply.size() > 0) {
|
||||
int numLoadBalancersForCommand = loadBalancersToApply.size();
|
||||
LoadBalancerTO[] loadBalancersForCommand = loadBalancersToApply.toArray(new LoadBalancerTO[numLoadBalancersForCommand]);
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand);
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(loadBalancersForCommand,null,null,null);
|
||||
long guestVlanTag = Integer.parseInt(network.getBroadcastUri().getHost());
|
||||
cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag));
|
||||
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ public class ElasticLoadBalancerManagerImpl implements
|
|||
lbs[i++] = lb;
|
||||
}
|
||||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs);
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,elbVm.getPublicIpAddress(),elbVm.getGuestIpAddress(),elbVm.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,
|
||||
elbVm.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,
|
||||
|
|
@ -299,13 +299,7 @@ public class ElasticLoadBalancerManagerImpl implements
|
|||
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
|
||||
cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key());
|
||||
cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key());
|
||||
if (cmd.lbStatsVisibility.equals("guest-network"))
|
||||
{
|
||||
cmd.lbStatsIp = elbVm.getGuestIpAddress();;
|
||||
}else
|
||||
{
|
||||
cmd.lbStatsIp = elbVm.getPrivateIpAddress();
|
||||
}
|
||||
|
||||
cmds.addCommand(cmd);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2193,21 +2193,20 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
LoadBalancerTO lb = new LoadBalancerTO(srcIp, srcPort, protocol, algorithm, revoked, false, destinations);
|
||||
lbs[i++] = lb;
|
||||
}
|
||||
String RouterPublicIp = null;
|
||||
|
||||
if (router instanceof DomainRouterVO) {
|
||||
DomainRouterVO domr = (DomainRouterVO)router;
|
||||
RouterPublicIp = domr.getPublicIpAddress();
|
||||
}
|
||||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs);
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,RouterPublicIp, router.getGuestIpAddress(),router.getPrivateIpAddress());
|
||||
|
||||
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());
|
||||
if (cmd.lbStatsVisibility.equals("guest-network"))
|
||||
{
|
||||
cmd.lbStatsIp = router.getGuestIpAddress();
|
||||
}else
|
||||
{
|
||||
cmd.lbStatsIp = router.getPrivateIpAddress();
|
||||
}
|
||||
|
||||
|
||||
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress());
|
||||
|
|
|
|||
|
|
@ -27,3 +27,4 @@ ALTER TABLE `cloud`.`host` MODIFY COLUMN `storage_ip_address` char(40);
|
|||
ALTER TABLE `cloud`.`resource_count` ADD UNIQUE `i_resource_count__type_accountId`(`type`, `account_id`);
|
||||
ALTER TABLE `cloud`.`resource_count` ADD UNIQUE `i_resource_count__type_domaintId`(`type`, `domain_id`);
|
||||
|
||||
UPDATE configuration set description='Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default' WHERE name='network.loadbalancer.haproxy.stats.visibility' ;
|
||||
|
|
|
|||
Loading…
Reference in New Issue