summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/discover/fetchers/cli/cli_access.py2
-rw-r--r--app/test/fetch/cli_fetch/test_cli_access.py12
-rw-r--r--app/test/fetch/cli_fetch/test_data/cli_access.py2
-rw-r--r--app/test/fetch/test_fetch.py6
4 files changed, 11 insertions, 11 deletions
diff --git a/app/discover/fetchers/cli/cli_access.py b/app/discover/fetchers/cli/cli_access.py
index 24f2975..f745de8 100644
--- a/app/discover/fetchers/cli/cli_access.py
+++ b/app/discover/fetchers/cli/cli_access.py
@@ -18,7 +18,7 @@ from utils.ssh_conn import SshConn
class CliAccess(BinaryConverter, Fetcher):
connections = {}
- ssh_cmd = "ssh -o StrictHostKeyChecking=no "
+ ssh_cmd = "ssh -q -o StrictHostKeyChecking=no "
call_count_per_con = {}
max_call_count_per_con = 100
cache_lifetime = 60 # no. of seconds to cache results
diff --git a/app/test/fetch/cli_fetch/test_cli_access.py b/app/test/fetch/cli_fetch/test_cli_access.py
index be80619..d32e1ed 100644
--- a/app/test/fetch/cli_fetch/test_cli_access.py
+++ b/app/test/fetch/cli_fetch/test_cli_access.py
@@ -23,12 +23,10 @@ class TestCliAccess(TestFetch):
self.configure_environment()
self.cli_access = CliAccess()
- @patch("utils.ssh_conn.SshConn.exec")
def check_run_result(self, is_gateway_host,
enable_cache,
cached_command_result, exec_result,
- expected_result, err_msg,
- ssh_con_exec):
+ expected_result, err_msg):
# mock cached commands
if not is_gateway_host:
self.cli_access.cached_commands = {
@@ -38,17 +36,15 @@ class TestCliAccess(TestFetch):
self.cli_access.cached_commands = {
GATEWAY_CACHED_COMMAND: cached_command_result
}
- original_is_gateway_host = SshConn.is_gateway_host
- SshConn.is_gateway_host = MagicMock(return_value=is_gateway_host)
- ssh_con_exec.return_value = exec_result
+
+ self.ssh_conn.exec.return_value = exec_result
+ self.ssh_conn.is_gateway_host.return_value = is_gateway_host
result = self.cli_access.run(COMMAND, COMPUTE_HOST_ID,
on_gateway=False, enable_cache=enable_cache)
self.assertEqual(result, expected_result, err_msg)
# reset the cached commands after testing
self.cli_access.cached_commands = {}
- # reset method
- SshConn.is_gateway_host = original_is_gateway_host
def test_run(self):
curr_time = time.time()
diff --git a/app/test/fetch/cli_fetch/test_data/cli_access.py b/app/test/fetch/cli_fetch/test_data/cli_access.py
index b151dc6..03309d1 100644
--- a/app/test/fetch/cli_fetch/test_data/cli_access.py
+++ b/app/test/fetch/cli_fetch/test_data/cli_access.py
@@ -9,7 +9,7 @@
###############################################################################
COMPUTE_HOST_ID = "node-5.cisco.com"
COMMAND = "virsh list"
-NON_GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "ssh -o StrictHostKeyChecking=no " + \
+NON_GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "ssh -q -o StrictHostKeyChecking=no " + \
COMPUTE_HOST_ID + " sudo " + COMMAND
GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "sudo " + COMMAND
CACHED_COMMAND_RESULT = " Id Name State\n---\n 2 instance-00000003 running"
diff --git a/app/test/fetch/test_fetch.py b/app/test/fetch/test_fetch.py
index e446ee5..55d7d4c 100644
--- a/app/test/fetch/test_fetch.py
+++ b/app/test/fetch/test_fetch.py
@@ -40,6 +40,9 @@ class TestFetch(unittest.TestCase):
self.response.status_code = self.requests.codes.ok
self.requests.get.return_value = self.response
self.requests.post.return_value = self.response
+
+ self.ssh_patcher = patch("discover.fetchers.cli.cli_access.SshConn")
+ self.ssh_conn = self.ssh_patcher.start().return_value
def configure_environment(self):
self.env = ENV_CONFIG
@@ -74,4 +77,5 @@ class TestFetch(unittest.TestCase):
SshConnection.connect = self._ssh_connect
SshConnection.check_definitions = self._ssh_conn_check_defs
SshConn.check_definitions = self._ssh_check_defs
- self.req_patcher.stop() \ No newline at end of file
+ self.req_patcher.stop()
+ self.ssh_patcher.stop() \ No newline at end of file