Remove openstack overcloud failures command
This was added to fetch the ansible errors via mistral api. We had long removed the json_error.py callback plugin that used to write ansible-errors.json, when moving ansible code to tripleo-ansible repo and the command is useless now. Also, users won't need it as they can get the errors from ansible.log. Change-Id: Iceb4c282f3ae9fcb2c3836263ba66f5792e42334
This commit is contained in:
parent
2b6fc058f7
commit
7cef22cc68
@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
``openstack overcloud failures`` command used to get ansible
|
||||
errors with mistral api has been removed as part of removal
|
||||
of mistral service from undercloud.
|
@ -62,7 +62,6 @@ openstack.tripleoclient.v2 =
|
||||
overcloud_credentials = tripleoclient.v1.overcloud_credentials:OvercloudCredentials
|
||||
overcloud_deploy = tripleoclient.v1.overcloud_deploy:DeployOvercloud
|
||||
overcloud_export = tripleoclient.v1.overcloud_export:ExportOvercloud
|
||||
overcloud_failures = tripleoclient.v1.overcloud_deploy:GetDeploymentFailures
|
||||
overcloud_status = tripleoclient.v1.overcloud_deploy:GetDeploymentStatus
|
||||
overcloud_image_build = tripleoclient.v1.overcloud_image:BuildOvercloudImage
|
||||
overcloud_image_upload = tripleoclient.v1.overcloud_image:UploadOvercloudImage
|
||||
|
@ -1840,57 +1840,3 @@ class TestGetDeploymentStatus(utils.TestCommand):
|
||||
'+-----------+-------------------+\n')
|
||||
|
||||
self.assertEqual(expected, self.cmd.app.stdout.getvalue())
|
||||
|
||||
|
||||
class TestGetDeploymentFailures(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestGetDeploymentFailures, self).setUp()
|
||||
|
||||
self.cmd = overcloud_deploy.GetDeploymentFailures(self.app, None)
|
||||
self.app.client_manager = mock.Mock()
|
||||
self.clients = self.app.client_manager
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.deployment.get_deployment_failures',
|
||||
autospec=True)
|
||||
def test_plan_get_deployment_status(self, mock_get_deployment_failures):
|
||||
parsed_args = self.check_parser(self.cmd, [], [])
|
||||
self.cmd.app.stdout = six.StringIO()
|
||||
|
||||
failures = {
|
||||
'host0': [
|
||||
['Task1', dict(key1=1, key2=2, key3=3)],
|
||||
['Task2', dict(key4=4, key5=5, key3=5)]
|
||||
],
|
||||
'host1': [
|
||||
['Task1', dict(key1=1, key2=2, key3=['a', 'b', 'c'])]
|
||||
],
|
||||
}
|
||||
|
||||
mock_get_deployment_failures.return_value = failures
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
expected = (
|
||||
'|-> Failures for host: host0\n'
|
||||
'|--> Task: Task1\n'
|
||||
'|---> key1: 1\n'
|
||||
'|---> key2: 2\n'
|
||||
'|---> key3: 3\n'
|
||||
'|--> Task: Task2\n'
|
||||
'|---> key3: 5\n'
|
||||
'|---> key4: 4\n'
|
||||
'|---> key5: 5\n'
|
||||
'\n'
|
||||
'|-> Failures for host: host1\n'
|
||||
'|--> Task: Task1\n'
|
||||
'|---> key1: 1\n'
|
||||
'|---> key2: 2\n'
|
||||
'|---> key3: [\n'
|
||||
' "a",\n'
|
||||
' "b",\n'
|
||||
' "c"\n'
|
||||
']\n\n')
|
||||
|
||||
self.assertEqual(expected, self.cmd.app.stdout.getvalue())
|
||||
|
@ -15,7 +15,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
@ -1122,51 +1121,3 @@ class GetDeploymentStatus(command.Command):
|
||||
['Plan Name', 'Deployment Status'])
|
||||
table.add_row([plan, status])
|
||||
print(table, file=self.app.stdout)
|
||||
|
||||
|
||||
class GetDeploymentFailures(command.Command):
|
||||
"""Get deployment failures"""
|
||||
|
||||
log = logging.getLogger(__name__ + ".GetDeploymentFailures")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(GetDeploymentFailures, self).get_parser(prog_name)
|
||||
parser.add_argument('--plan', '--stack',
|
||||
help=_('Name of the stack/plan. '
|
||||
'(default: overcloud)'),
|
||||
default='overcloud')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
plan = parsed_args.plan
|
||||
|
||||
failures = deployment.get_deployment_failures(
|
||||
self.app.client_manager,
|
||||
plan=plan
|
||||
)
|
||||
|
||||
out = self.app.stdout
|
||||
|
||||
hosts = list(failures.keys())
|
||||
hosts.sort()
|
||||
|
||||
for host in hosts:
|
||||
host_failures = failures[host]
|
||||
host_failures = sorted(host_failures, key=lambda k: k[0])
|
||||
out.write("|-> Failures for host: %s\n" % host)
|
||||
for task_name, task in host_failures:
|
||||
out.write('|--> Task: %s\n' % task_name)
|
||||
task_keys = sorted(task.keys())
|
||||
for task_key in task_keys:
|
||||
task_value = task[task_key]
|
||||
out.write('|---> %s: ' % task_key)
|
||||
try:
|
||||
value = json.dumps(task_value,
|
||||
sort_keys=True,
|
||||
separators=(',', ': '),
|
||||
indent=4)
|
||||
except ValueError:
|
||||
value = task_value
|
||||
out.write('%s\n' % value)
|
||||
out.write('\n')
|
||||
|
@ -607,20 +607,3 @@ def set_deployment_status(clients, plan, status):
|
||||
clients=clients,
|
||||
plan=plan,
|
||||
status=status)
|
||||
|
||||
|
||||
def get_deployment_failures(clients, plan):
|
||||
"""Return a list of deployment failures.
|
||||
|
||||
:param clients: application client object.
|
||||
:type clients: Object
|
||||
|
||||
:param plan: Name of plan to lookup.
|
||||
:param plan: String
|
||||
|
||||
:returns: Dictionary
|
||||
"""
|
||||
|
||||
context = clients.tripleoclient.create_mistral_context()
|
||||
get_failures = deployment.DeploymentFailuresAction(plan=plan)
|
||||
return get_failures.run(context=context)['failures']
|
||||
|
Loading…
x
Reference in New Issue
Block a user