Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions unit_tests/utilities/test_zaza_utilities_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,19 +1701,24 @@ def _get_action_output(stdout, code, stderr=None):
'Stderr': stderr,
'Stdout': stdout}}
return action

results = {
'/tmp/missing.cert': _get_action_output(
'',
'1',
'cat: /tmp/missing.cert: No such file or directory'),
'/tmp/good.cert': _get_action_output('CERTIFICATE', '0')}

async def _run(command, timeout=None):
return results[command.split()[-1]]
self.patch_object(openstack_utils.zaza.model, "async_run_on_unit")

async def _run_on_unit(unit_name, command, model_name=None,
timeout=None):
return results[command.split()[-1]].data.get('results')

self.async_run_on_unit.side_effect = _run_on_unit

self.unit1 = mock.MagicMock()
self.unit2 = mock.MagicMock()
self.unit2.run.side_effect = _run
self.unit1.run.side_effect = _run
self.units = [self.unit1, self.unit2]
_units = mock.MagicMock()
_units.units = self.units
Expand Down
14 changes: 14 additions & 0 deletions zaza/openstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@
# limitations under the License.

"""OpenStack specific zaza functionality."""
import os


def _set_proxy_vars():
# Set proxy vars if provided so that all code gets to use it.
for key, val in os.environ.items():
if not key.startswith('TEST_') or 'PROXY' not in key:
continue

_key = key.partition('TEST_')[2]
os.environ[_key.lower()] = val


_set_proxy_vars()
8 changes: 6 additions & 2 deletions zaza/openstack/utilities/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,12 @@ 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', '')
output = await zaza.model.async_run_on_unit(
unit.name,
'cat {}'.format(ca_file),
model_name=model_name
)
contents = output.get('Stdout', '')
if ca_cert not in contents:
break
# libjuju throws a generic error for connection failure. So we
Expand Down
Loading