Merge "Remove mistral from the deploy_on_servers workflow"
This commit is contained in:
commit
1ba4c660e6
@ -156,7 +156,8 @@ class FakePlaybookExecution(utils.TestCommand):
|
|||||||
|
|
||||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||||
self.app.client_manager.baremetal = mock.Mock()
|
self.app.client_manager.baremetal = mock.Mock()
|
||||||
self.app.client_manager.compute = mock.Mock()
|
compute = self.app.client_manager.compute = mock.Mock()
|
||||||
|
compute.servers.list.return_value = []
|
||||||
self.app.client_manager.identity = mock.Mock()
|
self.app.client_manager.identity = mock.Mock()
|
||||||
self.app.client_manager.image = mock.Mock()
|
self.app.client_manager.image = mock.Mock()
|
||||||
self.app.client_manager.network = mock.Mock()
|
self.app.client_manager.network = mock.Mock()
|
||||||
|
@ -35,6 +35,13 @@ class TestFFWDUpgradePrepare(fakes.TestFFWDUpgradePrepare):
|
|||||||
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
|
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
|
||||||
self.mock_uuid4 = uuid4_patcher.start()
|
self.mock_uuid4 = uuid4_patcher.start()
|
||||||
self.addCleanup(self.mock_uuid4.stop)
|
self.addCleanup(self.mock_uuid4.stop)
|
||||||
|
deploy_action = mock.patch(
|
||||||
|
'tripleo_common.actions.deployment.OrchestrationDeployAction.run',
|
||||||
|
autospec=True
|
||||||
|
)
|
||||||
|
deploy_action.start()
|
||||||
|
deploy_action.return_value = mock.Mock(is_success=True)
|
||||||
|
self.addCleanup(deploy_action.stop)
|
||||||
|
|
||||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||||
'take_action')
|
'take_action')
|
||||||
|
@ -18,7 +18,10 @@ import logging
|
|||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from tripleo_common.actions import deployment as deployment_actions
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
|
from tripleoclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
class RemoteExecute(command.Command):
|
class RemoteExecute(command.Command):
|
||||||
@ -39,45 +42,36 @@ class RemoteExecute(command.Command):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
|
||||||
self.log.debug("take_action(%s)" % parsed_args)
|
self.log.debug("take_action({})".format(parsed_args))
|
||||||
config = parsed_args.file_in.read()
|
config = parsed_args.file_in.read()
|
||||||
parsed_args.file_in.close()
|
parsed_args.file_in.close()
|
||||||
workflow_client = self.app.client_manager.workflow_engine
|
|
||||||
tripleoclients = self.app.client_manager.tripleoclient
|
tripleoclients = self.app.client_manager.tripleoclient
|
||||||
messaging_websocket = tripleoclients.messaging_websocket()
|
|
||||||
|
|
||||||
# no special characters here
|
# no special characters here
|
||||||
config_name = re.sub('[^\w]*', '',
|
config_name = re.sub(
|
||||||
os.path.basename(parsed_args.file_in.name))
|
r'[^\w]*', '', os.path.basename(parsed_args.file_in.name)
|
||||||
|
)
|
||||||
|
|
||||||
if not parsed_args.server_name:
|
if not parsed_args.server_name:
|
||||||
raise Exception('Please specify the -s (--server_name) option.')
|
raise Exception('Please specify the -s (--server_name) option.')
|
||||||
|
|
||||||
workflow_input = {
|
context = tripleoclients.create_mistral_context()
|
||||||
'server_name': parsed_args.server_name,
|
init_deploy = deployment_actions.OrchestrationDeployAction(
|
||||||
'config_name': config_name,
|
server_id=self.app.client_manager.compute.servers.list(
|
||||||
'group': parsed_args.group,
|
search_opts={
|
||||||
'config': config
|
'name': parsed_args.server_name
|
||||||
}
|
}
|
||||||
|
),
|
||||||
workflow_client.executions.create(
|
config=config,
|
||||||
'tripleo.deployment.v1.deploy_on_servers',
|
name=config_name,
|
||||||
workflow_input=workflow_input
|
group=parsed_args.group
|
||||||
)
|
)
|
||||||
|
init_deploy_return = init_deploy.run(context=context)
|
||||||
while True:
|
if init_deploy_return.is_success():
|
||||||
body = messaging_websocket.recv()['body']
|
print(init_deploy_return)
|
||||||
if 'tripleo.deployment.v1.deploy_on_server' == body['type']:
|
else:
|
||||||
payload = body['payload']
|
raise exceptions.DeploymentError(
|
||||||
status = 'SUCCESS'
|
'Execution failed: {}'.format(
|
||||||
if payload['status_code'] != 0:
|
init_deploy_return
|
||||||
status = 'FAILED'
|
)
|
||||||
print('%s :: -- %s --' % (payload['server_name'], status))
|
)
|
||||||
if payload['stdout']:
|
|
||||||
print('stdout\n: %s\n' % payload['stdout'])
|
|
||||||
if payload['stderr']:
|
|
||||||
print('stderr\n: %s\n' % payload['stderr'])
|
|
||||||
if 'tripleo.deployment.v1.deploy_on_servers' == body['type']:
|
|
||||||
break
|
|
||||||
|
|
||||||
messaging_websocket.cleanup()
|
|
||||||
|
@ -18,8 +18,11 @@ from oslo_log import log as logging
|
|||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
|
from tripleo_common.actions import deployment as deployment_actions
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
from tripleoclient import constants
|
from tripleoclient import constants
|
||||||
|
from tripleoclient import exceptions
|
||||||
from tripleoclient import utils as oooutils
|
from tripleoclient import utils as oooutils
|
||||||
from tripleoclient.v1.overcloud_deploy import DeployOvercloud
|
from tripleoclient.v1.overcloud_deploy import DeployOvercloud
|
||||||
from tripleoclient.workflows import deployment
|
from tripleoclient.workflows import deployment
|
||||||
@ -62,10 +65,23 @@ class FFWDUpgradePrepare(DeployOvercloud):
|
|||||||
stack_name = stack.stack_name
|
stack_name = stack.stack_name
|
||||||
|
|
||||||
# ffwd-upgrade "init" run command on overcloud nodes
|
# ffwd-upgrade "init" run command on overcloud nodes
|
||||||
package_update.run_on_nodes(
|
context = clients.tripleoclient.create_mistral_context()
|
||||||
clients, server_name='all',
|
jobs = dict()
|
||||||
config_name='ffwd-upgrade-prepare',
|
for server in clients.compute.servers.list():
|
||||||
config=constants.FFWD_UPGRADE_PREPARE_SCRIPT, group='script')
|
init_deploy = deployment_actions.OrchestrationDeployAction(
|
||||||
|
server_id=server.id,
|
||||||
|
config=constants.FFWD_UPGRADE_PREPARE_SCRIPT,
|
||||||
|
name='ffwd-upgrade-prepare'
|
||||||
|
)
|
||||||
|
init_deploy_return = init_deploy.run(context=context)
|
||||||
|
jobs[server.name] = init_deploy_return.is_success()
|
||||||
|
|
||||||
|
if jobs and any([not i for i in jobs.values() if not i]):
|
||||||
|
raise exceptions.DeploymentError(
|
||||||
|
'The following nodes failed: {}'.format(
|
||||||
|
[k for k, v in jobs.items() if not v]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# In case of update and upgrade we need to force the
|
# In case of update and upgrade we need to force the
|
||||||
# update_plan_only. The heat stack update is done by the
|
# update_plan_only. The heat stack update is done by the
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import pprint
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from heatclient.common import event_utils
|
from heatclient.common import event_utils
|
||||||
@ -20,7 +19,6 @@ from tripleo_common.actions import package_update
|
|||||||
|
|
||||||
from tripleoclient import exceptions
|
from tripleoclient import exceptions
|
||||||
from tripleoclient import utils
|
from tripleoclient import utils
|
||||||
from tripleoclient.workflows import base
|
|
||||||
|
|
||||||
|
|
||||||
_WORKFLOW_TIMEOUT = 120 * 60 # 2h
|
_WORKFLOW_TIMEOUT = 120 * 60 # 2h
|
||||||
@ -107,24 +105,3 @@ def update(clients, container):
|
|||||||
' `openstack --os-cloud undercloud stack failures list {}`'
|
' `openstack --os-cloud undercloud stack failures list {}`'
|
||||||
' to investigate these failures further.'.format(container)
|
' to investigate these failures further.'.format(container)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_on_nodes(clients, **workflow_input):
|
|
||||||
workflow_client = clients.workflow_engine
|
|
||||||
tripleoclients = clients.tripleoclient
|
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
|
||||||
execution = base.start_workflow(
|
|
||||||
workflow_client,
|
|
||||||
'tripleo.deployment.v1.deploy_on_servers',
|
|
||||||
workflow_input=workflow_input
|
|
||||||
)
|
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution,
|
|
||||||
_WORKFLOW_TIMEOUT):
|
|
||||||
assert payload['status'] == "SUCCESS", pprint.pformat(payload)
|
|
||||||
|
|
||||||
if payload['status'] == "SUCCESS":
|
|
||||||
print('Success')
|
|
||||||
else:
|
|
||||||
raise RuntimeError('run on nodes failed: {}'.format(payload))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user