Add cliff based common cli entrypoint

This commit adds the basic framework to tempest for a unified modular
CLI endpoint using cliff. As of right now this entry-point doesn't
really do anything but exist. It will be expanded in the future first
all the existing commands will be refactored to be used through this.
Secondly a new interface and workflow for running tempest will be
created on top of this.

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>

Change-Id: I1ff8d22c120dbc81d812f1f107db7c2d9b15a505
Implements: blueprint tempest-cli-improvements
This commit is contained in:
David Paterson 2015-04-02 01:27:34 -04:00 committed by Matthew Treinish
parent dfd1315e59
commit 4af1d02746
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
3 changed files with 54 additions and 0 deletions

View File

@ -2,6 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr<2.0,>=0.11
cliff>=1.13.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
jsonschema!=2.5.0,<3.0.0,>=2.0.0

View File

@ -25,6 +25,7 @@ console_scripts =
run-tempest-stress = tempest.cmd.run_stress:main
tempest-cleanup = tempest.cmd.cleanup:main
tempest-account-generator = tempest.cmd.account_generator:main
tempest = tempest.cmd.main:main
oslo.config.opts =
tempest.config = tempest.config:list_opts

52
tempest/cmd/main.py Normal file
View File

@ -0,0 +1,52 @@
# Copyright 2015 Dell Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
import sys
from cliff import app
from cliff import commandmanager
TEMPEST_CLI_VERSION = '0.1'
class Main(app.App):
log = logging.getLogger(__name__)
def __init__(self):
super(Main, self).__init__(
description='Tempest cli application',
version=TEMPEST_CLI_VERSION,
command_manager=commandmanager.CommandManager('tempest.cm'),
)
def initialize_app(self, argv):
self.log.debug('tempest initialize_app')
def prepare_to_run_command(self, cmd):
self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
def clean_up(self, cmd, result, err):
self.log.debug('tempest clean_up %s', cmd.__class__.__name__)
if err:
self.log.debug('tempest got an error: %s', err)
def main(argv=sys.argv[1:]):
the_app = Main()
return the_app.run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))