Browse Source

Merge "Convert horizon url workflow to ansible"

tags/13.1.0
Zuul Gerrit Code Review 2 weeks ago
parent
commit
0f318d1576
4 changed files with 39 additions and 18 deletions
  1. +0
    -3
      tripleoclient/tests/fixture_data/deployment.py
  2. +17
    -0
      tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py
  3. +1
    -2
      tripleoclient/v1/overcloud_deploy.py
  4. +21
    -13
      tripleoclient/workflows/deployment.py

+ 0
- 3
tripleoclient/tests/fixture_data/deployment.py View File

@@ -27,9 +27,6 @@ class DeploymentWorkflowFixture(fixtures.Fixture):
self.mock_config_download = self.useFixture(fixtures.MockPatch(
'tripleoclient.workflows.deployment.config_download')
).mock
self.mock_get_horizon_url = self.useFixture(fixtures.MockPatch(
'tripleoclient.workflows.deployment.get_horizon_url')
).mock
self.mock_set_deployment_status = self.useFixture(fixtures.MockPatch(
'tripleoclient.workflows.deployment.set_deployment_status')
).mock


+ 17
- 0
tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py View File

@@ -109,6 +109,23 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
get_container = client.object_store.get_container = mock.MagicMock()
get_container.return_value = ('container', [{'name': 'f1'}])

# Mock playbook runner
playbook_runner = mock.patch(
'tripleoclient.utils.run_ansible_playbook',
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)

# Mock horizon url return
horizon_url = mock.patch(
'tripleoclient.workflows.deployment.get_horizon_url',
autospec=True
)
horizon_url.start()
horizon_url.return_value = 'fake://url:12345'
self.addCleanup(horizon_url.stop)

def tearDown(self):
super(TestDeployOvercloud, self).tearDown()
os.unlink(self.parameter_defaults_env_file)


+ 1
- 2
tripleoclient/v1/overcloud_deploy.py View File

@@ -1007,8 +1007,7 @@ class DeployOvercloud(command.Command):

overcloud_endpoint = utils.get_overcloud_endpoint(stack)

horizon_url = deployment.get_horizon_url(
self.clients, stack=stack.stack_name)
horizon_url = deployment.get_horizon_url(stack=stack.stack_name)

print("Overcloud Endpoint: {0}".format(overcloud_endpoint))
print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url))


+ 21
- 13
tripleoclient/workflows/deployment.py View File

@@ -12,6 +12,7 @@
from __future__ import print_function

import copy
import os
import pprint
import time
import yaml
@@ -334,22 +335,29 @@ def config_download_export(clients, **workflow_input):
payload['message']))


def get_horizon_url(clients, **workflow_input):
workflow_client = clients.workflow_engine
tripleoclients = clients.tripleoclient
def get_horizon_url(stack):
"""Return horizon URL string.

with tripleoclients.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.deployment.v1.get_horizon_url',
workflow_input=workflow_input
)
:params stack: Stack name
:type stack: string
:returns: string
"""

for payload in base.wait_for_messages(workflow_client, ws, execution,
360):
assert payload['status'] == "SUCCESS"
with utils.TempDirs() as tmp:
horizon_tmp_file = os.path.join(tmp, 'horizon_url')
utils.run_ansible_playbook(
playbook='cli-undercloud-get-horizon-url.yaml',
inventory='localhost,',
workdir=tmp,
playbook_dir=ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'stack_name': stack,
'horizon_url_output_file': horizon_tmp_file
}
)

return payload['horizon_url']
with open(horizon_tmp_file) as f:
return f.read().strip()


def get_deployment_status(clients, **workflow_input):


Loading…
Cancel
Save