From 7cfca28e5857b480920c22ae12557f55ca2a8a19 Mon Sep 17 00:00:00 2001 From: omnom62 <75066712+omnom62@users.noreply.github.com> Date: Mon, 28 Sep 2026 22:34:13 +1000 Subject: T8989: vyos vrf module (#39) * 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 --- plugins/module_utils/vyos.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'plugins/module_utils/vyos.py') 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 -- cgit v1.2.3