Use general BindHostContext().

This commit is contained in:
Hui Xiang 2014-09-25 14:20:53 +08:00
parent 896d6a12bd
commit 2c8bfe7547
5 changed files with 17 additions and 15 deletions

View File

@ -801,3 +801,16 @@ class SyslogContext(OSContextGenerator):
'use_syslog': config('use-syslog')
}
return ctxt
class BindHostContext(OSContextGenerator):
def __call__(self):
if config('prefer-ipv6'):
return {
'bind_host': '::'
}
else:
return {
'bind_host': '0.0.0.0'
}

View File

@ -246,15 +246,3 @@ 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

View File

@ -294,6 +294,7 @@ def ha_relation_joined():
)
vip_group.append(vip_key)
if len(vip_group) >= 1:
relation_set(groups={'grp_swift_vips': ' '.join(vip_group)})
init_services = {

View File

@ -82,7 +82,7 @@ CONFIG_FILES = OrderedDict([
}),
(SWIFT_PROXY_CONF, {
'hook_contexts': [swift_context.SwiftIdentityContext(),
swift_context.SwiftIPv6Context()],
context.BindHostContext()],
'services': ['swift-proxy'],
}),
(HAPROXY_CONF, {

View File

@ -2,7 +2,7 @@
bind_port = {{ bind_port }}
workers = {{ workers }}
user = swift
bind_ip = {{ bind_ip }}
bind_ip = {{ bind_host }}
{% if ssl %}
cert_file = {{ ssl_cert }}
key_file = {{ ssl_key }}