diff --git a/.gitreview b/.gitreview index 4700065..0eac5a3 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] host=review.openstack.org port=29418 -project=openstack/charm-ceph-mon.git \ No newline at end of file +project=openstack/charm-ceph-proxy diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 4d141cc..ebe3a62 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -10,17 +10,10 @@ import glob import os -import random import shutil -import socket -import subprocess import sys -import uuid -import time import ceph -from charmhelpers.core import host -from charmhelpers.core import hookenv from charmhelpers.core.hookenv import ( log, DEBUG, @@ -29,21 +22,13 @@ from charmhelpers.core.hookenv import ( related_units, relation_get, relation_set, - leader_set, leader_get, - is_leader, remote_unit, Hooks, UnregisteredHookError, service_name, - relations_of_type, - status_set, - local_unit) + status_set,) from charmhelpers.core.host import ( - service_restart, mkdir, - write_file, - rsync, - cmp_pkgrevno, - service_stop, service_start) + cmp_pkgrevno,) from charmhelpers.fetch import ( apt_install, apt_update, @@ -52,17 +37,8 @@ from charmhelpers.fetch import ( ) from charmhelpers.payload.execd import execd_preinstall from charmhelpers.contrib.openstack.alternatives import install_alternative -from charmhelpers.contrib.network.ip import ( - get_ipv6_addr, - format_ipv6_addr, -) -from charmhelpers.core.sysctl import create as create_sysctl + from charmhelpers.core.templating import render -from charmhelpers.contrib.storage.linux.ceph import ( - monitor_key_set, - monitor_key_exists, - monitor_key_get, - get_mon_map) from ceph_broker import ( process_requests @@ -73,7 +49,6 @@ from utils import ( get_unit_hostname, ) -from charmhelpers.contrib.charmsupport import nrpe from charmhelpers.contrib.hardening.harden import harden hooks = Hooks() @@ -115,15 +90,22 @@ def emit_cephconf(): charm_ceph_conf, 100) keyring = 'ceph.client.admin.keyring' keyring_path = '/etc/ceph/' + keyring - render(keyring, keyring_path, {'admin_key': config('admin-key')}, owner=ceph.ceph_user(), perms=0o600) + ctx = {'admin_key': config('admin-key')} + user = ceph.ceph_user() + render(keyring, keyring_path, ctx, owner=user, perms=0o600) keyring = 'keyring' - keyring_path = '/var/lib/ceph/mon/ceph-' + get_unit_hostname()+ '/' + keyring - render('mon.keyring', keyring_path, {'admin_key': config('admin-key')}, owner=ceph.ceph_user(), perms=0o600) + keyring_path = ( + '/var/lib/ceph/mon/ceph-' + + get_unit_hostname() + + '/' + + keyring) + render('mon.keyring', keyring_path, ctx, owner=user, perms=0o600) notify_radosgws() notify_client() + @hooks.hook('config-changed') @harden() def config_changed(): @@ -234,31 +216,6 @@ def assess_status(): status_set('active', 'Ready to proxy settings') else: status_set('blocked', 'Ensure FSID and admin-key are set') - # moncount = int(config('monitor-count')) - # units = get_peer_units() - # # not enough peers and mon_count > 1 - # if len(units.keys()) < moncount: - # status_set('blocked', 'Insufficient peer units to bootstrap' - # ' cluster (require {})'.format(moncount)) - # return - - # # mon_count > 1, peers, but no ceph-public-address - # ready = sum(1 for unit_ready in units.itervalues() if unit_ready) - # if ready < moncount: - # status_set('waiting', 'Peer units detected, waiting for addresses') - # return - - # # active - bootstrapped + quorum status check - # if ceph.is_bootstrapped() and ceph.is_quorum(): - # status_set('active', 'Unit is ready and clustered') - # else: - # # Unit should be running and clustered, but no quorum - # # TODO: should this be blocked or waiting? - # status_set('blocked', 'Unit not clustered (no quorum)') - # # If there's a pending lock for this unit, - # # can i get the lock? - # # reboot the ceph-mon process - # status_set('active', 'doing some shit maybe?') @hooks.hook('update-status') diff --git a/requirements.txt b/requirements.txt index a72939e..6a3271b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,3 @@ Jinja2>=2.6 # BSD License (3 clause) six>=1.9.0 dnspython>=1.12.0 psutil>=1.1.1,<2.0.0 -charm-tools>=2.0.0 \ No newline at end of file diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unit_tests/test_dummy.py b/unit_tests/test_dummy.py new file mode 100644 index 0000000..93f686e --- /dev/null +++ b/unit_tests/test_dummy.py @@ -0,0 +1,6 @@ +import unittest + + +class CharmTestCase(unittest.TestCase): + def test_it_works(self): + assert True