Skip to content

Commit

Permalink
Merge pull request #26 from Nordix/add-tls-option/mboukhalfa
Browse files Browse the repository at this point in the history
✨ Add option to enable TLS
  • Loading branch information
metal3-io-bot authored Oct 28, 2024
2 parents ad9418f + 1157e3b commit 7bdb949
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion fake-ipa/fake_ipa/heartbeater.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ def _heartbeat_expected(self, agent, previous_heartbeat):

def do_heartbeat(self, system, agent):
"""Send a heartbeat to Ironic."""

# if tls enabled with fakeIPA use HTTPS else HTTP
adv_protocol="http"
cert = self._config.get("FAKE_IPA_CERTFILE")
key = self._config.get("FAKE_IPA_KEYFILE")
if cert is not None and key is not None :
adv_protocol="https"
try:
agent.api_client.heartbeat(
uuid=agent.node['uuid'],
advertise_address=Host(
hostname=self._config['FAKE_IPA_ADVERTISE_ADDRESS_IP'],
port=self._config['FAKE_IPA_ADVERTISE_ADDRESS_PORT']),
advertise_protocol="https",
advertise_protocol=adv_protocol,
generated_cert=None,
)
self._logger.info('heartbeat successful')
Expand Down
9 changes: 8 additions & 1 deletion fake-ipa/fake_ipa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ def main():
'FAKE_IPA_ADVERTISE_ADDRESS_IP: %s',
app.config.get('FAKE_IPA_ADVERTISE_ADDRESS_IP')
)
app.run(host=app.config.get('SUSHY_FAKE_IPA_LISTEN_IP', '0.0.0.0'),
cert = app.config.get("FAKE_IPA_CERTFILE")
key = app.config.get("FAKE_IPA_KEYFILE")
if cert is not None and key is not None:
ssl = (cert, key)
else:
ssl = None
app.run(ssl_context=ssl,
host=app.config.get('SUSHY_FAKE_IPA_LISTEN_IP', '0.0.0.0'),
port=app.config.get('SUSHY_FAKE_IPA_LISTEN_PORT', DEFAULT_PORT),
debug=True)

Expand Down

0 comments on commit 7bdb949

Please sign in to comment.