MCPcopy Create free account
hub / github.com/adobe/Marinus / SplunkConnector

Class SplunkConnector

python3_cron_scripts/libs3/SplunkConnector.py:27–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27class SplunkConnector(object):
28 splunk_config_file = "connector.config"
29 _logger = None
30
31 def _log(self):
32 """
33 Get the log
34 """
35 return logging.getLogger(__name__)
36
37 def _init_splunk_connection(self, config):
38 """
39 Initialize defaults
40 """
41 self.HOST = ConnectorUtil.get_config_setting(
42 self._logger, config, "Splunk", "splunk.host"
43 )
44 self.PORT = ConnectorUtil.get_config_setting(
45 self._logger, config, "Splunk", "splunk.port"
46 )
47 self.USERNAME = ConnectorUtil.get_config_setting(
48 self._logger, config, "Splunk", "splunk.username"
49 )
50 self.PASSWORD = ConnectorUtil.get_config_setting(
51 self._logger, config, "Splunk", "splunk.password"
52 )
53 self.APP = ConnectorUtil.get_config_setting(
54 self._logger, config, "Splunk", "splunk.app"
55 )
56
57 def __init__(self, config_file="", log_level=None):
58 """
59 Initialize the object
60 """
61
62 self._logger = self._log()
63 if log_level is not None:
64 self._logger.setLevel(log_level)
65
66 if config_file != "":
67 self.splunk_config_file = config_file
68
69 config = configparser.ConfigParser()
70 config_file = config.read(self.splunk_config_file)
71 if len(config_file) == 0:
72 self._logger.error("Error: Could not find the config file")
73 exit(1)
74
75 self._init_splunk_connection(config)
76
77 def get_splunk_client(self):
78 """
79 Create a Splunk client
80 """
81 try:
82 if self.APP is not None and self.APP != "":
83 service = client.connect(
84 host=self.HOST,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected