First go on rearranging haproxy and apache. Needs some refactoring.

This commit is contained in:
Ante Karamatic 2014-02-14 21:56:58 +01:00
parent 704b1f8dbe
commit d7afa5ad96
5 changed files with 27 additions and 17 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 %}

View File

@ -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

View File

@ -1 +1 @@
312
313