diff options
| author | omnom62 <75066712+omnom62@users.noreply.github.com> | 2026-09-28 22:34:13 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-28 13:34:13 +0100 |
| commit | 7cfca28e5857b480920c22ae12557f55ca2a8a19 (patch) | |
| tree | 8e3bfc20dc621371af85b9d62e89b4f3e1838c01 /plugins/module_utils | |
| parent | 916b2cc86b29aabe3778be8fa88393f6a5324832 (diff) | |
| download | rest.vyos-7cfca28e5857b480920c22ae12557f55ca2a8a19.tar.gz rest.vyos-7cfca28e5857b480920c22ae12557f55ca2a8a19.zip | |
* T8989: vyos_vrf module
* T8989: vyos_vrf module
* T8989: vyos_vrf module unit tests
* T8989: vyos_vrf module integration tests
* T8989: vyos_vrf module integration tests
* T8989: vyos_vrf module changelog
* T8989: fix pylint disallowed-name issues
* T8989: fix pylint disallowed-name issues
* T8989: fix lint issues for vrf
* T8989: vrf AI comment fixed
* T8989: vrf AI comment fixed
---------
Co-authored-by: Daniil Baturin <daniil@vyos.io>
Diffstat (limited to 'plugins/module_utils')
| -rw-r--r-- | plugins/module_utils/vyos.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/module_utils/vyos.py b/plugins/module_utils/vyos.py index b7a519e..382394b 100644 --- a/plugins/module_utils/vyos.py +++ b/plugins/module_utils/vyos.py @@ -383,3 +383,24 @@ class VyOSModule: return True except VyOSRestError: return False + + +def import_module_plugin(name): + """Import a sibling plugin from plugins/modules/ by name. + + Ansible's AnsiballZ does not add plugins/modules to sys.path, so + collection modules cannot be imported via the standard import system. + This utility resolves the module file relative to this module_utils + directory and loads it with importlib. + """ + import importlib.util + import os + + modules_dir = os.path.normpath( + os.path.join(os.path.dirname(__file__), "..", "modules"), + ) + module_path = os.path.join(modules_dir, "{0}.py".format(name)) + spec = importlib.util.spec_from_file_location(name, module_path) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod |
