From 2e0b9522505f4b839e98930415aeadcdbd910de2 Mon Sep 17 00:00:00 2001 From: alejandro Date: Fri, 18 Aug 2023 14:53:12 +0200 Subject: [PATCH] added set_global_variable and get_global_variable in snmp --- .../extras/pandoraPlugintools/snmp.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pandora_server/extras/pandoraPlugintools/snmp.py b/pandora_server/extras/pandoraPlugintools/snmp.py index 45bd487f74..19c8c04179 100644 --- a/pandora_server/extras/pandoraPlugintools/snmp.py +++ b/pandora_server/extras/pandoraPlugintools/snmp.py @@ -20,6 +20,46 @@ _GLOBAL_VARIABLES = { 'remote_port' : 161, } +#### +# Set a global variable with the specified name and assigns a value to it. +######################################################################################### +def set_global_variable( + variable_name: str = "", + value = None + )-> None: + """ + Sets the value of a global variable in the '_GLOBAL_VARIABLES' dictionary. + + Args: + variable_name (str): Name of the variable to set. + value (any): Value to assign to the variable. + + Returns: + None + """ + from .general import set_dict_key_value + + set_dict_key_value(_GLOBAL_VARIABLES, variable_name, value) + +#### +# Get a global variable with the specified name. +######################################################################################### +def get_global_variable( + variable_name: str = "" + )-> None: + """ + Gets the value of a global variable in the '_GLOBAL_VARIABLES' dictionary. + + Args: + variable_name (str): Name of the variable to set. + + Returns: + None + """ + from .general import get_dict_key_value + + get_dict_key_value(_GLOBAL_VARIABLES, variable_name) + #### # Creates an SNMP session based on the global configuration variables. #########################################################################################