Correct templates to support IPv6.
This commit is contained in:
parent
71ded8fe37
commit
59aaa38404
@ -143,11 +143,14 @@ class SwiftIdentityContext(OSContextGenerator):
|
||||
import multiprocessing
|
||||
workers = multiprocessing.cpu_count()
|
||||
if config('prefer-ipv6'):
|
||||
proxy_ip = '%s' % get_ipv6_addr()
|
||||
proxy_ip = '[%s]' % get_ipv6_addr()
|
||||
memcached_ip = 'ip6-localhost'
|
||||
else:
|
||||
proxy_ip = get_host_ip(unit_get('private-address'))
|
||||
memcached_ip = get_host_ip(unit_get('private-address'))
|
||||
ctxt = {
|
||||
'proxy_ip': proxy_ip,
|
||||
'memcached_ip': memcached_ip,
|
||||
'bind_port': determine_api_port(bind_port),
|
||||
'workers': workers,
|
||||
'operator_roles': config('operator-roles'),
|
||||
@ -211,9 +214,9 @@ class MemcachedContext(OSContextGenerator):
|
||||
ctxt = {}
|
||||
if config('prefer-ipv6'):
|
||||
|
||||
ctxt['proxy_ip'] = get_ipv6_addr()
|
||||
ctxt['memcached_ip'] = 'ip6-localhost'
|
||||
else:
|
||||
ctxt['proxy_ip'] = get_host_ip(unit_get('private-address'))
|
||||
ctxt['memcached_ip'] = get_host_ip(unit_get('private-address'))
|
||||
|
||||
return ctxt
|
||||
|
||||
@ -245,3 +248,14 @@ class SwiftHashContext(OSContextGenerator):
|
||||
'swift_hash': get_swift_hash()
|
||||
}
|
||||
return ctxt
|
||||
|
||||
|
||||
class SwiftIPv6Context(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
if config('prefer-ipv6'):
|
||||
ctxt['bind_ip'] = '::'
|
||||
else:
|
||||
ctxt['bind_ip'] = '0.0.0.0'
|
||||
return ctxt
|
||||
|
@ -40,7 +40,8 @@ from charmhelpers.core.hookenv import (
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
service_restart,
|
||||
restart_on_change
|
||||
restart_on_change,
|
||||
lsb_release,
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
@ -177,7 +178,7 @@ def balance_rings():
|
||||
@restart_on_change(restart_map())
|
||||
def storage_changed():
|
||||
if config('prefer-ipv6'):
|
||||
host_ip = relation_get('private-address')
|
||||
host_ip = '[%s]' % relation_get('private-address')
|
||||
else:
|
||||
host_ip = openstack.get_host_ip(relation_get('private-address'))
|
||||
zone = get_zone(config('zone-assignment'))
|
||||
|
@ -75,7 +75,8 @@ CONFIG_FILES = OrderedDict([
|
||||
'services': ['swift-proxy'],
|
||||
}),
|
||||
(SWIFT_PROXY_CONF, {
|
||||
'hook_contexts': [swift_context.SwiftIdentityContext()],
|
||||
'hook_contexts': [swift_context.SwiftIdentityContext(),
|
||||
swift_context.SwiftIPv6Context()],
|
||||
'services': ['swift-proxy'],
|
||||
}),
|
||||
(HAPROXY_CONF, {
|
||||
|
@ -2,6 +2,7 @@
|
||||
bind_port = {{ bind_port }}
|
||||
workers = {{ workers }}
|
||||
user = swift
|
||||
bind_ip = {{ bind_ip }}
|
||||
{% if ssl %}
|
||||
cert_file = {{ ssl_cert }}
|
||||
key_file = {{ ssl_key }}
|
||||
@ -31,7 +32,7 @@ use = egg:swift#healthcheck
|
||||
|
||||
[filter:cache]
|
||||
use = egg:swift#memcache
|
||||
memcache_servers = {{ proxy_ip }}:11211
|
||||
memcache_servers = {{ memcached_ip }}:11211
|
||||
|
||||
[filter:account-quotas]
|
||||
use = egg:swift#account_quotas
|
||||
|
@ -32,7 +32,7 @@ logfile /var/log/memcached.log
|
||||
# Specify which IP address to listen on. The default is to listen on all IP addresses
|
||||
# This parameter is one of the only security measures that memcached has, so make sure
|
||||
# it's listening on a firewalled interface.
|
||||
-l {{ proxy_ip }}
|
||||
-l {{ memcached_ip }}
|
||||
|
||||
# Limit the number of simultaneous incoming connections. The daemon default is 1024
|
||||
# -c 1024
|
||||
|
Loading…
Reference in New Issue
Block a user