Added graph_type and dry_run flag for tasks output

Also changed behaviour of method get_display_data_single,
it uses special value for missing fields instead of raising
exception.

Change-Id: I2b92b66f47e4e5c866790f486571f69ff5ae14dd
Closes-Bug: 1622563
(cherry picked from commit d29dcfcc50)
This commit is contained in:
Bulat Gaifullin 2016-09-12 13:56:19 +03:00 committed by Alexey Shtokolov
parent dfd85c96da
commit ef4efad679
3 changed files with 11 additions and 11 deletions

View File

@ -126,8 +126,10 @@ class TaskList(TaskMixIn, base.BaseListCommand):
columns = ('id', columns = ('id',
'status', 'status',
'name', 'name',
'graph_type',
'cluster', 'cluster',
'result', 'result',
'dry_run',
'progress') 'progress')
@ -137,8 +139,10 @@ class TaskShow(TaskMixIn, base.BaseShowCommand):
'uuid', 'uuid',
'status', 'status',
'name', 'name',
'graph_type',
'cluster', 'cluster',
'result', 'result',
'dry_run',
'progress', 'progress',
'message') 'message')

View File

@ -16,27 +16,23 @@ import json
import os import os
import yaml import yaml
from fuelclient.cli import error
from fuelclient import utils from fuelclient import utils
def get_display_data_single(fields, data): def get_display_data_single(fields, data, missing_field_value=None):
"""Performs slicing of data by set of given fields """Performs slicing of data by set of given fields
:param fields: Iterable containing names of fields to be retrieved :param fields: Iterable containing names of fields to be retrieved
from data from data
:param data: Collection of JSON objects representing some :param data: Collection of JSON objects representing some
external entities external entities
:param missing_field_value: the value will be used for all missing fields
:return: list containing the collection of values of the :return: list containing the collection of values of the
supplied attributes. supplied attributes.
""" """
try: return [data.get(field, missing_field_value) for field in fields]
return [data[field] for field in fields]
except KeyError as e:
raise error.BadDataException('{} is not found in the supplied '
'data.'.format(e.args[0]))
def get_display_data_multi(fields, data): def get_display_data_multi(fields, data):

View File

@ -203,10 +203,10 @@ class TestUtils(base.UnitTestCase):
def test_get_display_data_bad_key(self): def test_get_display_data_bad_key(self):
test_data = {'a': 1, 'b': 2, 'c': 3} test_data = {'a': 1, 'b': 2, 'c': 3}
fields = ('b', 'bad_key') fields = ('b', 'bad_key')
self.assertEqual(
self.assertRaises(error.BadDataException, [2, None],
data_utils.get_display_data_single, data_utils.get_display_data_single(fields, test_data)
fields, test_data) )
def test_get_display_data_multi(self): def test_get_display_data_multi(self):
test_data = [{'a': 1, 'b': 2, 'c': 3}, {'b': 8, 'c': 9}] test_data = [{'a': 1, 'b': 2, 'c': 3}, {'b': 8, 'c': 9}]