From 7ca193c79d2666eae92712d5e732c3f681a3f722 Mon Sep 17 00:00:00 2001 From: Mohammed Boukhalfa Date: Mon, 28 Oct 2024 11:12:06 +0200 Subject: [PATCH] Add TLS option to external notifier This is needed when fakeIPA is needed is running with TLS Change-Id: Ida70590ac464992be61076ae1f2e5e9c13862983 Signed-off-by: Mohammed Boukhalfa --- .../emulator/resources/systems/fakedriver.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sushy_tools/emulator/resources/systems/fakedriver.py b/sushy_tools/emulator/resources/systems/fakedriver.py index 13b056c3..693bea2a 100644 --- a/sushy_tools/emulator/resources/systems/fakedriver.py +++ b/sushy_tools/emulator/resources/systems/fakedriver.py @@ -188,12 +188,24 @@ class FakeDriver(AbstractSystemsDriver): Info: Logs the start of the fake IPA boot process. Error: Logs any errors encountered during the request. """ - external_notification_url = self._config['EXTERNAL_NOTIFICATION_URL'] + external_notification_url = self._config.get( + 'EXTERNAL_NOTIFICATION_URL' + ) + cert = None + verify = False + if self._config.get("EXTERNAL_NOTIFICATION_CAFILE"): + verify = self._config.get("EXTERNAL_NOTIFICATION_CAFILE") + elif self._config.get("EXTERNAL_NOTIFICATION_CERTFILE") and \ + self._config.get("EXTERNAL_NOTIFICATION_KEYFILE"): + cert = (self._config.get("EXTERNAL_NOTIFICATION_CERTFILE"), + self._config.get("EXTERNAL_NOTIFICATION_KEYFILE")) + verify = True + self._logger.info( 'External notification to (%s): node %s power state changes', external_notification_url, system.get('name')) resp = requests.put( - external_notification_url, json=system, + external_notification_url, verify=verify, cert=cert, json=system, headers={'Content-type': 'application/json'}) # Check if the request was unsuccessful