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
hooks
charmhelpers/contrib
hahelpers
openstack
nova_cc_context.py
revision

@ -126,6 +126,13 @@ def determine_api_port(public_port):
return public_port - (i * 10) 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): def determine_haproxy_port(public_port):
''' '''
Description: Determine correct proxy listening port based on public IP + 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 returns: int: the correct listening port for the HAProxy service
''' '''
i = 0 i = 0
if https():
i += 1
return public_port - (i * 10) return public_port - (i * 10)

@ -27,6 +27,7 @@ from charmhelpers.core.hookenv import (
) )
from charmhelpers.contrib.hahelpers.cluster import ( from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
determine_api_port, determine_api_port,
determine_haproxy_port, determine_haproxy_port,
https, https,
@ -341,11 +342,9 @@ class ApacheSSLContext(OSContextGenerator):
'private_address': unit_get('private-address'), 'private_address': unit_get('private-address'),
'endpoints': [] 'endpoints': []
} }
for ext_port in self.external_ports: for api_port in self.external_ports:
if peer_units() or is_clustered(): ext_port = determine_apache_port(api_port)
int_port = determine_haproxy_port(ext_port) int_port = determine_api_port(api_port)
else:
int_port = determine_api_port(ext_port)
portmap = (int(ext_port), int(int_port)) portmap = (int(ext_port), int(int_port))
ctxt['endpoints'].append(portmap) ctxt['endpoints'].append(portmap)
return ctxt return ctxt

@ -8,8 +8,8 @@ global
defaults defaults
log global log global
mode http mode tcp
option httplog option tcplog
option dontlognull option dontlognull
retries 3 retries 3
timeout queue 1000 timeout queue 1000
@ -29,7 +29,6 @@ listen stats :8888
{% for service, ports in service_ports.iteritems() -%} {% for service, ports in service_ports.iteritems() -%}
listen {{ service }} 0.0.0.0:{{ ports[0] }} listen {{ service }} 0.0.0.0:{{ ports[0] }}
balance roundrobin balance roundrobin
option tcplog
{% for unit, address in units.iteritems() -%} {% for unit, address in units.iteritems() -%}
server {{ unit }} {{ address }}:{{ ports[1] }} check server {{ unit }} {{ address }}:{{ ports[1] }} check
{% endfor %} {% endfor %}

@ -6,7 +6,7 @@ from charmhelpers.fetch import apt_install, filter_installed_packages
from charmhelpers.contrib.openstack import context, neutron, utils from charmhelpers.contrib.openstack import context, neutron, utils
from charmhelpers.contrib.hahelpers.cluster import ( 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): class ApacheSSLContext(context.ApacheSSLContext):
@ -67,6 +67,13 @@ class HAProxyContext(context.HAProxyContext):
nvol_api = determine_api_port(api_port('nova-api-os-volume')) nvol_api = determine_api_port(api_port('nova-api-os-volume'))
neutron_api = determine_api_port(api_port('neutron-server')) 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. # to be set in nova.conf accordingly.
listen_ports = { listen_ports = {
'osapi_compute_listen_port': compute_api, 'osapi_compute_listen_port': compute_api,
@ -77,15 +84,15 @@ class HAProxyContext(context.HAProxyContext):
port_mapping = { port_mapping = {
'nova-api-os-compute': [ 'nova-api-os-compute': [
determine_haproxy_port(api_port('nova-api-os-compute')), determine_haproxy_port(api_port('nova-api-os-compute')),
compute_api, a_compute_api,
], ],
'nova-api-ec2': [ 'nova-api-ec2': [
determine_haproxy_port(api_port('nova-api-ec2')), determine_haproxy_port(api_port('nova-api-ec2')),
ec2_api, a_ec2_api,
], ],
'nova-objectstore': [ 'nova-objectstore': [
determine_haproxy_port(api_port('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({ port_mapping.update({
'nova-api-ec2': [ 'nova-api-ec2': [
determine_haproxy_port(api_port('nova-api-ec2')), determine_haproxy_port(api_port('nova-api-ec2')),
nvol_api], a_nvol_api],
}) })
listen_ports['osapi_volume_listen_port'] = nvol_api listen_ports['osapi_volume_listen_port'] = nvol_api
@ -101,7 +108,7 @@ class HAProxyContext(context.HAProxyContext):
port_mapping.update({ port_mapping.update({
'neutron-server': [ 'neutron-server': [
determine_haproxy_port(api_port('neutron-server')), determine_haproxy_port(api_port('neutron-server')),
neutron_api] a_neutron_api]
}) })
# quantum/neutron.conf listening port, set separte from nova's. # quantum/neutron.conf listening port, set separte from nova's.
ctxt['neutron_bind_port'] = neutron_api ctxt['neutron_bind_port'] = neutron_api

@ -1 +1 @@
312 313