Merge charm-helpers from lp:~ivoks/charm-helpers/new-ssl
This commit is contained in:
parent
e765eaf600
commit
ce86120823
@ -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 +
|
||||||
|
@ -27,8 +27,8 @@ 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,
|
|
||||||
https,
|
https,
|
||||||
is_clustered,
|
is_clustered,
|
||||||
peer_units,
|
peer_units,
|
||||||
@ -341,11 +341,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
|
||||||
|
@ -194,7 +194,7 @@ def file_hash(path):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def restart_on_change(restart_map):
|
def restart_on_change(restart_map, stopstart=False):
|
||||||
"""Restart services based on configuration files changing
|
"""Restart services based on configuration files changing
|
||||||
|
|
||||||
This function is used a decorator, for example
|
This function is used a decorator, for example
|
||||||
@ -219,8 +219,14 @@ def restart_on_change(restart_map):
|
|||||||
for path in restart_map:
|
for path in restart_map:
|
||||||
if checksums[path] != file_hash(path):
|
if checksums[path] != file_hash(path):
|
||||||
restarts += restart_map[path]
|
restarts += restart_map[path]
|
||||||
for service_name in list(OrderedDict.fromkeys(restarts)):
|
services_list = list(OrderedDict.fromkeys(restarts))
|
||||||
service('restart', service_name)
|
if not stopstart:
|
||||||
|
for service_name in services_list:
|
||||||
|
service('restart', service_name)
|
||||||
|
else:
|
||||||
|
for action in ['stop', 'start']:
|
||||||
|
for service_name in services_list:
|
||||||
|
service(action, service_name)
|
||||||
return wrapped_f
|
return wrapped_f
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
@ -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 %}
|
||||||
|
Loading…
Reference in New Issue
Block a user