Updates to kube env interaction
- local KUBECONFIG var detection
- proper handling of env vars
- fixes for KUBECONFIG loading when env file is given/not given
- main IP extraction
- wording fixes
Related-PROD: PROD-35903
Change-Id: I68f1fd18a72a99502460d3b6158a43cd60d7cf1b
diff --git a/cfg_checker/common/ssh_utils.py b/cfg_checker/common/ssh_utils.py
index fdf4c91..bdfe6b5 100644
--- a/cfg_checker/common/ssh_utils.py
+++ b/cfg_checker/common/ssh_utils.py
@@ -27,6 +27,7 @@
# Build SSH cmd
if keypath:
_ssh_cmd.append("-i " + keypath)
+ _ssh_cmd.append("-o " + "IdentitiesOnly=yes")
if port:
_ssh_cmd.append("-p " + str(port))
if username:
@@ -106,7 +107,8 @@
self._options += ["-p", str(self.port)]
self._extra_options = [
"-o", "UserKnownHostsFile=/dev/null",
- "-o", "StrictHostKeyChecking=no"
+ "-o", "StrictHostKeyChecking=no",
+ "-o", "IdentitiesOnly=yes"
]
self._host_uri = ""
@@ -120,7 +122,7 @@
raise CheckerException(
"Invalid SSH banner type: '{}'".format(type(banner))
)
- logger.debug("...connecting")
+ logger.debug("... connecting")
while True:
try:
line = self.outq.get(block=False)
@@ -136,11 +138,11 @@
"...timed out after {} sec".format(str(self.timeout))
)
return False
- logger.debug("...connected")
+ logger.debug("... connected")
return True
def _wait_for_string(self, string):
- logger.debug("...waiting for '{}'".format(string))
+ logger.debug("... waiting for '{}'".format(string))
while True:
try:
line = self.outq.get(block=False)
@@ -156,10 +158,10 @@
self.timeout -= 1
if not self.timeout:
logger.debug(
- "...timed out after {} sec".format(str(self.timeout))
+ "... timed out after {} sec".format(str(self.timeout))
)
return False
- logger.debug("...found")
+ logger.debug("... found")
return True
def _init_connection(self, cmd):
@@ -203,7 +205,7 @@
def do(self, cmd, timeout=30, sudo=False, strip_cmd=True):
cmd = cmd if isinstance(cmd, bytes) else bytes(cmd.encode('utf-8'))
- logger.debug("...ssh: '{}'".format(cmd))
+ logger.debug("... ssh: '{}'".format(cmd))
if sudo:
_cmd = b"sudo " + cmd
else:
@@ -376,7 +378,7 @@
self._cmd += [self._host_uri]
logger.debug(
- "...port forwarding: '{}'".format(" ".join(self._cmd))
+ "... port forwarding: '{}'".format(" ".join(self._cmd))
)
self._init_connection(self._cmd)
return self