Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test pr #1

Open
wants to merge 34 commits into
base: dev/qe
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f01c7df
Merge pull request #22 from yfried-redhat/dev/qe
Feb 10, 2016
bfb63a8
Moves the excepthood closure to the module level
aopincar Feb 10, 2016
ae51f97
Moves logger import to the haed of local imports
aopincar Feb 10, 2016
5f54f4b
Changes the exception import way in main.py
aopincar Feb 10, 2016
370c59b
Fixes CR comments
aopincar Feb 10, 2016
127cbaf
Merge pull request #23 from aopincar/kcli
Feb 10, 2016
3864723
Splits code to seperate modules & add documention
aopincar Feb 10, 2016
e7c5516
Adds unittest for dict_insert method
aopincar Feb 11, 2016
fee3c14
Fixes CR comments (commit # 38647237)
aopincar Feb 14, 2016
9c7e651
Adds missing new line in enumerated lists lines
aopincar Feb 15, 2016
8466816
Moves 'execute' package to a module in kcli dir
aopincar Feb 16, 2016
51cd9b2
Moves 'dict_lookup' method int 'Lookup' class
aopincar Feb 16, 2016
8e92465
Adds a handler for yaml ConstructorError
aopincar Feb 16, 2016
bfea12b
Merge pull request #24 from aopincar/kcli
Feb 17, 2016
dae2bd9
Merge pull request #25 from aopincar/unittest
Feb 17, 2016
428ee7a
Merge pull request #27 from aopincar/execute
Feb 17, 2016
935de3c
Merge pull request #28 from aopincar/move_dict_lookup_into_Lookup
Feb 17, 2016
42e4092
Merge pull request #30 from aopincar/general_unhandled_yaml_construct…
Feb 17, 2016
d7e7f0c
Organizes all lookup method in Lookup class
aopincar Feb 17, 2016
980ccdb
Adds unitest for unsupported YAML constructor
aopincar Feb 17, 2016
fbdbcb6
Merge pull request #34 from aopincar/organize_all_lookup_funcs
Feb 18, 2016
36896a6
Fixes comments from pull request #38 - pep8 fix
aopincar Feb 18, 2016
a4add1d
Merge pull request #38 from aopincar/unittest
Feb 18, 2016
cad99ce
Removes the un-needed parser in execute.py
aopincar Feb 18, 2016
e0d8990
Adds constructor & unittest for !placeholder tag
aopincar Feb 18, 2016
d5dfd43
Merge pull request #39 from aopincar/remove_parser_from_execute
Feb 18, 2016
6c8a0fa
Fixes comments from pull #40
aopincar Feb 18, 2016
bdabd7b
Fixes typo in placholder's yamles & add data check
aopincar Feb 18, 2016
5327725
Merge pull request #40 from aopincar/placeholder
Feb 21, 2016
e655268
WIP - dereference khaleesi & kcli
aopincar Feb 21, 2016
60b87cc
More deref
Feb 21, 2016
9fed394
Merge pull request #42 from yfried-redhat/aopincar-dereference_khalee…
Feb 21, 2016
590c2c4
A testing file only
Apr 13, 2016
6703209
Delete TestingOnly
Apr 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions tools/kcli/kcli/execute/execute.py → tools/kcli/kcli/execute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import argparse
import sys
from os import path

import ansible.color
@@ -6,14 +8,17 @@
import ansible.utils
from ansible import callbacks

from kcli import conf, exceptions
from kcli.execute import core
from kcli import conf, exceptions, utils

VERBOSITY = 0
HOSTS_FILE = "hosts"
LOCAL_HOSTS = "local_hosts"
PROVISION = "provision"
PLAYBOOKS = [PROVISION, "install", "test", "collect-logs", "cleanup"]

assert "playbooks" == path.basename(conf.PLAYBOOKS_DIR), \
"Bad path to playbooks"


# ansible-playbook
# https://github.com/ansible/ansible/blob/devel/bin/ansible-playbook
@@ -139,11 +144,31 @@ def ansible_wrapper(args):

playbooks = [p for p in PLAYBOOKS if getattr(args, p, False)]
if not playbooks:
core.parser.error("No playbook to execute (%s)" % PLAYBOOKS)
parser.error("No playbook to execute (%s)" % PLAYBOOKS)

for playbook in (p for p in PLAYBOOKS if getattr(args, p, False)):
print "Executing Playbook: %s" % playbook
try:
execute_ansible(playbook, args)
except Exception:
raise exceptions.IRPlaybookFailedException(playbook)


def main():
args = parser.parse_args()
args.func(args)


parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', default=VERBOSITY, action="count",
help="verbose mode (-vvv for more,"
" -vvvv to enable connection debugging)")
parser.add_argument("--settings",
default=conf.KCLI_SETTINGS_YML,
type=lambda file_path: utils.normalize_file(file_path),
help="settings file to use. default: %s"
% conf.KCLI_SETTINGS_YML)
subparsers = parser.add_subparsers(metavar="COMMAND")

if __name__ == '__main__':
sys.exit(main())
2 changes: 0 additions & 2 deletions tools/kcli/kcli/execute/__init__.py

This file was deleted.

38 changes: 0 additions & 38 deletions tools/kcli/kcli/execute/core.py

This file was deleted.

2 changes: 1 addition & 1 deletion tools/kcli/kcli/main.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

from kcli import conf
from kcli import options as kcli_options
from kcli.execute.execute import PLAYBOOKS
from kcli.execute import PLAYBOOKS
from kcli import parse
from kcli import utils

15 changes: 8 additions & 7 deletions tools/kcli/kcli/parse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from argparse import ArgumentParser, RawTextHelpFormatter

from execute.core import *
from execute.execute import *
from kcli import conf, execute, utils


def create_parser(options_trees):
@@ -17,13 +16,14 @@ def create_parser(options_trees):

execute_parser = sub_parsers.add_parser('execute')
execute_parser.add_argument('-i', '--inventory', default=None,
type=lambda x: core.file_exists(
execute_parser, x),
type=lambda file_path: utils.normalize_file(
file_path),
help="Inventory file to use. "
"Default: {lcl}. "
"NOTE: to reuse old environment use {"
"host}".
format(lcl=LOCAL_HOSTS, host=HOSTS_FILE))
format(lcl=execute.LOCAL_HOSTS,
host=execute.HOSTS_FILE))
execute_parser.add_argument("-v", "--verbose", help="verbosity",
action='count', default=0)
execute_parser.add_argument("--provision", action="store_true",
@@ -37,10 +37,11 @@ def create_parser(options_trees):
execute_parser.add_argument("--cleanup", action="store_true",
help="cleanup nodes")
execute_parser.add_argument("--settings",
type=lambda x: file_exists(parser, x),
type=lambda file_path: utils.normalize_file(
file_path),
help="settings file to use. default: %s"
% conf.KCLI_SETTINGS_YML)
execute_parser.set_defaults(func=ansible_wrapper)
execute_parser.set_defaults(func=execute.ansible_wrapper)
execute_parser.set_defaults(which='execute')

for options_tree in options_trees: