added haproxy support like other charms

This commit is contained in:
Edward Hope-Morley 2015-04-02 12:52:13 +01:00
parent 53ee4bc20b
commit 633896c4d2
4 changed files with 47 additions and 2 deletions

View File

@ -3,7 +3,10 @@ import os
from charmhelpers.contrib.openstack import context
from charmhelpers.core.hookenv import config
from charmhelpers.core.host import pwgen
from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
determine_api_port,
)
HEAT_PATH = '/var/lib/heat/'
API_PORTS = {
@ -61,6 +64,30 @@ class EncryptionContext(context.OSContextGenerator):
return ctxt
class HeatHAProxyContext(context.OSContextGenerator):
interfaces = ['heat-haproxy']
def __call__(self):
"""Extends the main charmhelpers HAProxyContext with a port mapping
specific to this charm.
Also used to extend cinder.conf context with correct api_listening_port
"""
haproxy_port = API_PORTS['heat-api']
api_port = determine_api_port(API_PORTS['heat-api'],
singlenode_mode=True)
api_cfn_port = determine_api_port(API_PORTS['heat-api-cfn'],
singlenode_mode=True)
apache_port = determine_apache_port(API_PORTS['heat-api'],
singlenode_mode=True)
ctxt = {
'service_ports': {'heat_api': [haproxy_port, apache_port]},
'api_listen_port': api_port,
'api_cfn_listen_port': api_cfn_port,
}
return ctxt
class HeatApacheSSLContext(context.ApacheSSLContext):
external_ports = [API_PORTS['heat-api']]

View File

@ -30,6 +30,7 @@ from heat_context import (
HeatIdentityServiceContext,
EncryptionContext,
HeatApacheSSLContext,
HeatHAProxyContext,
)
TEMPLATES = 'templates/'
@ -38,7 +39,8 @@ BASE_PACKAGES = [
'python-keystoneclient',
'python-six',
'uuid',
'apache2'
'apache2',
'haproxy',
]
BASE_SERVICES = [
@ -51,6 +53,7 @@ SVC = 'heat'
HEAT_DIR = '/etc/heat'
HEAT_CONF = '/etc/heat/heat.conf'
HEAT_API_PASTE = '/etc/heat/api-paste.ini'
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
HTTPS_APACHE_CONF = '/etc/apache2/sites-available/openstack_https_frontend'
HTTPS_APACHE_24_CONF = os.path.join('/etc/apache2/sites-available',
'openstack_https_frontend.conf')
@ -63,6 +66,7 @@ CONFIG_FILES = OrderedDict([
ssl_dir=HEAT_DIR),
context.OSConfigFlagContext(),
HeatIdentityServiceContext(service=SVC, service_user=SVC),
HeatHAProxyContext(),
EncryptionContext(),
context.SyslogContext()]
}),
@ -70,6 +74,11 @@ CONFIG_FILES = OrderedDict([
'services': [s for s in BASE_SERVICES if 'api' in s],
'contexts': [HeatIdentityServiceContext()],
}),
(HAPROXY_CONF, {
'hook_contexts': [context.HAProxyContext(singlenode_mode=True),
HeatHAProxyContext()],
'services': ['haproxy'],
}),
(HTTPS_APACHE_CONF, {
'contexts': [HeatApacheSSLContext()],
'services': ['apache2'],

View File

@ -63,7 +63,15 @@ connection = {{ database_type }}://{{ database_user }}:{{ database_password }}@{
api_paste_config=/etc/heat/api-paste.ini
[heat_api]
{% if api_listen_port -%}
bind_port={{ api_listen_port }}
{% else -%}
bind_port=8004
{% endif %}
[heat_api_cfn]
{% if api_cfn_listen_port -%}
bind_port={{ api_cfn_listen_port }}
{% else -%}
bind_port=8000
{% endif %}

View File

@ -27,6 +27,7 @@ TO_PATCH = [
RESTART_MAP = OrderedDict([
('/etc/heat/heat.conf', ['heat-api', 'heat-api-cfn', 'heat-engine']),
('/etc/heat/api-paste.ini', ['heat-api', 'heat-api-cfn']),
('/etc/haproxy/haproxy.cfg', ['haproxy']),
('/etc/apache2/sites-available/openstack_https_frontend', ['apache2']),
('/etc/apache2/sites-available/openstack_https_frontend.conf',
['apache2']),