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/clients/__init__.py b/cfg_checker/clients/__init__.py
index 86d731f..5d3a48d 100644
--- a/cfg_checker/clients/__init__.py
+++ b/cfg_checker/clients/__init__.py
@@ -1,8 +1,11 @@
from cfg_checker.common import logger
from cfg_checker.common.salt_utils import SaltRemote
+from cfg_checker.common.kube_utils import KubeRemote
+
# instance of the salt client
salt = None
+kube = None
def get_salt_remote(config):
@@ -20,6 +23,24 @@
logger.info("Creating salt remote instance")
# create it once
if salt is None:
- salt = SaltRemote()
+ salt = SaltRemote(config)
# return once required
return salt
+
+
+def get_kube_remote(config):
+ """Singleton-like creation of instance
+
+ Arguments:
+ config {base_config} -- an instance to base_config
+ with creds and params
+
+ Returns:
+ KubeRemote -- instance of kube client
+ """
+ global kube
+ logger.info("Creating kube remote client instance")
+ # Create it once
+ if kube is None:
+ kube = KubeRemote(config)
+ return kube