Require relation to nova-compute application
Without a relation to at least one nova-compute application a cinder-ceph backend will not be functional as the libvirt secrets will not have been created to allow access to the ceph cluster from libvirt/qemu. Add a simple context to check that the 'ceph-access' relation is present. This will result in a blocked status if the relation is not detected - for example: Missing relations: nova-compute Change-Id: Iedbf4aafc2348cbf6f14257417e86aa9aeb48a81 Closes-Bug: 1718051
This commit is contained in:
parent
e1f2335358
commit
f200d8dff5
|
@ -0,0 +1 @@
|
||||||
|
cinder_hooks.py
|
|
@ -0,0 +1 @@
|
||||||
|
cinder_hooks.py
|
|
@ -17,6 +17,8 @@ from charmhelpers.core.hookenv import (
|
||||||
service_name,
|
service_name,
|
||||||
is_relation_made,
|
is_relation_made,
|
||||||
leader_get,
|
leader_get,
|
||||||
|
relation_ids,
|
||||||
|
related_units,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack.context import (
|
from charmhelpers.contrib.openstack.context import (
|
||||||
|
@ -35,6 +37,17 @@ def ceph_config_file():
|
||||||
return CHARM_CEPH_CONF.format(service_name())
|
return CHARM_CEPH_CONF.format(service_name())
|
||||||
|
|
||||||
|
|
||||||
|
class CephAccessContext(OSContextGenerator):
|
||||||
|
interfaces = ['ceph-access']
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
"""Simple check to validate that compute units are present"""
|
||||||
|
for r_id in relation_ids(self.interfaces[0]):
|
||||||
|
if related_units(r_id):
|
||||||
|
return {'complete': True}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class CephSubordinateContext(OSContextGenerator):
|
class CephSubordinateContext(OSContextGenerator):
|
||||||
interfaces = ['ceph-cinder']
|
interfaces = ['ceph-cinder']
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ from charmhelpers.core.hookenv import (
|
||||||
)
|
)
|
||||||
from charmhelpers.core.host import mkdir
|
from charmhelpers.core.host import mkdir
|
||||||
|
|
||||||
|
import cinder_contexts
|
||||||
|
|
||||||
|
|
||||||
PACKAGES = [
|
PACKAGES = [
|
||||||
'ceph-common',
|
'ceph-common',
|
||||||
|
@ -39,6 +41,7 @@ VERSION_PACKAGE = 'cinder-common'
|
||||||
|
|
||||||
REQUIRED_INTERFACES = {
|
REQUIRED_INTERFACES = {
|
||||||
'ceph': ['ceph'],
|
'ceph': ['ceph'],
|
||||||
|
'nova-compute': ['ceph-access'],
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARM_CEPH_CONF = '/var/lib/charm/{}/ceph.conf'
|
CHARM_CEPH_CONF = '/var/lib/charm/{}/ceph.conf'
|
||||||
|
@ -84,7 +87,8 @@ def register_configs():
|
||||||
install_alternative(os.path.basename(CEPH_CONF),
|
install_alternative(os.path.basename(CEPH_CONF),
|
||||||
CEPH_CONF, ceph_config_file())
|
CEPH_CONF, ceph_config_file())
|
||||||
CONFIG_FILES[ceph_config_file()] = {
|
CONFIG_FILES[ceph_config_file()] = {
|
||||||
'hook_contexts': [context.CephContext()],
|
'hook_contexts': [context.CephContext(),
|
||||||
|
cinder_contexts.CephAccessContext()],
|
||||||
'services': ['cinder-volume'],
|
'services': ['cinder-volume'],
|
||||||
}
|
}
|
||||||
confs.append(ceph_config_file())
|
confs.append(ceph_config_file())
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
charm-tools>=2.4.4
|
charm-tools>=2.4.4
|
||||||
requests>=2.18.4
|
requests>=2.18.4
|
||||||
mock>=1.2
|
mock>=1.2
|
||||||
flake8>=2.2.4,<=2.4.1
|
flake8>=2.2.4
|
||||||
stestr>=2.2.0
|
stestr>=2.2.0
|
||||||
coverage>=4.5.2
|
coverage>=4.5.2
|
||||||
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
|
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
|
||||||
|
|
|
@ -26,6 +26,7 @@ def _add_path(path):
|
||||||
if path not in sys.path:
|
if path not in sys.path:
|
||||||
sys.path.insert(1, path)
|
sys.path.insert(1, path)
|
||||||
|
|
||||||
|
|
||||||
_add_path(_actions)
|
_add_path(_actions)
|
||||||
_add_path(_hooks)
|
_add_path(_hooks)
|
||||||
_add_path(_charmhelpers)
|
_add_path(_charmhelpers)
|
||||||
|
|
|
@ -24,6 +24,8 @@ TO_PATCH = [
|
||||||
'service_name',
|
'service_name',
|
||||||
'get_os_codename_package',
|
'get_os_codename_package',
|
||||||
'leader_get',
|
'leader_get',
|
||||||
|
'relation_ids',
|
||||||
|
'related_units',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,3 +142,19 @@ class TestCinderContext(CharmTestCase):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
def test_ceph_access_incomplete(self):
|
||||||
|
self.relation_ids.return_value = ['ceph-access:1']
|
||||||
|
self.related_units.return_value = []
|
||||||
|
self.assertEqual(
|
||||||
|
contexts.CephAccessContext()(),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_ceph_access_complete(self):
|
||||||
|
self.relation_ids.return_value = ['ceph-access:1']
|
||||||
|
self.related_units.return_value = ['nova-compute/0', 'nova-compute/1']
|
||||||
|
self.assertEqual(
|
||||||
|
contexts.CephAccessContext()(),
|
||||||
|
{'complete': True}
|
||||||
|
)
|
||||||
|
|
|
@ -93,9 +93,9 @@ class TestConfig(object):
|
||||||
return self.config
|
return self.config
|
||||||
|
|
||||||
def set(self, attr, value):
|
def set(self, attr, value):
|
||||||
if attr not in self.config:
|
if attr not in self.config:
|
||||||
raise KeyError
|
raise KeyError
|
||||||
self.config[attr] = value
|
self.config[attr] = value
|
||||||
|
|
||||||
|
|
||||||
class TestRelation(object):
|
class TestRelation(object):
|
||||||
|
|
Loading…
Reference in New Issue