[hopem,r=gnuoy] fix ipv6 db access

This commit is contained in:
Liam Young 2015-01-27 08:42:02 +00:00
commit abd29e5000
2 changed files with 22 additions and 4 deletions

View File

@ -114,6 +114,18 @@ options:
juju-myservice-0
If you're running multiple environments with the same services in them
this allows you to differentiate between them.
prefer-ipv6:
type: boolean
default: False
description: |
If True enables IPv6 support. The charm will expect network interfaces
to be configured with an IPv6 address. If set to False (default) IPv4
is expected.
.
NOTE: these charms do not currently support IPv6 privacy extension. In
order for this charm to function correctly, the privacy extension must be
disabled and a non-temporary address must be configured/available on
your network interface.
# Network configuration options
# by default all access is over 'private-address'
os-data-network:

View File

@ -32,6 +32,7 @@ from charmhelpers.contrib.hahelpers.apache import(
from charmhelpers.contrib.openstack.utils import (
configure_installation_source,
openstack_upgrade_available,
sync_db_with_multi_ipv6_addresses,
)
from charmhelpers.payload.execd import execd_preinstall
from charmhelpers.core.sysctl import create as create_sysctl
@ -138,10 +139,15 @@ def db_joined(relation_id=None):
'associated a postgresql one')
log(e, level=ERROR)
raise Exception(e)
relation_set(username=config('database-user'),
database=config('database'),
hostname=unit_get('private-address'),
relation_id=relation_id)
if config('prefer-ipv6'):
sync_db_with_multi_ipv6_addresses(config('database'),
config('database-user'))
else:
relation_set(username=config('database-user'),
database=config('database'),
hostname=unit_get('private-address'),
relation_id=relation_id)
@hooks.hook('pgsql-db-relation-joined')