Skip to content

Commit

Permalink
Only load the config once on intelmqctl init
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalTrustCenter authored and aaronkaplan committed Jan 31, 2024
1 parent 1d4105c commit 51500be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
(PR#2408 and PR#2414 by Jan Kaliszewski).
- `intelmq.lib.upgrades`: Replace deprecated instances of `url2fqdn` experts by the new `url` expert in runtime configuration (PR#2432 by Sebastian Wagner).
- `intelmq.lib.bot`: Ensure closing log files on reloading (PR#2435 by Kamil Mankowski).
- Only load the config once when starting intelmqctl (which makes IntelMQ API calls take less time) (PR#2444 by DigitalTrustCenter).

### Development
- Makefile: Add codespell and test commands (PR#2425 by Sebastian Wagner).
Expand Down
13 changes: 7 additions & 6 deletions intelmq/bin/intelmqctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
self._parameters.logging_handler = 'file'
self._parameters.logging_path = DEFAULT_LOGGING_PATH

try:
self._runtime_configuration = utils.load_configuration(RUNTIME_CONF_FILE)
except ValueError as exc: # pragma: no cover
self.abort(f'Error loading {RUNTIME_CONF_FILE!r}: {exc}')

# Try to get logging_level from defaults configuration, else use default (defined above)
defaults_loading_exc = None
try:
Expand Down Expand Up @@ -203,11 +208,6 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
intelmqctl debug --get-environment-variables
'''

try:
self._runtime_configuration = utils.load_configuration(RUNTIME_CONF_FILE)
except ValueError as exc: # pragma: no cover
self.abort(f'Error loading {RUNTIME_CONF_FILE!r}: {exc}')

self._processmanagertype = getattr(self._parameters, 'process_manager', 'intelmq')
if self._processmanagertype not in process_managers():
self.abort('Invalid process manager given: %r, should be one of %r.' '' % (self._processmanagertype, list(process_managers().keys())))
Expand Down Expand Up @@ -384,7 +384,8 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
)

def load_defaults_configuration(self, silent=False):
for option, value in utils.get_global_settings().items():
global_settings = self._runtime_configuration.get('global', {})
for option, value in global_settings.items():
setattr(self._parameters, option, value)

# copied from intelmq.lib.bot, should be refactored to e.g. intelmq.lib.config
Expand Down

0 comments on commit 51500be

Please sign in to comment.