Use public/cluster addr for osd, osd mon can't parse ipv6 network.
This commit is contained in:
parent
719623f0b6
commit
6f8364f410
|
@ -41,15 +41,15 @@ from charmhelpers.fetch import (
|
||||||
from charmhelpers.payload.execd import execd_preinstall
|
from charmhelpers.payload.execd import execd_preinstall
|
||||||
from charmhelpers.contrib.openstack.alternatives import install_alternative
|
from charmhelpers.contrib.openstack.alternatives import install_alternative
|
||||||
from charmhelpers.contrib.network.ip import (
|
from charmhelpers.contrib.network.ip import (
|
||||||
is_ipv6
|
is_ipv6,
|
||||||
|
get_ipv6_addr
|
||||||
)
|
)
|
||||||
|
|
||||||
from utils import (
|
from utils import (
|
||||||
render_template,
|
render_template,
|
||||||
get_public_addr,
|
get_public_addr,
|
||||||
assert_charm_supports_ipv6,
|
assert_charm_supports_ipv6,
|
||||||
get_host_ip,
|
get_host_ip
|
||||||
get_network
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hooks = Hooks()
|
hooks = Hooks()
|
||||||
|
@ -87,11 +87,11 @@ def emit_cephconf():
|
||||||
}
|
}
|
||||||
|
|
||||||
if config('prefer-ipv6'):
|
if config('prefer-ipv6'):
|
||||||
network = get_network()
|
dynamic_ipv6_address = get_ipv6_addr()[0]
|
||||||
if not config('ceph-public-network'):
|
if not config('ceph-public-network'):
|
||||||
cephcontext['ceph_public_network'] = network
|
cephcontext['public_addr'] = dynamic_ipv6_address
|
||||||
if not config('ceph-cluster-network'):
|
if not config('ceph-cluster-network'):
|
||||||
cephcontext['ceph_cluster_network'] = network
|
cephcontext['cluster_addr'] = dynamic_ipv6_address
|
||||||
|
|
||||||
# Install ceph.conf as an alternative to support
|
# Install ceph.conf as an alternative to support
|
||||||
# co-existence with other charms that write this file
|
# co-existence with other charms that write this file
|
||||||
|
|
|
@ -98,33 +98,3 @@ def assert_charm_supports_ipv6():
|
||||||
if lsb_release()['DISTRIB_CODENAME'].lower() < "trusty":
|
if lsb_release()['DISTRIB_CODENAME'].lower() < "trusty":
|
||||||
raise Exception("IPv6 is not supported in the charms for Ubuntu "
|
raise Exception("IPv6 is not supported in the charms for Ubuntu "
|
||||||
"versions less than Trusty 14.04")
|
"versions less than Trusty 14.04")
|
||||||
|
|
||||||
|
|
||||||
def get_network(iface="eth0"):
|
|
||||||
try:
|
|
||||||
try:
|
|
||||||
import netifaces
|
|
||||||
except ImportError:
|
|
||||||
apt_install('python-netifaces')
|
|
||||||
import netifaces
|
|
||||||
|
|
||||||
try:
|
|
||||||
from netaddr import IPNetwork
|
|
||||||
except ImportError:
|
|
||||||
apt_install('python-netaddr', fatal=True)
|
|
||||||
from netaddr import IPNetwork
|
|
||||||
|
|
||||||
ipv6_address = get_ipv6_addr(iface)[0]
|
|
||||||
ifa_addrs = netifaces.ifaddresses(iface)
|
|
||||||
|
|
||||||
for ifaddr in ifa_addrs[netifaces.AF_INET6]:
|
|
||||||
if ipv6_address == ifaddr['addr']:
|
|
||||||
network = "{}/{}".format(ifaddr['addr'],
|
|
||||||
ifaddr['netmask'])
|
|
||||||
ip = IPNetwork(network)
|
|
||||||
return str(ip.network)
|
|
||||||
|
|
||||||
except ValueError:
|
|
||||||
raise Exception("Invalid interface '%s'" % iface)
|
|
||||||
|
|
||||||
raise Exception("No valid network found in interface '%s'" % iface)
|
|
||||||
|
|
|
@ -33,3 +33,9 @@ keyring = /var/lib/ceph/osd/$cluster-$id/keyring
|
||||||
osd journal size = {{ osd_journal_size }}
|
osd journal size = {{ osd_journal_size }}
|
||||||
filestore xattr use omap = true
|
filestore xattr use omap = true
|
||||||
|
|
||||||
|
{% if public_addr %}
|
||||||
|
public addr = {{ public_addr }}
|
||||||
|
{% endif %}
|
||||||
|
{% if cluster_addr %}
|
||||||
|
cluster addr = {{ cluster_addr }}
|
||||||
|
{%- endif %}
|
||||||
|
|
Loading…
Reference in New Issue