33
33
from charmhelpers.core.host import (
37
37
from utils import (
44
check_optional_relations,
46
47
from charmhelpers.payload.execd import execd_preinstall
47
48
from charmhelpers.core.host import cmp_pkgrevno
48
from socket import gethostname as get_unit_hostname
50
50
from charmhelpers.contrib.network.ip import (
51
51
get_iface_for_address,
98
100
def install_packages():
101
status_set('maintenance', 'Installing apt packages')
99
102
add_source(config('source'), config('key'))
100
103
if (config('use-ceph-optimised-packages') and
101
104
not config('use-embedded-webserver')):
112
115
@hooks.hook('install.real')
117
status_set('maintenance', 'Executing pre-install')
114
118
execd_preinstall()
115
119
enable_pocket('multiverse')
116
120
install_packages()
117
121
os.makedirs(NSS_DIR)
121
# Ensure ceph directory actually exists
122
122
if not os.path.exists('/etc/ceph'):
123
123
os.makedirs('/etc/ceph')
126
'auth_supported': get_auth() or 'none',
127
'mon_hosts': ' '.join(get_mon_hosts()),
128
'hostname': get_unit_hostname(),
129
'old_auth': cmp_pkgrevno('radosgw', "0.51") < 0,
130
'use_syslog': str(config('use-syslog')).lower(),
131
'embedded_webserver': config('use-embedded-webserver'),
134
# Check to ensure that correct version of ceph is
136
if cmp_pkgrevno('radosgw', '0.55') >= 0:
137
# Add keystone configuration if found
138
ks_conf = get_keystone_conf()
140
cephcontext.update(ks_conf)
142
with open('/etc/ceph/ceph.conf', 'w') as cephconf:
143
cephconf.write(render_template('ceph.conf', cephcontext))
146
126
def emit_apacheconf():
147
127
apachecontext = {
194
174
identity_joined(relid=r_id)
199
for relid in relation_ids('mon'):
200
for unit in related_units(relid):
201
host_ip = get_host_ip(relation_get('ceph-public-address',
203
hosts.append('{}:6789'.format(host_ip))
210
return get_conf('auth')
214
for relid in relation_ids('mon'):
215
for unit in related_units(relid):
216
conf = relation_get(name,
223
def get_keystone_conf():
224
for relid in relation_ids('identity-service'):
225
for unit in related_units(relid):
227
'auth_type': 'keystone',
229
relation_get('auth_protocol', unit, relid) or "http",
230
'auth_host': relation_get('auth_host', unit, relid),
231
'auth_port': relation_get('auth_port', unit, relid),
232
'admin_token': relation_get('admin_token', unit, relid),
233
'user_roles': config('operator-roles'),
234
'cache_size': config('cache-size'),
235
'revocation_check_interval':
236
config('revocation-check-interval')
238
if None not in ks_auth.itervalues():
243
177
@hooks.hook('mon-relation-departed',
244
178
'mon-relation-changed')
245
179
@restart_on_change({'/etc/ceph/ceph.conf': ['radosgw']})
246
180
def mon_relation():
248
182
key = relation_get('radosgw_key')
250
184
ceph.import_radosgw_key(key)
377
311
hooks.execute(sys.argv)
378
312
except UnregisteredHookError as e:
379
313
log('Unknown hook {} - skipping.'.format(e))
314
set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
315
charm_func=check_optional_relations)