def ceph_changed():
    if 'ceph' not in CONFIGS.complete_contexts():
        juju_log('ceph relation incomplete. Peer not ready?')
        return

    service = service_name()

    if not ensure_ceph_keyring(service=service,
                               user='******', group='glance'):
        juju_log('Could not create ceph keyring: peer not ready?')
        return

    CONFIGS.write(GLANCE_API_CONF)
    CONFIGS.write(CEPH_CONF)

    if eligible_leader(CLUSTER_RES):
        _config = config()
        ensure_ceph_pool(service=service,
                         replicas=_config['ceph-osd-replication-count'])
 def test_ensure_ceph_pool_already_exists(self):
     self.ceph_pool_exists.return_value = True
     utils.ensure_ceph_pool(service='glance', replicas=3)
     self.assertFalse(self.ceph_create_pool.called)
 def test_ensure_ceph_pool(self):
     self.ceph_pool_exists.return_value = False
     utils.ensure_ceph_pool(service='glance', replicas=3)
     self.ceph_create_pool.assert_called_with(service='glance',
                                              name='glance',
                                              replicas=3)