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/modules/packages/__init__.py b/cfg_checker/modules/packages/__init__.py
index 2d0cc79..e482eec 100644
--- a/cfg_checker/modules/packages/__init__.py
+++ b/cfg_checker/modules/packages/__init__.py
@@ -1,9 +1,12 @@
+from cfg_checker.common.settings import ENV_TYPE_SALT, \
+ ENV_TYPE_KUBE, ENV_TYPE_LINUX
from cfg_checker.helpers import args_utils
from cfg_checker.modules.packages.repos import RepoManager
from . import checker
command_help = "Package versions check (Candidate vs Installed)"
+supported_envs = [ENV_TYPE_SALT, ENV_TYPE_KUBE, ENV_TYPE_LINUX]
def init_parser(_parser):
@@ -98,12 +101,19 @@
return _parser
-def do_report(args):
+def do_report(args, config):
"""Create package versions report, HTML
:args: - parser arguments
:return: - no return value
"""
+ # Check if there is supported env found
+ _env = args_utils.check_supported_env(
+ [ENV_TYPE_SALT, ENV_TYPE_KUBE],
+ args,
+ config
+ )
+ # Start command
_type, _filename = args_utils.get_package_report_type_and_filename(args)
if ' ' in args.exclude_keywords:
@@ -113,12 +123,23 @@
# init connection to salt and collect minion data
_skip, _skip_file = args_utils.get_skip_args(args)
- pChecker = checker.CloudPackageChecker(
- force_tag=args.force_tag,
- exclude_keywords=_kw,
- skip_list=_skip,
- skip_list_file=_skip_file
- )
+ if _env == ENV_TYPE_SALT:
+ pChecker = checker.SaltCloudPackageChecker(
+ config,
+ force_tag=args.force_tag,
+ exclude_keywords=_kw,
+ skip_list=_skip,
+ skip_list_file=_skip_file
+ )
+ elif _env == ENV_TYPE_KUBE:
+ pChecker = checker.KubeCloudPackageChecker(
+ config,
+ force_tag=args.force_tag,
+ exclude_keywords=_kw,
+ skip_list=_skip,
+ skip_list_file=_skip_file
+ )
+
# collect data on installed packages
pChecker.collect_installed_packages()
# diff installed and candidates
@@ -127,12 +148,14 @@
pChecker.create_report(_filename, rtype=_type, full=args.full)
-def do_versions(args):
+def do_versions(args, config):
"""Builds tagged repo structure and parses Packages.gz files
:args: - parser arguments
:return: - no return value
"""
+ # Check if there is supported env found
+ args_utils.check_supported_env(ENV_TYPE_LINUX, args, config)
# Get the list of tags for the url
r = RepoManager()
if args.list_tags:
@@ -159,9 +182,11 @@
r.parse_repos()
-def do_show(args):
+def do_show(args, config):
"""Shows package (or multiple) history across parsed tags
"""
+ # Check if there is supported env found
+ args_utils.check_supported_env(ENV_TYPE_LINUX, args, config)
# Init manager
r = RepoManager()
# show packages
@@ -169,9 +194,11 @@
r.show_package(p)
-def do_show_app(args):
+def do_show_app(args, config):
"""Shows packages for app
"""
+ # Check if there is supported env found
+ args_utils.check_supported_env(ENV_TYPE_LINUX, args, config)
# Init manager
r = RepoManager()
# show packages