add juju availability zone to ceph osd location when present

The approach here is to use the availability zone as an imaginary rack.
All hosts that are in the same AZ will be in the same imaginary rack.
From Ceph's perspective this doesn't matter as it's just a bucket after all.
This will give users the ability to further customize their ceph deployment.

Change-Id: Ie25ac1b001db558d6a40fe3eaca014e8f4174241
This commit is contained in:
Chris MacNaughton 2016-03-16 16:13:25 -04:00
parent 5eb7fb5b65
commit c94e0b4b0e
2 changed files with 15 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import os
import shutil
import sys
import tempfile
import socket
import ceph
from charmhelpers.core.hookenv import (
@ -73,6 +74,12 @@ def install():
install_upstart_scripts()
def az_info():
az_info = os.environ.get('JUJU_AVAILABILITY_ZONE')
log("AZ Info: " + az_info)
return az_info
def emit_cephconf():
mon_hosts = get_mon_hosts()
log('Monitor hosts are ' + repr(mon_hosts))
@ -103,6 +110,10 @@ def emit_cephconf():
if not cluster_network:
cephcontext['cluster_addr'] = dynamic_ipv6_address
if az_info():
cephcontext['crush_location'] = "root=default rack={} host={}" \
.format(az_info(), socket.gethostname())
# Install ceph.conf as an alternative to support
# co-existence with other charms that write this file
charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())

View File

@ -29,6 +29,10 @@ public addr = {{ public_addr }}
cluster addr = {{ cluster_addr }}
{%- endif %}
{% if crush_location %}
osd crush location = {{crush_location}}
{% endif %}
[mon]
keyring = /var/lib/ceph/mon/$cluster-$id/keyring