Add logging for salt-api requests/responses

Change-Id: I0dd73c60cc4364ce5962ddb2520390ad3ee32f06
Closes-Task:#PROD-29994(PROD:29994)
diff --git a/test_set/cvp-sanity/tests/test_cinder_services.py b/test_set/cvp-sanity/tests/test_cinder_services.py
index 4a6c45e..a612bca 100644
--- a/test_set/cvp-sanity/tests/test_cinder_services.py
+++ b/test_set/cvp-sanity/tests/test_cinder_services.py
@@ -1,4 +1,5 @@
 import pytest
+import logging
 
 
 @pytest.mark.sl_dup
@@ -28,8 +29,6 @@
     cinder_volume = local_salt_client.cmd_any(
         tgt='keystone:server',
         param='. /root/keystonercv3; cinder service-list | grep "volume" |grep -c -v -e "lvm"')
-    print(backends_cinder)
-    print(cinder_volume)
     backends_num = len(backends_cinder.keys())
     assert cinder_volume == str(backends_num), \
         'Number of cinder-volume services ({0}) does not match ' \
diff --git a/test_set/cvp-sanity/tests/test_drivetrain.py b/test_set/cvp-sanity/tests/test_drivetrain.py
index 05ea831..1b71ad0 100644
--- a/test_set/cvp-sanity/tests/test_drivetrain.py
+++ b/test_set/cvp-sanity/tests/test_drivetrain.py
@@ -10,7 +10,7 @@
 import git
 import ldap
 import ldap.modlist as modlist
-
+import logging
 
 def join_to_gerrit(local_salt_client, gerrit_user, gerrit_password):
     gerrit_port = local_salt_client.pillar_get(
@@ -73,7 +73,7 @@
         #Create test project and add description
         server.put("/projects/"+test_proj_name)
         server.put("/projects/"+test_proj_name+"/description",json={"description":"Test DriveTrain project","commit_message": "Update the project description"})
-    except HTTPError, e:
+    except HTTPError as e:
         gerrit_error = e
     try:
         #Create test folder and init git
@@ -98,7 +98,7 @@
         last_change = changes[0].get('change_id')
         server.post("/changes/{0}/revisions/1/review".format(last_change),json={"message": "All is good","labels":{"Code-Review":"+2"}})
         server.post("/changes/{0}/submit".format(last_change))
-    except HTTPError, e:
+    except HTTPError as e:
         gerrit_error = e
     finally:
         #Delete test project
@@ -174,7 +174,7 @@
         #Check search test user in LDAP
         searchScope = ldap.SCOPE_SUBTREE
         ldap_result = ldap_server.search_s(ldap_dc, searchScope, searchFilter)
-    except ldap.LDAPError, e:
+    except ldap.LDAPError as e:
         ldap_error = e
     try:
         #Check connection between Jenkins and LDAP
@@ -188,9 +188,9 @@
         gerrit_add_user = gerrit_server.put(_link)
         gerrit_server = join_to_gerrit(local_salt_client,test_user_name,'aSecretPassw')
         gerrit_result = gerrit_server.get("/changes/?q=owner:self%20status:open")
-    except HTTPError, e:
+    except HTTPError as e:
         gerrit_error = e
-    except jenkins.JenkinsException, e:
+    except jenkins.JenkinsException as e:
         jenkins_error = e
     finally:
         ldap_server.modify_s(admin_gr_dn,[(ldap.MOD_DELETE, 'memberUid', [test_user_name],)],)
@@ -233,7 +233,7 @@
         if len(wrong_items) == 0:
             break
         else:
-            print('''Some DriveTrain services doesn't have expected number of replicas:
+            logging.error('''Some DriveTrain services doesn't have expected number of replicas:
                   {}\n'''.format(json.dumps(wrong_items, indent=4)))
             time.sleep(5)
     assert len(wrong_items) == 0
@@ -312,7 +312,7 @@
                 param='jenkins:client:job:{}:scm:branch'.format(job_name))
 
         if not BranchSpec:
-            print("No BranchSpec has found for {} job".format(job_name))
+            logging.debug("No BranchSpec has found for {} job".format(job_name))
             continue
 
         actual_version = BranchSpec[0].getElementsByTagName('name')[0].childNodes[0].data
@@ -400,8 +400,6 @@
                 expected=expected_replica,
                 actual=actual_replica
             )
-
-    print report_with_errors
     assert report_with_errors == "", \
         "\n{sep}{kubectl_output}{sep} \n\n {report} ".format(
             sep="\n" + "-"*20 + "\n",
@@ -437,8 +435,6 @@
                 expected=expected_replica,
                 actual=actual_replica
             )
-
-    print report_with_errors
     assert report_with_errors != "", \
         "\n{sep}{kubectl_output}{sep} \n\n {report} ".format(
             sep="\n" + "-" * 20 + "\n",
diff --git a/test_set/cvp-sanity/tests/test_duplicate_ips.py b/test_set/cvp-sanity/tests/test_duplicate_ips.py
index bbd532e..392838f 100644
--- a/test_set/cvp-sanity/tests/test_duplicate_ips.py
+++ b/test_set/cvp-sanity/tests/test_duplicate_ips.py
@@ -2,6 +2,7 @@
 from pprint import pformat
 import os
 import pytest
+import logging
 import utils
 
 
@@ -32,7 +33,7 @@
     for node in nodes:
         if isinstance(nodes[node], bool):
             # TODO: do not skip node
-            print ("{} node is skipped".format(node))
+            logging.info("{} node is skipped".format(node))
             continue
         for iface in nodes[node]['ip4_interfaces']:
             # Omit 'ip-less' ifaces
diff --git a/test_set/cvp-sanity/tests/test_k8s.py b/test_set/cvp-sanity/tests/test_k8s.py
index f04066e..d3455c3 100644
--- a/test_set/cvp-sanity/tests/test_k8s.py
+++ b/test_set/cvp-sanity/tests/test_k8s.py
@@ -1,6 +1,7 @@
 import pytest
 import json
 import os
+import logging
 
 
 def test_k8s_get_cs_status(local_salt_client):
@@ -138,9 +139,9 @@
     hostname = 'https://docker-dev-virtual.docker.mirantis.net/artifactory/webapp/'
     response = os.system('curl -s --insecure {} > /dev/null'.format(hostname))
     if response == 0:
-        print '{} is AVAILABLE'.format(hostname)
+        logging.info('{} is AVAILABLE'.format(hostname))
     else:
-        print '{} IS NOT AVAILABLE'.format(hostname)
+        logging.error('{} IS NOT AVAILABLE'.format(hostname))
 
 
 def test_k8s_dashboard_available(local_salt_client):
diff --git a/test_set/cvp-sanity/tests/test_mtu.py b/test_set/cvp-sanity/tests/test_mtu.py
index b215c1d..01d6642 100644
--- a/test_set/cvp-sanity/tests/test_mtu.py
+++ b/test_set/cvp-sanity/tests/test_mtu.py
@@ -2,6 +2,7 @@
 import json
 import utils
 import os
+import logging
 
 
 @pytest.mark.full
@@ -23,7 +24,7 @@
 
     for node, ifaces_info in network_info.iteritems():
         if isinstance(ifaces_info, bool):
-            print ("{} node is skipped".format(node))
+            logging.info("{} node is skipped".format(node))
             continue
         if node in kvm_nodes:
             kvm_info = local_salt_client.cmd(tgt=node,
diff --git a/test_set/cvp-sanity/tests/test_ntp_sync.py b/test_set/cvp-sanity/tests/test_ntp_sync.py
index bf51290..6751f1a 100644
--- a/test_set/cvp-sanity/tests/test_ntp_sync.py
+++ b/test_set/cvp-sanity/tests/test_ntp_sync.py
@@ -1,10 +1,11 @@
 import json
 import utils
 import pytest
+import logging
 
 
 @pytest.mark.smoke
-#move to sl?
+# move to sl?
 def test_ntp_sync(local_salt_client):
     """Test checks that system time is the same across all nodes"""
 
@@ -40,7 +41,7 @@
         sys_peer_declared = False
         if not state[node]:
             # TODO: do not skip
-            print ("Node {} is skipped".format(node))
+            logging.warning("Node {} is skipped".format(node))
             continue
         ntpq_output = state[node].split('\n')
         # if output has no 'remote' in the head of ntpq output
diff --git a/test_set/cvp-sanity/tests/test_packet_checker.py b/test_set/cvp-sanity/tests/test_packet_checker.py
index 786fba9..382576a 100644
--- a/test_set/cvp-sanity/tests/test_packet_checker.py
+++ b/test_set/cvp-sanity/tests/test_packet_checker.py
@@ -1,6 +1,7 @@
 import pytest
 import json
 import utils
+import logging
 
 
 @pytest.mark.full
@@ -23,7 +24,7 @@
     for node in total_nodes:
         if not packages_versions[node]:
             # TODO: do not skip node
-            print "Node {} is skipped".format (node)
+            logging.warning("Node {} is skipped".format(node))
             continue
         nodes.append(node)
         packages_names.update(packages_versions[node].keys())
diff --git a/test_set/cvp-sanity/tests/test_repo_list.py b/test_set/cvp-sanity/tests/test_repo_list.py
index 1ba255c..a864b2c 100644
--- a/test_set/cvp-sanity/tests/test_repo_list.py
+++ b/test_set/cvp-sanity/tests/test_repo_list.py
@@ -1,4 +1,5 @@
 import pytest
+import logging
 
 
 @pytest.mark.full
@@ -15,7 +16,7 @@
         repos = info_salt[node]
         if not info_salt[node]:
             # TODO: do not skip node
-            print "Node {} is skipped".format (node)
+            logging.warning("Node {} is skipped".format(node))
             continue
         for repo in repos.keys():
             repository = repos[repo]
@@ -60,4 +61,4 @@
         "Several problems found: {0}".format(
             json.dumps(diff, indent=4))
     if fail_counter == 0 and len(diff) > 0:
-        print "\nWarning: nodes contain more repos than reclass"
+        logging.warning("\nWarning: nodes contain more repos than reclass")
diff --git a/test_set/cvp-sanity/tests/test_salt_master.py b/test_set/cvp-sanity/tests/test_salt_master.py
index f0d6499..f2d7f1a 100644
--- a/test_set/cvp-sanity/tests/test_salt_master.py
+++ b/test_set/cvp-sanity/tests/test_salt_master.py
@@ -1,5 +1,6 @@
 import json
 import pytest
+import logging
 
 
 @pytest.mark.full
@@ -36,7 +37,7 @@
         expr_form='pillar', check_status=True).values()[0]
     reclass_warnings = reclass[reclass.keys()[0]].split('{\n  "base":')[0]
     if reclass_warnings:
-        print "\nReclass-salt output has warnings"
+        logging.warning("\nReclass-salt output has warnings: {}".format(reclass_warnings))
     reclass_nodes = reclass[reclass.keys()[0]].split('{\n  "base":')[1]
     assert reclass_nodes != '', 'No nodes were found in' \
                                 ' reclass-salt --top output'
diff --git a/test_set/cvp-sanity/tests/test_services.py b/test_set/cvp-sanity/tests/test_services.py
index 224c207..fac31e5 100644
--- a/test_set/cvp-sanity/tests/test_services.py
+++ b/test_set/cvp-sanity/tests/test_services.py
@@ -1,6 +1,7 @@
 import pytest
 import json
 import utils
+import logging
 
 # Some nodes can have services that are not applicable for other nodes in similar group.
 # For example , there are 3 node in kvm group, but just kvm03 node has srv-volumes-backup.mount service
@@ -30,7 +31,7 @@
     for node in services_by_nodes:
         if not services_by_nodes[node]:
             # TODO: do not skip node
-            print "Node {} is skipped".format (node)
+            logging.info("Node {} is skipped".format (node))
             continue
         nodes.append(node)
         all_services.update(services_by_nodes[node])