Changes Creation Of overcloudrc File to Call Workflow
This patch updates the code and associated tests to change from directly calling the tripleo.deployment.overcloudrc action to calling the tripleo.deployment.v1.create_overcloudrc workflow. Change-Id: Ib100163a5c9a5d2e6cca6cbc5a186e8e5cbc19ce Depends-On: I6074b4085b5b77f010f5f2972e7b120aa344f6c5 Partial-Bug: 1640436
This commit is contained in:
parent
de41293be4
commit
c692982bee
@ -11,7 +11,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import mock
|
||||
import shutil
|
||||
import tempfile
|
||||
@ -26,15 +25,22 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
|
||||
super(TestOvercloudCredentials, self).setUp()
|
||||
|
||||
self.cmd = overcloud_credentials.OvercloudCredentials(self.app, None)
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
self.workflow.action_executions.create.return_value = mock.MagicMock(
|
||||
output=json.dumps({
|
||||
"result": {
|
||||
"overcloudrc": "OVERCLOUDRC CONTENTS",
|
||||
"overcloudrc.v3": "OVERCLOUDRC.v3 CONTENTS",
|
||||
}
|
||||
})
|
||||
)
|
||||
self.app.client_manager.workflow_engine = self.workflow = mock.Mock()
|
||||
self.tripleoclient = mock.Mock()
|
||||
self.websocket = mock.Mock()
|
||||
self.websocket.__enter__ = lambda s: self.websocket
|
||||
self.websocket.__exit__ = lambda s, *exc: None
|
||||
self.tripleoclient.messaging_websocket.return_value = self.websocket
|
||||
self.app.client_manager.tripleoclient = self.tripleoclient
|
||||
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
"message": {
|
||||
"overcloudrc": "OVERCLOUDRC CONTENTS",
|
||||
"overcloudrc.v3": "OVERCLOUDRC.v3 CONTENTS",
|
||||
}
|
||||
}])
|
||||
|
||||
@mock.patch('os.chmod')
|
||||
def test_ok(self, mock_chmod):
|
||||
@ -43,6 +49,7 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
|
||||
('plan', 'overcloud'),
|
||||
('directory', '.')
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
with mock.patch("tripleoclient.utils.open", create=True) as m:
|
||||
@ -54,9 +61,9 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
|
||||
mock.call('./overcloudrc', 384),
|
||||
mock.call('./overcloudrc.v3', 384)])
|
||||
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.deployment.overcloudrc', {'container': 'overcloud'},
|
||||
run_sync=True, save_result=True)
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.deployment.v1.create_overcloudrc',
|
||||
workflow_input={'container': 'overcloud'})
|
||||
|
||||
@mock.patch('os.chmod')
|
||||
def test_okay_custom_dir(self, mock_chmod):
|
||||
@ -83,6 +90,6 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
|
||||
mock.call(path, 384),
|
||||
mock.call(pathv3, 384)])
|
||||
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.deployment.overcloudrc', {'container': 'overcloud'},
|
||||
run_sync=True, save_result=True)
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.deployment.v1.create_overcloudrc',
|
||||
workflow_input={'container': 'overcloud'})
|
||||
|
@ -352,7 +352,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
'_create_parameters_env', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
|
||||
@ -1666,7 +1666,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
@mock.patch('tripleoclient.utils.wait_for_provision_state')
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
|
||||
@ -1723,7 +1723,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
|
||||
@ -1761,7 +1761,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
|
||||
|
@ -36,7 +36,7 @@ class TestFFWDUpgradePrepare(fakes.TestFFWDUpgradePrepare):
|
||||
self.mock_uuid4 = uuid4_patcher.start()
|
||||
self.addCleanup(self.mock_uuid4.stop)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
|
||||
|
@ -36,7 +36,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
|
||||
self.mock_uuid4 = uuid4_patcher.start()
|
||||
self.addCleanup(self.mock_uuid4.stop)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
|
||||
|
@ -34,9 +34,9 @@ class OvercloudCredentials(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
workflow_engine = self.app.client_manager.workflow_engine
|
||||
clients = self.app.client_manager
|
||||
plan = parsed_args.plan
|
||||
dir_ = parsed_args.directory
|
||||
|
||||
overcloudrcs = deployment.overcloudrc(workflow_engine, container=plan)
|
||||
overcloudrcs = deployment.create_overcloudrc(clients, container=plan)
|
||||
utils.write_overcloudrc(plan, overcloudrcs, dir_)
|
||||
|
@ -894,8 +894,8 @@ class DeployOvercloud(command.Command):
|
||||
# Force fetching of attributes
|
||||
stack.get()
|
||||
|
||||
overcloudrcs = deployment.overcloudrc(
|
||||
self.workflow_client, container=stack.stack_name,
|
||||
overcloudrcs = deployment.create_overcloudrc(
|
||||
self.clients, container=stack.stack_name,
|
||||
no_proxy=parsed_args.no_proxy)
|
||||
|
||||
rcpath = utils.write_overcloudrc(stack.stack_name, overcloudrcs)
|
||||
|
@ -104,7 +104,7 @@ class FFWDUpgradePrepare(DeployOvercloud):
|
||||
ceph_ansible_playbook=ceph_ansible_playbook)
|
||||
package_update.get_config(clients, container=stack_name)
|
||||
|
||||
overcloudrcs = deployment.overcloudrc(
|
||||
overcloudrcs = deployment.create_overcloudrc(
|
||||
clients.workflow_engine,
|
||||
container=stack_name)
|
||||
oooutils.write_overcloudrc(stack_name, overcloudrcs)
|
||||
|
@ -87,7 +87,7 @@ class UpgradePrepare(DeployOvercloud):
|
||||
ceph_ansible_playbook=ceph_ansible_playbook)
|
||||
package_update.get_config(clients, container=stack_name)
|
||||
|
||||
overcloudrcs = deployment.overcloudrc(
|
||||
overcloudrcs = deployment.create_overcloudrc(
|
||||
clients.workflow_engine,
|
||||
container=stack_name)
|
||||
oooutils.write_overcloudrc(stack_name, overcloudrcs)
|
||||
|
@ -106,9 +106,26 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
||||
raise exceptions.DeploymentError("Heat Stack update failed.")
|
||||
|
||||
|
||||
def overcloudrc(workflow_client, **input_):
|
||||
return base.call_action(workflow_client, 'tripleo.deployment.overcloudrc',
|
||||
**input_)
|
||||
def create_overcloudrc(clients, **workflow_input):
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
|
||||
execution = base.start_workflow(
|
||||
workflow_client,
|
||||
'tripleo.deployment.v1.create_overcloudrc',
|
||||
workflow_input=workflow_input
|
||||
)
|
||||
|
||||
with tripleoclients.messaging_websocket() as ws:
|
||||
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
||||
# the workflow will return the overcloudrc data, an error message
|
||||
# or blank.
|
||||
if payload.get('status') == 'SUCCESS':
|
||||
return payload.get('message')
|
||||
else:
|
||||
raise exceptions.WorkflowServiceError(
|
||||
'Exception creating overcloudrc: {}'.format(
|
||||
payload.get('message')))
|
||||
|
||||
|
||||
def get_overcloud_hosts(stack, ssh_network):
|
||||
|
Loading…
x
Reference in New Issue
Block a user