step6829 | a9a664c | 2015-11-30 18:12:25 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | """ |
| 16 | Utility for listing all currently installed Tempest plugins. |
| 17 | |
| 18 | **Usage:** ``tempest list-plugins``. |
| 19 | """ |
| 20 | |
| 21 | from cliff import command |
| 22 | from oslo_log import log as logging |
| 23 | import prettytable |
| 24 | |
| 25 | from tempest.test_discover.plugins import TempestTestPluginManager |
| 26 | |
| 27 | LOG = logging.getLogger(__name__) |
| 28 | |
| 29 | |
| 30 | class TempestListPlugins(command.Command): |
| 31 | def take_action(self, parsed_args): |
| 32 | self._list_plugins() |
step6829 | a9a664c | 2015-11-30 18:12:25 +0000 | [diff] [blame] | 33 | |
| 34 | def get_description(self): |
| 35 | return 'List all tempest plugins' |
| 36 | |
| 37 | def _list_plugins(self): |
| 38 | plugins = TempestTestPluginManager() |
| 39 | |
| 40 | output = prettytable.PrettyTable(["Name", "EntryPoint"]) |
| 41 | for plugin in plugins.ext_plugins.extensions: |
| 42 | output.add_row([ |
| 43 | plugin.name, plugin.entry_point_target]) |
| 44 | |
| 45 | print(output) |