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
This commit is contained in:
abregman 2019-01-24 23:08:09 +02:00
parent 1a2a874d45
commit 3b72d757d6
5 changed files with 75 additions and 0 deletions

View File

@ -7,6 +7,8 @@ name = "pypi"
tobiko = {editable = true,path = "."} tobiko = {editable = true,path = "."}
ansible = "*" ansible = "*"
testscenarios = "*" testscenarios = "*"
crayons = "*"
cryptography = "2.2.2"
[dev-packages] [dev-packages]

View File

@ -7,3 +7,11 @@ Tempest plugin for testing upgrades
* Free software: Apache license * Free software: Apache license
* Source: https://git.openstack.org/cgit/openstack/tobiko * Source: https://git.openstack.org/cgit/openstack/tobiko
* Bugs: https://bugs.launchpad.net/tobiko * Bugs: https://bugs.launchpad.net/tobiko
Usage
-----
Run Neutorn tests::
tox -e neutron

View File

@ -3,3 +3,5 @@
ansible>=2.4.0 # GPLv3 ansible>=2.4.0 # GPLv3
os-faults>=0.1.18 # Apache-2.0 os-faults>=0.1.18 # Apache-2.0
tempest>=17.1.0 # Apache-2.0 tempest>=17.1.0 # Apache-2.0
crayons>=0.1.2
cryptography<=2.2.2

View File

@ -30,6 +30,7 @@ console_scripts =
tobiko-create = tobiko.cmd.create:main tobiko-create = tobiko.cmd.create:main
tobiko-delete = tobiko.cmd.delete:main tobiko-delete = tobiko.cmd.delete:main
tobiko-list = tobiko.cmd.list:main tobiko-list = tobiko.cmd.list:main
tobiko = tobiko.cmd.run:main
[global] [global]
setup-hooks = setup-hooks =

62
tobiko/cmd/run.py Normal file
View File

@ -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())