diff --git a/hooks/charmhelpers/contrib/hahelpers/cluster.py b/hooks/charmhelpers/contrib/hahelpers/cluster.py index 074855f4..f6e741d3 100644 --- a/hooks/charmhelpers/contrib/hahelpers/cluster.py +++ b/hooks/charmhelpers/contrib/hahelpers/cluster.py @@ -126,6 +126,13 @@ def determine_api_port(public_port): return public_port - (i * 10) +def determine_apache_port(public_port): + i = 0 + if len(peer_units()) > 0 or is_clustered(): + i += 1 + return public_port - (i * 10) + + def determine_haproxy_port(public_port): ''' Description: Determine correct proxy listening port based on public IP + @@ -136,8 +143,6 @@ def determine_haproxy_port(public_port): returns: int: the correct listening port for the HAProxy service ''' i = 0 - if https(): - i += 1 return public_port - (i * 10) diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index 1a08c916..60a47229 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -27,6 +27,7 @@ from charmhelpers.core.hookenv import ( ) from charmhelpers.contrib.hahelpers.cluster import ( + determine_apache_port, determine_api_port, determine_haproxy_port, https, @@ -341,11 +342,9 @@ class ApacheSSLContext(OSContextGenerator): 'private_address': unit_get('private-address'), 'endpoints': [] } - for ext_port in self.external_ports: - if peer_units() or is_clustered(): - int_port = determine_haproxy_port(ext_port) - else: - int_port = determine_api_port(ext_port) + for api_port in self.external_ports: + ext_port = determine_apache_port(api_port) + int_port = determine_api_port(api_port) portmap = (int(ext_port), int(int_port)) ctxt['endpoints'].append(portmap) return ctxt diff --git a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg index a1694e44..56ed913e 100644 --- a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg +++ b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg @@ -8,8 +8,8 @@ global defaults log global - mode http - option httplog + mode tcp + option tcplog option dontlognull retries 3 timeout queue 1000 @@ -29,7 +29,6 @@ listen stats :8888 {% for service, ports in service_ports.iteritems() -%} listen {{ service }} 0.0.0.0:{{ ports[0] }} balance roundrobin - option tcplog {% for unit, address in units.iteritems() -%} server {{ unit }} {{ address }}:{{ ports[1] }} check {% endfor %} diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index 72d0d145..55a4ea93 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -6,7 +6,7 @@ from charmhelpers.fetch import apt_install, filter_installed_packages from charmhelpers.contrib.openstack import context, neutron, utils from charmhelpers.contrib.hahelpers.cluster import ( - determine_api_port, determine_haproxy_port) + determine_apache_port, determine_api_port, determine_haproxy_port) class ApacheSSLContext(context.ApacheSSLContext): @@ -67,6 +67,13 @@ class HAProxyContext(context.HAProxyContext): nvol_api = determine_api_port(api_port('nova-api-os-volume')) neutron_api = determine_api_port(api_port('neutron-server')) + # Apache ports + a_compute_api = determine_apache_port(api_port('nova-api-os-compute')) + a_ec2_api = determine_apache_port(api_port('nova-api-ec2')) + a_s3_api = determine_apache_port(api_port('nova-objectstore')) + a_nvol_api = determine_apache_port(api_port('nova-api-os-volume')) + a_neutron_api = determine_apache_port(api_port('neutron-server')) + # to be set in nova.conf accordingly. listen_ports = { 'osapi_compute_listen_port': compute_api, @@ -77,15 +84,15 @@ class HAProxyContext(context.HAProxyContext): port_mapping = { 'nova-api-os-compute': [ determine_haproxy_port(api_port('nova-api-os-compute')), - compute_api, + a_compute_api, ], 'nova-api-ec2': [ determine_haproxy_port(api_port('nova-api-ec2')), - ec2_api, + a_ec2_api, ], 'nova-objectstore': [ determine_haproxy_port(api_port('nova-objectstore')), - s3_api, + a_s3_api, ], } @@ -93,7 +100,7 @@ class HAProxyContext(context.HAProxyContext): port_mapping.update({ 'nova-api-ec2': [ determine_haproxy_port(api_port('nova-api-ec2')), - nvol_api], + a_nvol_api], }) listen_ports['osapi_volume_listen_port'] = nvol_api @@ -101,7 +108,7 @@ class HAProxyContext(context.HAProxyContext): port_mapping.update({ 'neutron-server': [ determine_haproxy_port(api_port('neutron-server')), - neutron_api] + a_neutron_api] }) # quantum/neutron.conf listening port, set separte from nova's. ctxt['neutron_bind_port'] = neutron_api diff --git a/revision b/revision index a1e0432c..5478c714 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -312 +313