Merge "Add nbd kernel module for snapshot mounts"

This commit is contained in:
Zuul 2022-09-27 12:57:13 +00:00 committed by Gerrit Code Review
commit 2eb9b5f0ab
3 changed files with 28 additions and 0 deletions

View File

@ -12,6 +12,9 @@
import charms_openstack.charm as charm
import charms.reactive as reactive
import charmhelpers.core.kernel as ch_kernel
import charmhelpers.core.host as ch_host
import charmhelpers.core.hookenv as ch_hookenv
# This charm's library contains all of the handler code associated with
# trilio_dm
@ -38,6 +41,23 @@ def render_config(*args):
reactive.set_state("config.rendered")
@reactive.when_not('is-update-status-hook')
@reactive.when('charm.installed')
def setup_kernel_modules():
module = 'nbd'
if ch_host.is_container():
ch_hookenv.log(
"Cannot load modules inside of a container",
level=ch_hookenv.WARNING)
else:
try:
ch_kernel.modprobe(module)
except Exception:
ch_hookenv.log(
"Failed to load kernel module '%s'" % module,
level=ch_hookenv.WARNING)
@reactive.when('shared-db.connected')
def default_setup_database(database):
"""Handle the default database connection setup

View File

@ -7,3 +7,5 @@ sys.path.append("src/lib")
import charms_openstack.test_mocks # noqa
charms_openstack.test_mocks.mock_charmhelpers()
sys.modules['charmhelpers.core.kernel'] = (
charms_openstack.test_mocks.charmhelpers.core.kernel)

View File

@ -93,11 +93,17 @@ class Test(test_utils.PatchHelper):
"ceph_connected": (
"ceph.connected",
),
"setup_kernel_modules": (
"charm.installed",
),
}
when_not_patterns = {
"ceph_connected": (
"ceph.access.req.sent",
),
"setup_kernel_modules": (
"is-update-status-hook",
),
}
# check the when hooks are attached to the expected functions
for t, p in [