Add nbd kernel module for snapshot mounts
Add nbd kernel module for mounting snapshots. Closes-Bug: 1961149 Change-Id: I59a8a02db3326026f58a775649b63935254b6cf6
This commit is contained in:
parent
f13d1bf9e6
commit
f674bcd4fa
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
import charms_openstack.charm as charm
|
import charms_openstack.charm as charm
|
||||||
import charms.reactive as reactive
|
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
|
# This charm's library contains all of the handler code associated with
|
||||||
# trilio_dm
|
# trilio_dm
|
||||||
@ -38,6 +41,23 @@ def render_config(*args):
|
|||||||
reactive.set_state("config.rendered")
|
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')
|
@reactive.when('shared-db.connected')
|
||||||
def default_setup_database(database):
|
def default_setup_database(database):
|
||||||
"""Handle the default database connection setup
|
"""Handle the default database connection setup
|
||||||
|
@ -7,3 +7,5 @@ sys.path.append("src/lib")
|
|||||||
import charms_openstack.test_mocks # noqa
|
import charms_openstack.test_mocks # noqa
|
||||||
|
|
||||||
charms_openstack.test_mocks.mock_charmhelpers()
|
charms_openstack.test_mocks.mock_charmhelpers()
|
||||||
|
sys.modules['charmhelpers.core.kernel'] = (
|
||||||
|
charms_openstack.test_mocks.charmhelpers.core.kernel)
|
||||||
|
@ -93,11 +93,17 @@ class Test(test_utils.PatchHelper):
|
|||||||
"ceph_connected": (
|
"ceph_connected": (
|
||||||
"ceph.connected",
|
"ceph.connected",
|
||||||
),
|
),
|
||||||
|
"setup_kernel_modules": (
|
||||||
|
"charm.installed",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
when_not_patterns = {
|
when_not_patterns = {
|
||||||
"ceph_connected": (
|
"ceph_connected": (
|
||||||
"ceph.access.req.sent",
|
"ceph.access.req.sent",
|
||||||
),
|
),
|
||||||
|
"setup_kernel_modules": (
|
||||||
|
"is-update-status-hook",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
# check the when hooks are attached to the expected functions
|
# check the when hooks are attached to the expected functions
|
||||||
for t, p in [
|
for t, p in [
|
||||||
|
Loading…
Reference in New Issue
Block a user