[Hui Xiang] support ipv6 for rabbitmq-server

This commit is contained in:
Hui Xiang 2014-07-01 18:27:53 +08:00
parent 71c7aa8104
commit f38c781e8e
3 changed files with 26 additions and 2 deletions

View File

@ -133,3 +133,7 @@ options:
description: |
Key ID to import to the apt keyring to support use with arbitary source
configuration from outside of Launchpad archives or PPA's.
use-ipv6:
type: boolean
default: False
description: "Enable Ipv6"

View File

@ -28,6 +28,10 @@ from charmhelpers.contrib.peerstorage import (
peer_retrieve
)
from charmhelpers.contrib.hahelpers.cluster import (
get_ipv6_addr
)
PACKAGES = ['rabbitmq-server', 'python-amqplib']
RABBITMQ_CTL = '/usr/sbin/rabbitmqctl'
@ -367,3 +371,11 @@ def get_rabbit_password(username, password=None):
# cluster relation is not yet started, use on-disk
_password = get_rabbit_password_on_disk(username, password)
return _password
def bind_ipv6_interface():
ipv6_addr = get_ipv6_addr()
out = "RABBITMQ_NODE_IP_ADDRESS=%s" % ipv6_addr
with open(ENV_CONF, 'wb') as conf:
conf.write(''.join(out))

View File

@ -13,7 +13,8 @@ from lib.utils import (
)
from charmhelpers.contrib.hahelpers.cluster import (
is_clustered,
eligible_leader
eligible_leader,
get_ipv6_addr
)
import charmhelpers.contrib.storage.linux.ceph as ceph
@ -115,7 +116,11 @@ def amqp_changed(relation_id=None, remote_unit=None):
queues[amqp]['username'],
queues[amqp]['vhost'])
relation_settings['hostname'] = unit_get('private-address')
if config('use-ipv6'):
relation_settings['hostname'] = '[%s]' % get_ipv6_addr()
else:
relation_settings['hostname'] = unit_get('private-address')
configure_client_ssl(relation_settings)
if is_clustered():
@ -528,6 +533,9 @@ def config_changed():
chown(RABBIT_DIR, rabbit.RABBIT_USER, rabbit.RABBIT_USER)
chmod(RABBIT_DIR, 0o775)
if config('use-ipv6'):
rabbit.bind_ipv6_interface()
if config('management_plugin') is True:
rabbit.enable_plugin(MAN_PLUGIN)
open_port(55672)