From 13d37f254b2c3a7f1b9597decbcf245b12082353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 6 Nov 2022 10:58:22 +0100 Subject: [PATCH] Context class added --- plugins/inventory/reconstructed.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/inventory/reconstructed.py b/plugins/inventory/reconstructed.py index 85fd6b4..4d0c320 100644 --- a/plugins/inventory/reconstructed.py +++ b/plugins/inventory/reconstructed.py @@ -114,6 +114,24 @@ INSTR_FIELDS = {k: set(v + INSTR_COMMON_FIELDS) for k, v in INSTR_OWN_FIELDS.ite """All supported fields for each instruction, including common and specific fields.""" +class Context: + """Script execution context. + + This class contains the script's context when it is executed for a given + host. This includes the variable storage instance as well as the host's new + name if a ``rename_host`` instruction has been executed. + """ + + def __init__(self, host_vars): + """Initialize the context. + + Args: + host_vars: the host variables + """ + self.variables = VariableStorage(host_vars) + self.new_name = None + + class VariableStorage(MutableMapping): """Variable storage and cache.