Show supported openstack releases on the `fuel plugins` output
While working with .rpm plugin format it is complicated to get to know which exactly openstack version this plugin supports. This fix allows to add this information to the output of the 'fuel plugins' cli command Change-Id: I35d8e9dacf79bd3ef9b7e5ba2ed536c7fbe40686 Closes-Bug: 1499742
This commit is contained in:
parent
f657e8e034
commit
fdb1a70ac7
|
@ -12,6 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
import six
|
||||
|
||||
import fuelclient.cli.arguments as Args
|
||||
|
||||
from fuelclient.cli.actions.base import Action
|
||||
|
@ -31,6 +34,7 @@ class PluginAction(Action):
|
|||
"name",
|
||||
"version",
|
||||
"package_version",
|
||||
"releases"
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
|
@ -74,6 +78,14 @@ class PluginAction(Action):
|
|||
fuel plugins --list
|
||||
"""
|
||||
plugins = Plugins.get_all_data()
|
||||
# Replace original nested 'release' dictionary (from plugins meta
|
||||
# dictionary) to flat one with necessary release info (os, version)
|
||||
for plugin in plugins:
|
||||
releases = collections.defaultdict(list)
|
||||
for key in plugin['releases']:
|
||||
releases[key['os']].append(key['version'])
|
||||
plugin['releases'] = ', '.join('{} ({})'.format(k, ', '.join(v))
|
||||
for k, v in six.iteritems(releases))
|
||||
self.serializer.print_to_output(
|
||||
plugins,
|
||||
format_table(plugins, acceptable_keys=self.acceptable_keys))
|
||||
|
|
|
@ -24,14 +24,6 @@ from fuelclient.objects.plugins import Plugins
|
|||
from fuelclient.tests.unit.v1 import base
|
||||
|
||||
|
||||
plugin_data = {
|
||||
'id': 1,
|
||||
'name': 'plugin_name',
|
||||
'version': '1.0.0',
|
||||
'package_version': '1.0.0'
|
||||
}
|
||||
|
||||
|
||||
class TestPluginsActions(base.UnitTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -58,7 +50,20 @@ class TestPluginsActions(base.UnitTestCase):
|
|||
@patch.object(Serializer, 'print_to_output')
|
||||
@patch.object(Plugins, 'get_all_data')
|
||||
def test_list_default(self, get_mock, print_mock):
|
||||
plugins = [plugin_data, plugin_data]
|
||||
plugins = [
|
||||
{'id': 1,
|
||||
'name': 'plugin_name1',
|
||||
'version': '1.0.0',
|
||||
'package_version': '1.0.0',
|
||||
'releases': [{'os': 'ubuntu', 'version': 'liberty-8.0'},
|
||||
{'os': 'centos', 'version': 'liberty-8.0'}]},
|
||||
{'id': 2,
|
||||
'name': 'plugin_name2',
|
||||
'version': '1.0.0',
|
||||
'package_version': '1.0.0',
|
||||
'releases': [{'os': 'ubuntu', 'version': 'liberty-8.0'},
|
||||
{'os': 'ubuntu', 'version': 'mitaka-9.0'}]}
|
||||
]
|
||||
get_mock.return_value = plugins
|
||||
|
||||
self.exec_plugins([])
|
||||
|
@ -69,7 +74,20 @@ class TestPluginsActions(base.UnitTestCase):
|
|||
@patch.object(Serializer, 'print_to_output')
|
||||
@patch.object(Plugins, 'get_all_data')
|
||||
def test_list(self, get_mock, print_mock):
|
||||
plugins = [plugin_data, plugin_data]
|
||||
plugins = [
|
||||
{'id': 1,
|
||||
'name': 'plugin_name1',
|
||||
'version': '1.0.0',
|
||||
'package_version': '1.0.0',
|
||||
'releases': [{'os': 'ubuntu', 'version': 'liberty-8.0'},
|
||||
{'os': 'centos', 'version': 'liberty-8.0'}]},
|
||||
{'id': 2,
|
||||
'name': 'plugin_name2',
|
||||
'version': '1.0.0',
|
||||
'package_version': '1.0.0',
|
||||
'releases': [{'os': 'ubuntu', 'version': 'liberty-8.0'},
|
||||
{'os': 'ubuntu', 'version': 'mitaka-9.0'}]}
|
||||
]
|
||||
get_mock.return_value = plugins
|
||||
|
||||
self.exec_plugins(['--list'])
|
||||
|
|
Loading…
Reference in New Issue