Multi env support and Kube client integration
Kube friendly Beta
Package versions supports Kube env
Added:
- Env type detection
- New option: --use-env, for selecting env
when function supports multiple detected envs
- Updated config loading
- Each module and command type has supported env check
and stops execution if it is on unsupported env
- Functions can support multiple envs
- Kubernetes dependency
- Kubenernetes API detection: local and remote
- Package checking class hierachy for using Salt or Kube
- Remote pod execution routine
- Flexible SSH/SSH Forwarder classes: with, ssh,do(), etc
- Multithreaded SSH script execution
- Number of workers parameter, default 5
Fixed:
- Config dependency
- Command loading with supported envs list
- Unittests structure and execution flow updated
- Unittests fixes
- Fixed debug mode handling
- Unified command type/support routine
- Nested attrs getter/setter
Change-Id: I3ade693ac21536e2b5dcee4b24d511749dc72759
Related-PROD: PROD-35811
diff --git a/cfg_checker/cfg_check.py b/cfg_checker/cfg_check.py
index 11190b4..403483e 100644
--- a/cfg_checker/cfg_check.py
+++ b/cfg_checker/cfg_check.py
@@ -2,9 +2,11 @@
import sys
from logging import DEBUG, INFO
+from cfg_checker.cli.arguments import add_global_arguments
from cfg_checker.cli.command import execute_command, helps, parsers, \
parsers_inits
-from cfg_checker.common import config, logger, logger_cli
+from cfg_checker.common.settings import CheckerConfiguration
+from cfg_checker.common import logger, logger_cli
from cfg_checker.helpers.args_utils import MyParser
pkg_dir = os.path.dirname(__file__)
@@ -20,33 +22,7 @@
"""
# Main entrypoint
parser = MyParser(prog="# Mirantis Cloud configuration checker")
-
- parser.add_argument(
- "-d",
- "--debug",
- action="store_true", default=False,
- help="Set CLI logging level to DEBUG"
- )
- parser.add_argument(
- '-s',
- '--sudo',
- action='store_true', default=True,
- help="Use sudo for getting salt creds"
- )
-
- parser.add_argument(
- '--skip-nodes',
- metavar='skip_string', default=None,
- help="String with nodes to skip. Only trailing '*' supported!"
- " Example: 'cmp*,ctl01'"
- )
-
- parser.add_argument(
- '--skip-nodes-file',
- metavar='skip_nodes_file', default=None,
- help="Filename with nodes to skip. Note: use fqdn node names."
- )
-
+ add_global_arguments(parser)
subparsers = parser.add_subparsers(dest='command')
# create parsers
@@ -76,17 +52,18 @@
parser.print_help()
logger_cli.info("\n# Please, type a command listed above")
sys.exit(1)
- # Pass externally configured values
- config.ssh_uses_sudo = args.sudo
- # Handle options
+ # Handle debug option before config init
if args.debug:
logger_cli.setLevel(DEBUG)
else:
logger_cli.setLevel(INFO)
+ # Init the config and pass externally configured values
+ config = CheckerConfiguration(args)
+
# Execute the command
- result = execute_command(args, args.command)
+ result = execute_command(args, args.command, config)
logger.debug(result)
sys.exit(result)