From 3b72d757d6a743a4f4de97860a5047900cfe26a1 Mon Sep 17 00:00:00 2001 From: abregman Date: Thu, 24 Jan 2019 23:08:09 +0200 Subject: [PATCH] Add Tobiko run command Add basic structure file for supporting Tobiko run command. The command will be used for generating configuration and run the tests. Change-Id: I046b3a85e2ad3d73f983d2be0c804ee863d56d9c --- Pipfile | 2 ++ README.rst | 8 ++++++ extra-requirements.txt | 2 ++ setup.cfg | 1 + tobiko/cmd/run.py | 62 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 tobiko/cmd/run.py diff --git a/Pipfile b/Pipfile index c014ddbad..18b826c5b 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,8 @@ name = "pypi" tobiko = {editable = true,path = "."} ansible = "*" testscenarios = "*" +crayons = "*" +cryptography = "2.2.2" [dev-packages] diff --git a/README.rst b/README.rst index 8033611f4..905fcdb94 100644 --- a/README.rst +++ b/README.rst @@ -7,3 +7,11 @@ Tempest plugin for testing upgrades * Free software: Apache license * Source: https://git.openstack.org/cgit/openstack/tobiko * Bugs: https://bugs.launchpad.net/tobiko + + +Usage +----- + +Run Neutorn tests:: + + tox -e neutron diff --git a/extra-requirements.txt b/extra-requirements.txt index 698000723..c5a4ca894 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -3,3 +3,5 @@ ansible>=2.4.0 # GPLv3 os-faults>=0.1.18 # Apache-2.0 tempest>=17.1.0 # Apache-2.0 +crayons>=0.1.2 +cryptography<=2.2.2 diff --git a/setup.cfg b/setup.cfg index 6394e74a7..9fa296067 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,7 @@ console_scripts = tobiko-create = tobiko.cmd.create:main tobiko-delete = tobiko.cmd.delete:main tobiko-list = tobiko.cmd.list:main + tobiko = tobiko.cmd.run:main [global] setup-hooks = diff --git a/tobiko/cmd/run.py b/tobiko/cmd/run.py new file mode 100644 index 000000000..70be38d59 --- /dev/null +++ b/tobiko/cmd/run.py @@ -0,0 +1,62 @@ +# Copyright 2018 Red Hat +# +# 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. +from __future__ import absolute_import + +import argparse +import sys + +import crayons +import paramiko + +from oslo_log import log + +LOG = log.getLogger(__name__) + + +class Tobiko(): + + def __init__(self): + self.parser = self.get_parser() + self.args = (self.parser).parse_args() + self.ssh = paramiko.SSHClient() + self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + + def get_parser(self): + parser = argparse.ArgumentParser(add_help=True) + parser.add_argument( + '--host', + help="The name of the host where your cloud is deployed.\n") + parser.add_argument( + '--key', '-k', + help="They SSH key to use to connect the host.") + return parser + + def verify_connection(self): + """Verifies it's able to connect the host provided by the user.""" + try: + self.ssh.connect(self.args.host) + except paramiko.ssh_exception.AuthenticationException: + LOG.error("Unable to connect {}".format( + crayons.red(self.args.host))) + + +def main(): + """Run CLI main entry.""" + tobiko = Tobiko() + tobiko.verify_connection() + # run.discover_environment() + + +if __name__ == '__main__': + sys.exit(main())