6
from subprocess import CalledProcessError
7
from common import get_relation_config, chown, log
9
get_ceph_client_path, write_ceph_client_keyring, write_ceph_client_config)
12
relation_config = get_relation_config()
13
# The key is only reported once the ceph ring has quorum (there are enough
14
# nodes in the service). There's nothing to do until the key is provided.
15
if "key" not in relation_config:
16
log("Ceph key not reported in relation config, nothing to do.")
19
ceph_client_dir = get_ceph_client_path()
20
if not os.path.exists(ceph_client_dir):
21
os.mkdir(ceph_client_dir)
22
chown(ceph_client_dir)
24
# Create ceph client keyring and config for landscape-client use.
26
keyring_file = write_ceph_client_keyring(
27
"landscape-client", relation_config["key"])
28
except CalledProcessError as err:
29
log("Writing ceph keyring file failed with code %d" % err.returncode)
33
write_ceph_client_config(
34
relation_config["auth"], keyring_file,
35
relation_config["private-address"])
36
log("Ceph configuration written to file.")
37
except IOError as err:
38
log("Writing ceph configuratin file failed: %s" % err)