Skip to content

Commit

Permalink
mitigate metric variable installation
Browse files Browse the repository at this point in the history
  • Loading branch information
sametd committed Dec 20, 2023
1 parent 3a202f7 commit 1026913
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self, config, *args, **kwargs):
self.frequency = aviso_rest_config["frequency"]
self.enabled = aviso_rest_config["enabled"]
self.tlms = aviso_rest_config["tlms"]
#configure the metric vars once only here
OpsviewReporter.configure_metric_vars(config)
super().__init__(config, *args, **kwargs)

def process_messages(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@


class OpsviewReporter(ABC):
metric_ssl_enabled = False
metric_token = ""

def __init__(self, config: Config, msg_receiver=None):
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
self.monitor_servers = config.monitor_servers
self.msg_receiver = msg_receiver
self.token = {}

@classmethod
def configure_metric_vars(cls, config):
"""
Configures the class attributes based on the provided config.
"""
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if config.kube_state_metrics["ssl_enabled"]:
self.metric_ssl_enabled = True
self.metric_token = config.kube_state_metrics["token"]
cls.metric_ssl_enabled = True
cls.metric_token = config.kube_state_metrics["token"]

def ms_authenticate(self, m_server):
"""
Expand Down

0 comments on commit 1026913

Please sign in to comment.