diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-07-26 14:06:31 +0300 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2020-07-26 14:06:31 +0300 |
commit | 5f78e67c746e9357cbb59fe066c2b32f34bc92ae (patch) | |
tree | 7a392c617c7a008f134a676436eb29eda24c98a4 /python/vyos/util.py | |
parent | 9578890e1e4dc31da7387a6ad810d2efb22391e7 (diff) | |
parent | 675942ce3e2329a0122da189cd5944df08d7fcab (diff) | |
download | vyos-1x-5f78e67c746e9357cbb59fe066c2b32f34bc92ae.tar.gz vyos-1x-5f78e67c746e9357cbb59fe066c2b32f34bc92ae.zip |
Merge branch 'current' of https://github.com/vyos/vyos-1x into current
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 924df6b3a..7078762df 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -242,7 +242,7 @@ def chown(path, user, group): if not os.path.exists(path): return False - + uid = getpwnam(user).pw_uid gid = getgrnam(group).gr_gid os.chown(path, uid, gid) @@ -652,3 +652,12 @@ def get_bridge_member_config(conf, br, intf): conf.set_level(old_level) return memberconf + +def check_kmod(k_mod): + """ Common utility function to load required kernel modules on demand """ + if isinstance(k_mod, str): + k_mod = k_mod.split() + for module in k_mod: + if not os.path.exists(f'/sys/module/{module}'): + if call(f'modprobe {module}') != 0: + raise ConfigError(f'Loading Kernel module {module} failed') |