aboutsummaryrefslogtreecommitdiffstats
path: root/contrail-agent/hooks/charmhelpers/core/kernel_factory/centos.py
blob: 1c402c1157900ff1ad5c6c296a409c9e8fb96d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import subprocess
import os


def persistent_modprobe(module):
    """Load a kernel module and configure for auto-load on reboot."""
    if not os.path.exists('/etc/rc.modules'):
        open('/etc/rc.modules', 'a')
        os.chmod('/etc/rc.modules', 111)
    with open('/etc/rc.modules', 'r+') as modules:
        if module not in modules.read():
            modules.write('modprobe %s\n' % module)


def update_initramfs(version='all'):
    """Updates an initramfs image."""
    return subprocess.check_call(["dracut", "-f", version])