Skip to content

Commit

Permalink
utilities/openstack: Fix handling of unit.run for CA check
Browse files Browse the repository at this point in the history
The `async_block_until_ca_exists` function makes direct use of the
libjuju APIs which changed in Juju 3.x.

Use the action normalise helper from the Zaza model module to
reconcile.

Signed-off-by: Frode Nordahl <[email protected]>
  • Loading branch information
fnordahl committed Jan 2, 2024
1 parent 53248f2 commit 418de2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions unit_tests/utilities/test_zaza_utilities_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,12 @@ def _get_action_output(stdout, code, stderr=None):
'Code': code,
'Stderr': stderr,
'Stdout': stdout}}
action.results = action.data['results']

async def _action_wait():
return action

action.wait = _action_wait
return action
results = {
'/tmp/missing.cert': _get_action_output(
Expand Down
11 changes: 9 additions & 2 deletions zaza/openstack/utilities/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,15 @@ async def _check_ca_present(model, ca_files):
for ca_file in ca_files:
for unit in units:
try:
output = await unit.run('cat {}'.format(ca_file))
contents = output.data.get('results').get('Stdout', '')
action = await unit.run('cat {}'.format(ca_file))
action = await action.wait()
# NOTE(fnordahl): yes, this is a call to a private
# function, and to be pragmatic we are already
# mocking about under the hood in this function, so let's
# just make it work.
results = zaza.model._normalise_action_results(
getattr(action, 'results', action.data.get('results')))
contents = results.get('stdout', '')
if ca_cert not in contents:
break
# libjuju throws a generic error for connection failure. So we
Expand Down

0 comments on commit 418de2c

Please sign in to comment.