@when('ceph-storage.available')
@when_not('ceph-storage.configured')
def ceph_storage(ceph_admin):
    'Ceph on kubernetes will require a few things - namely a ceph\n    configuration, and the ceph secret key file used for authentication.\n    This method will install the client package, and render the requisit files\n    in order to consume the ceph-storage relation.'
    ceph_context = {'mon_hosts': ceph_admin.mon_hosts(), 'fsid': ceph_admin.fsid(), 'auth_supported': ceph_admin.auth(), 'use_syslog': 'true', 'ceph_public_network': '', 'ceph_cluster_network': '', 'loglevel': 1, 'hostname': socket.gethostname()}
    apt_install(['ceph-common'], fatal=True)
    etc_ceph_directory = '/etc/ceph'
    if (not os.path.isdir(etc_ceph_directory)):
        os.makedirs(etc_ceph_directory)
    charm_ceph_conf = os.path.join(etc_ceph_directory, 'ceph.conf')
    render('ceph.conf', charm_ceph_conf, ceph_context)
    admin_key = os.path.join(etc_ceph_directory, 'ceph.client.admin.keyring')
    try:
        with open(admin_key, 'w') as key_file:
            key_file.write('[client.admin]\n\tkey = {}\n'.format(ceph_admin.key()))
    except IOError as err:
        hookenv.log('IOError writing admin.keyring: {}'.format(err))
    if ceph_admin.key():
        encoded_key = base64.b64encode(ceph_admin.key().encode('utf-8'))
    else:
        return
    context = {'secret': encoded_key.decode('ascii')}
    render('ceph-secret.yaml', '/tmp/ceph-secret.yaml', context)
    try:
        cmd = ['kubectl', 'apply', '-f', '/tmp/ceph-secret.yaml']
        check_call(cmd)
        os.remove('/tmp/ceph-secret.yaml')
    except:
        return
    set_state('ceph-storage.configured')
Ceph on kubernetes will require a few things - namely a ceph
configuration, and the ceph secret key file used for authentication.
This method will install the client package, and render the requisit files
in order to consume the ceph-storage relation.
@when('ceph-storage.available')
@when_not('ceph-storage.configured')
def ceph_storage(ceph_admin):
    'Ceph on kubernetes will require a few things - namely a ceph\n    configuration, and the ceph secret key file used for authentication.\n    This method will install the client package, and render the requisit files\n    in order to consume the ceph-storage relation.'
    ceph_context = {'mon_hosts': ceph_admin.mon_hosts(), 'fsid': ceph_admin.fsid(), 'auth_supported': ceph_admin.auth(), 'use_syslog': 'true', 'ceph_public_network': , 'ceph_cluster_network': , 'loglevel': 1, 'hostname': socket.gethostname()}
    apt_install(['ceph-common'], fatal=True)
    etc_ceph_directory = '/etc/ceph'
    if (not os.path.isdir(etc_ceph_directory)):
        os.makedirs(etc_ceph_directory)
    charm_ceph_conf = os.path.join(etc_ceph_directory, 'ceph.conf')
    render('ceph.conf', charm_ceph_conf, ceph_context)
    admin_key = os.path.join(etc_ceph_directory, 'ceph.client.admin.keyring')
    try:
        with open(admin_key, 'w') as key_file:
            key_file.write('[client.admin]\n\tkey = {}\n'.format(ceph_admin.key()))
    except IOError as err:
        hookenv.log('IOError writing admin.keyring: {}'.format(err))
    if ceph_admin.key():
        encoded_key = base64.b64encode(ceph_admin.key().encode('utf-8'))
    else:
        return
    context = {'secret': encoded_key.decode('ascii')}
    render('ceph-secret.yaml', '/tmp/ceph-secret.yaml', context)
    try:
        cmd = ['kubectl', 'apply', '-f', '/tmp/ceph-secret.yaml']
        check_call(cmd)
        os.remove('/tmp/ceph-secret.yaml')
    except:
        return
    set_state('ceph-storage.configured')