Do IPv6 check for supported version.
This commit is contained in:
parent
a6ef02a945
commit
721f6514f0
|
@ -47,4 +47,3 @@ options:
|
|||
default: false
|
||||
type: boolean
|
||||
description: "Enable IPv6."
|
||||
|
||||
|
|
|
@ -184,6 +184,7 @@ def configure_db(hostname,
|
|||
username,
|
||||
admin=False):
|
||||
''' Configure access to database for username from hostname '''
|
||||
|
||||
if config_get('prefer-ipv6'):
|
||||
remote_ip = hostname
|
||||
elif hostname != unit_get('private-address'):
|
||||
|
|
|
@ -46,6 +46,7 @@ from percona_utils import (
|
|||
seeded, mark_seeded,
|
||||
configure_mysql_root_password,
|
||||
relation_clear,
|
||||
setup_ipv6
|
||||
)
|
||||
from mysql import (
|
||||
get_mysql_password,
|
||||
|
@ -64,7 +65,7 @@ from charmhelpers.contrib.network.ip import (
|
|||
is_address_in_network,
|
||||
get_address_in_network,
|
||||
get_netmask_for_address,
|
||||
get_ipv6_addr,
|
||||
get_ipv6_addr
|
||||
)
|
||||
|
||||
hooks = Hooks()
|
||||
|
@ -83,6 +84,9 @@ def install():
|
|||
apt_update(fatal=True)
|
||||
apt_install(PACKAGES, fatal=True)
|
||||
configure_sstuser(config('sst-password'))
|
||||
|
||||
if config('prefer-ipv6'):
|
||||
setup_ipv6()
|
||||
|
||||
|
||||
def render_config(clustered=False, hosts=[]):
|
||||
|
@ -110,6 +114,9 @@ def render_config(clustered=False, hosts=[]):
|
|||
@hooks.hook('upgrade-charm')
|
||||
@hooks.hook('config-changed')
|
||||
def config_changed():
|
||||
if config('prefer-ipv6'):
|
||||
setup_ipv6()
|
||||
|
||||
hosts = get_cluster_hosts()
|
||||
clustered = len(hosts) > 1
|
||||
pre_hash = file_hash(MY_CNF)
|
||||
|
|
|
@ -4,7 +4,7 @@ from subprocess import Popen, PIPE
|
|||
import socket
|
||||
import os
|
||||
from charmhelpers.core.host import (
|
||||
lsb_release,
|
||||
lsb_release
|
||||
)
|
||||
from charmhelpers.core.hookenv import (
|
||||
unit_get,
|
||||
|
@ -13,17 +13,18 @@ from charmhelpers.core.hookenv import (
|
|||
relation_get,
|
||||
relation_set,
|
||||
local_unit,
|
||||
config,
|
||||
config
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
filter_installed_packages,
|
||||
filter_installed_packages
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_ipv6_addr,
|
||||
get_ipv6_addr
|
||||
)
|
||||
from mysql import get_mysql_root_password, MySQLHelper
|
||||
|
||||
|
||||
try:
|
||||
import jinja2
|
||||
except ImportError:
|
||||
|
@ -106,6 +107,7 @@ def get_cluster_hosts():
|
|||
for relid in relation_ids('cluster'):
|
||||
for unit in related_units(relid):
|
||||
private_address = relation_get('private-address', unit, relid)
|
||||
|
||||
if config('prefer-ipv6'):
|
||||
hostname = relation_get('hostname', unit, relid)
|
||||
if not hostname or hostname in hosts:
|
||||
|
@ -175,3 +177,9 @@ def render_hosts(map):
|
|||
for line in lines:
|
||||
hosts.write(line)
|
||||
|
||||
|
||||
def setup_ipv6():
|
||||
ubuntu_rel = float(lsb_release()['DISTRIB_RELEASE'])
|
||||
if ubuntu_rel < 14.04:
|
||||
raise Exception("IPv6 is not supported for Ubuntu "
|
||||
"versions less than Trusty 14.04")
|
||||
|
|
Loading…
Reference in New Issue