Default ceph pool name to service name

Ensure that the pool name requested matches the service name
for the application, inline with other OpenStack charms.

Change-Id: Ia3ee274b52bdb2cb90a17e43ec5a379e7765efe0
This commit is contained in:
James Page 2017-09-25 11:05:26 +01:00
parent 17c89a1d63
commit 0764051352
5 changed files with 7 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
build/
.local/
.testrepository/
.stestr/
.tox/
func-results.json
test-charm/

View File

@ -33,8 +33,6 @@ GNOCCHI_WSGI_CONF = '/etc/apache2/sites-available/{}.conf'.format(
CEPH_CONF = '/etc/ceph/ceph.conf'
CEPH_POOL_NAME = 'gnocchi'
DB_INTERFACE = 'shared-db'

View File

@ -70,7 +70,7 @@ def cluster_connected(hacluster):
@reactive.when('storage-ceph.connected')
def storage_ceph_connected(ceph):
ceph.create_pool(gnocchi.CEPH_POOL_NAME)
ceph.create_pool(hookenv.service_name())
@reactive.when('storage-ceph.available')

View File

@ -28,7 +28,7 @@ coordination_url = {{ coordinator_memcached.url }}
{% if storage_ceph.key -%}
driver = ceph
ceph_pool = gnocchi
ceph_pool = {{ options.service_name }}
ceph_username = {{ options.service_name }}
ceph_secret = {{ storage_ceph.key }}
ceph_conffile = /etc/ceph/ceph.conf

View File

@ -95,11 +95,13 @@ class TestHandlers(test_utils.PatchHelper):
handlers.init_db()
self.gnocchi_charm.db_sync.assert_called_once_with()
def test_storage_ceph_connected(self):
@mock.patch.object(handlers, 'hookenv')
def test_storage_ceph_connected(self, hookenv):
mock_ceph = mock.MagicMock()
hookenv.service_name.return_value = 'mygnocchi'
handlers.storage_ceph_connected(mock_ceph)
mock_ceph.create_pool.assert_called_once_with(
handlers.gnocchi.CEPH_POOL_NAME
'mygnocchi',
)
@mock.patch.object(handlers, 'hookenv')