Fix output for resource type list
The api for resource type list is returning alias-searching, alias-indexing and type instead of name and type now, the output of the osc command need to be updated either. Change-Id: I272173e1efecbd9e7c059e545a95e9bf84e11e7a Closes-bug: #1702234
This commit is contained in:
parent
4dddff44dc
commit
f26e0856b6
@ -16,7 +16,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
|
||||||
|
|
||||||
|
|
||||||
class ListResourceType(command.Lister):
|
class ListResourceType(command.Lister):
|
||||||
@ -29,11 +28,22 @@ class ListResourceType(command.Lister):
|
|||||||
|
|
||||||
search_client = self.app.client_manager.search
|
search_client = self.app.client_manager.search
|
||||||
columns = (
|
columns = (
|
||||||
"Name",
|
"Alias Searching",
|
||||||
|
"Alias Indexing",
|
||||||
"Type"
|
"Type"
|
||||||
)
|
)
|
||||||
data = search_client.resource_types.list()
|
data = search_client.resource_types.list()
|
||||||
return (columns,
|
return (columns,
|
||||||
(utils.get_item_properties(
|
(self.get_item_properties(
|
||||||
s, columns,
|
s, columns,
|
||||||
) for s in data))
|
) for s in data))
|
||||||
|
|
||||||
|
def get_item_properties(self, item, fields):
|
||||||
|
# osc_lib.utils.get_item_properties doesn't work because
|
||||||
|
# the field names are using "-" instead of "_".
|
||||||
|
row = []
|
||||||
|
for field in fields:
|
||||||
|
field_name = field.lower().replace(' ', '-')
|
||||||
|
data = getattr(item, field_name, '')
|
||||||
|
row.append(data)
|
||||||
|
return tuple(row)
|
||||||
|
@ -20,9 +20,9 @@ from searchlightclient.tests.unit.osc import utils
|
|||||||
|
|
||||||
|
|
||||||
ResourceType = {
|
ResourceType = {
|
||||||
"index": "searchlight",
|
"alias-searching": "searchlight-search",
|
||||||
"type": "OS::Nova::Server",
|
"alias-indexing": "searchlight-listener",
|
||||||
"name": "OS::Nova::Server"
|
"type": "OS::Nova::Server"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,8 +42,10 @@ class TestResourceTypeList(TestResourceType):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
self.rtype_client.list.assert_called_with()
|
self.rtype_client.list.assert_called_with()
|
||||||
|
|
||||||
collist = ('Name', 'Type')
|
collist = ('Alias Searching', 'Alias Indexing', 'Type')
|
||||||
self.assertEqual(collist, columns)
|
self.assertEqual(collist, columns)
|
||||||
|
|
||||||
datalist = (('OS::Nova::Server', 'OS::Nova::Server'),)
|
datalist = (('searchlight-search',
|
||||||
|
'searchlight-listener',
|
||||||
|
'OS::Nova::Server'),)
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
Loading…
Reference in New Issue
Block a user