David Paterson | 4af1d02 | 2015-04-02 01:27:34 -0400 | [diff] [blame] | 1 | # Copyright 2015 Dell Inc. |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 | # not use this file except in compliance with the License. You may obtain |
| 4 | # a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 | # License for the specific language governing permissions and limitations |
| 12 | # under the License. |
| 13 | |
David Paterson | 4af1d02 | 2015-04-02 01:27:34 -0400 | [diff] [blame] | 14 | import sys |
| 15 | |
| 16 | from cliff import app |
| 17 | from cliff import commandmanager |
Cady_Chen | 72014bc | 2016-11-16 09:43:49 +0800 | [diff] [blame] | 18 | from oslo_log import log as logging |
Matthew Treinish | 0ef3a73 | 2015-10-29 02:44:34 -0400 | [diff] [blame] | 19 | from pbr import version |
David Paterson | 4af1d02 | 2015-04-02 01:27:34 -0400 | [diff] [blame] | 20 | |
| 21 | |
| 22 | class Main(app.App): |
| 23 | |
| 24 | log = logging.getLogger(__name__) |
| 25 | |
| 26 | def __init__(self): |
| 27 | super(Main, self).__init__( |
| 28 | description='Tempest cli application', |
Masayuki Igawa | 70e0a89 | 2016-06-07 15:45:48 +0900 | [diff] [blame] | 29 | version=version.VersionInfo('tempest').version_string_with_vcs(), |
David Paterson | 4af1d02 | 2015-04-02 01:27:34 -0400 | [diff] [blame] | 30 | command_manager=commandmanager.CommandManager('tempest.cm'), |
Masayuki Igawa | 2f1f497 | 2016-01-13 12:26:59 +0900 | [diff] [blame] | 31 | deferred_help=True, |
David Paterson | 4af1d02 | 2015-04-02 01:27:34 -0400 | [diff] [blame] | 32 | ) |
| 33 | |
| 34 | def initialize_app(self, argv): |
| 35 | self.log.debug('tempest initialize_app') |
| 36 | |
| 37 | def prepare_to_run_command(self, cmd): |
| 38 | self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__) |
| 39 | |
| 40 | def clean_up(self, cmd, result, err): |
| 41 | self.log.debug('tempest clean_up %s', cmd.__class__.__name__) |
| 42 | if err: |
| 43 | self.log.debug('tempest got an error: %s', err) |
| 44 | |
| 45 | |
| 46 | def main(argv=sys.argv[1:]): |
| 47 | the_app = Main() |
| 48 | return the_app.run(argv) |
| 49 | |
| 50 | |
| 51 | if __name__ == '__main__': |
| 52 | sys.exit(main(sys.argv[1:])) |