Skip to content

Commit

Permalink
Merge pull request openstack-charmers#5 from cloud-padawan/ceph-proxy…
Browse files Browse the repository at this point in the history
…-tests

added ceph-proxy tests
  • Loading branch information
coreycb committed May 30, 2019
2 parents ce9db84 + 0c32e1b commit 1bbe859
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,19 @@ def _source_get_object():

self.assertEqual(target_content.decode('UTF-8'),
source_content.decode('UTF-8'))


class CephProxyTest(unittest.TestCase):
"""Test ceph via proxy."""

@classmethod
def setUpClass(cls):
"""Run class setup for running tests."""
super(CephProxyTest, cls).setUpClass()

def test_ceph_health(self):
"""Make sure ceph-proxy can communicate with ceph."""
self.assertEqual(
zaza_model.run_on_leader("ceph-proxy", "sudo ceph health")["Code"],
"0"
)
31 changes: 31 additions & 0 deletions zaza/openstack/configure/ceph_proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Module to setup ceph-proxy charm."""

import logging
import zaza.model as model


def setup_ceph_proxy():
"""
Configure ceph proxy with ceph metadata.
Fetches admin_keyring and FSID from ceph-mon and
uses those to configure ceph-proxy.
"""
raw_admin_keyring = model.run_on_leader(
"ceph-mon", 'cat /etc/ceph/ceph.client.admin.keyring')["Stdout"]
admin_keyring = [
line for line in raw_admin_keyring.split("\n") if "key" in line
][0].split(' = ')[-1].rstrip()
fsid = model.run_on_leader("ceph-mon", "leader-get fsid")["Stdout"]
cluster_ips = model.get_app_ips("ceph-mon")

proxy_config = {
'auth-supported': 'cephx',
'admin-key': admin_keyring,
'fsid': fsid,
'monitor-hosts': ' '.join(cluster_ips)
}

logging.debug('Config: {}'.format(proxy_config))

model.set_application_config("ceph-proxy", proxy_config)

0 comments on commit 1bbe859

Please sign in to comment.