print sample id for query-samples

Provide sample id can make it possible for end user to query particular
sample by its id, this is needed because we don't show everything in
the list.

Change-Id: I06bfc2de1a4e9a24892b2e36b6d2137e1b38cb27
Closes-Bug: #1506745
This commit is contained in:
ZhiQiang Fan
2015-10-15 23:54:43 -07:00
parent 29abd38e3f
commit e68e56684c
2 changed files with 13 additions and 13 deletions

View File

@@ -682,16 +682,16 @@ class ShellQuerySamplesCommandTest(utils.BaseTestCase):
ceilometer_shell.do_query_samples(self.cc, self.args) ceilometer_shell.do_query_samples(self.cc, self.args)
self.assertEqual('''\ self.assertEqual('''\
+--------------------------------------+----------+-------+--------+---------\ +--------------------------------------+--------------------------------------\
-+----------------------------+ +----------+-------+--------+----------+----------------------------+
| Resource ID | Meter | Type | Volume | Unit \ | ID | Resource ID \
| Timestamp | | Meter | Type | Volume | Unit | Timestamp |
+--------------------------------------+----------+-------+--------+---------\ +--------------------------------------+--------------------------------------\
-+----------------------------+ +----------+-------+--------+----------+----------------------------+
| bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 | instance | gauge | 1 | instance\ | b55d1526-9929-11e3-a3f6-02163e5df1e6 | bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 \
| 2014-02-19T05:50:16.673604 | | instance | gauge | 1 | instance | 2014-02-19T05:50:16.673604 |
+--------------------------------------+----------+-------+--------+---------\ +--------------------------------------+--------------------------------------\
-+----------------------------+ +----------+-------+--------+----------+----------------------------+
''', sys.stdout.getvalue()) ''', sys.stdout.getvalue())
@mock.patch('sys.stdout', new=six.StringIO()) @mock.patch('sys.stdout', new=six.StringIO())

View File

@@ -1171,9 +1171,9 @@ def do_query_samples(cc, args):
except exc.HTTPNotFound: except exc.HTTPNotFound:
raise exc.CommandError('Samples not found') raise exc.CommandError('Samples not found')
else: else:
field_labels = ['Resource ID', 'Meter', 'Type', 'Volume', 'Unit', field_labels = ['ID', 'Resource ID', 'Meter', 'Type', 'Volume',
'Timestamp'] 'Unit', 'Timestamp']
fields = ['resource_id', 'meter', 'type', fields = ['id', 'resource_id', 'meter', 'type',
'volume', 'unit', 'timestamp'] 'volume', 'unit', 'timestamp']
utils.print_list(samples, fields, field_labels, utils.print_list(samples, fields, field_labels,
sortby=None) sortby=None)