Skip to content

Commit 51500be

Browse files
DigitalTrustCenteraaronkaplan
authored andcommitted
Only load the config once on intelmqctl init
1 parent 1d4105c commit 51500be

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
(PR#2408 and PR#2414 by Jan Kaliszewski).
3535
- `intelmq.lib.upgrades`: Replace deprecated instances of `url2fqdn` experts by the new `url` expert in runtime configuration (PR#2432 by Sebastian Wagner).
3636
- `intelmq.lib.bot`: Ensure closing log files on reloading (PR#2435 by Kamil Mankowski).
37+
- Only load the config once when starting intelmqctl (which makes IntelMQ API calls take less time) (PR#2444 by DigitalTrustCenter).
3738

3839
### Development
3940
- Makefile: Add codespell and test commands (PR#2425 by Sebastian Wagner).

intelmq/bin/intelmqctl.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
8787
self._parameters.logging_handler = 'file'
8888
self._parameters.logging_path = DEFAULT_LOGGING_PATH
8989

90+
try:
91+
self._runtime_configuration = utils.load_configuration(RUNTIME_CONF_FILE)
92+
except ValueError as exc: # pragma: no cover
93+
self.abort(f'Error loading {RUNTIME_CONF_FILE!r}: {exc}')
94+
9095
# Try to get logging_level from defaults configuration, else use default (defined above)
9196
defaults_loading_exc = None
9297
try:
@@ -203,11 +208,6 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
203208
intelmqctl debug --get-environment-variables
204209
'''
205210

206-
try:
207-
self._runtime_configuration = utils.load_configuration(RUNTIME_CONF_FILE)
208-
except ValueError as exc: # pragma: no cover
209-
self.abort(f'Error loading {RUNTIME_CONF_FILE!r}: {exc}')
210-
211211
self._processmanagertype = getattr(self._parameters, 'process_manager', 'intelmq')
212212
if self._processmanagertype not in process_managers():
213213
self.abort('Invalid process manager given: %r, should be one of %r.' '' % (self._processmanagertype, list(process_managers().keys())))
@@ -384,7 +384,8 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
384384
)
385385

386386
def load_defaults_configuration(self, silent=False):
387-
for option, value in utils.get_global_settings().items():
387+
global_settings = self._runtime_configuration.get('global', {})
388+
for option, value in global_settings.items():
388389
setattr(self._parameters, option, value)
389390

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

0 commit comments

Comments
 (0)