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
This commit is contained in:
Bulat Gaifullin 2016-09-12 13:56:19 +03:00
parent 34d8070375
commit d29dcfcc50
3 changed files with 11 additions and 11 deletions

View File

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

View File

@ -16,27 +16,23 @@ import json
import os
import yaml
from fuelclient.cli import error
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
:param fields: Iterable containing names of fields to be retrieved
from data
:param data: Collection of JSON objects representing some
external entities
:param missing_field_value: the value will be used for all missing fields
:return: list containing the collection of values of the
supplied attributes.
"""
try:
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]))
return [data.get(field, missing_field_value) for field in fields]
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):
test_data = {'a': 1, 'b': 2, 'c': 3}
fields = ('b', 'bad_key')
self.assertRaises(error.BadDataException,
data_utils.get_display_data_single,
fields, test_data)
self.assertEqual(
[2, None],
data_utils.get_display_data_single(fields, test_data)
)
def test_get_display_data_multi(self):
test_data = [{'a': 1, 'b': 2, 'c': 3}, {'b': 8, 'c': 9}]