Merge "Show supported openstack releases on the fuel plugins output"
This commit is contained in:
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user