Mark bug 6595 on test failure
[integration/test.git] / csit / libraries / UtilLibrary.py
index 05ef69ab374ada992473714c97b64244f737328d..1b2ead89baf977a2572d098467f3ca8da430a188 100644 (file)
@@ -1,22 +1,27 @@
-__author__ = "Basheeruddin Ahmed"
-__copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
-__license__ = "New-style BSD"
-__email__ = "syedbahm@cisco.com"
-
-
 import requests
 from SSHLibrary import SSHLibrary
 
 import robot
 import time
 import re
+import warnings
+
+
+__author__ = "Basheeruddin Ahmed"
+__copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
+__license__ = "New-style BSD"
+__email__ = "syedbahm@cisco.com"
+
 
 global _cache
 
 
 def get(url, userId='admin', password='admin'):
     """Helps in making GET REST calls"""
-
+    warnings.warn(
+        "Use the Robot RequestsLibrary rather than this. See DatastoreCRUD.robot for examples",
+        DeprecationWarning
+    )
     headers = {}
     headers['Accept'] = 'application/xml'
 
@@ -30,6 +35,10 @@ def get(url, userId='admin', password='admin'):
 
 def nonprintpost(url, userId, password, data):
     """Helps in making POST REST calls without outputs"""
+    warnings.warn(
+        "Use the Robot RequestsLibrary rather than this. See DatastoreCRUD.robot for examples",
+        DeprecationWarning
+    )
 
     if userId is None:
         userId = 'admin'
@@ -49,6 +58,10 @@ def nonprintpost(url, userId, password, data):
 
 def post(url, userId, password, data):
     """Helps in making POST REST calls"""
+    warnings.warn(
+        "Use the Robot RequestsLibrary rather than this. See DatastoreCRUD.robot for examples",
+        DeprecationWarning
+    )
 
     if userId is None:
         userId = 'admin'
@@ -56,16 +69,16 @@ def post(url, userId, password, data):
     if password is None:
         password = 'admin'
 
-    print("post request with url "+url)
-    print("post request with data "+data)
+    print("post request with url " + url)
+    print("post request with data " + data)
     headers = {}
     headers['Content-Type'] = 'application/json'
-    # headers['Accept']= 'application/xml'
+    # headers['Accept'] = 'application/xml'
     session = _cache.switch("CLUSTERING_POST")
     resp = session.post(url, data.encode('utf-8'), headers=headers, auth=(userId, password))
 
-    # print (resp.raise_for_status())
-    print (resp.headers)
+    # print(resp.raise_for_status())
+    print(resp.headers)
     if resp.status_code >= 500:
         print(resp.text)
 
@@ -74,7 +87,11 @@ def post(url, userId, password, data):
 
 def delete(url, userId='admin', password='admin'):
     """Helps in making DELET REST calls"""
-    print("delete all resources belonging to url"+url)
+    warnings.warn(
+        "Use the Robot RequestsLibrary rather than this. See DatastoreCRUD.robot for examples",
+        DeprecationWarning
+    )
+    print("delete all resources belonging to url" + url)
     session = _cache.switch("CLUSTERING_DELETE")
     resp = session.delete(url, auth=(userId, password))  # noqa
 
@@ -131,7 +148,7 @@ def wait_for_controller_up(ip, port="8181"):
 def startAllControllers(username, password, karafhome, port, *ips):
     # Start all controllers
     for ip in ips:
-        execute_ssh_command(ip, username, password, karafhome+"/bin/start")
+        execute_ssh_command(ip, username, password, karafhome + "/bin/start")
 
     # Wait for all of them to be up
     for ip in ips:
@@ -153,7 +170,7 @@ def stopcontroller(ip, username, password, karafhome):
 
 
 def executeStopController(ip, username, password, karafhome):
-    execute_ssh_command(ip, username, password, karafhome+"/bin/stop")
+    execute_ssh_command(ip, username, password, karafhome + "/bin/stop")
 
 
 def stopAllControllers(username, password, karafhome, *ips):
@@ -207,7 +224,7 @@ def isolate_controller(controllers, username, password, isolated):
     :param isolated: Number (starting at one) of the controller to be isolated.
     :return: If successful, returns "pass", otherwise returns the last failed IPTables text.
     """
-    isolated_controller = controllers[isolated-1]
+    isolated_controller = controllers[isolated - 1]
     for controller in controllers:
         if controller != isolated_controller:
             base_str = 'sudo iptables -I OUTPUT -p all --source '
@@ -239,7 +256,7 @@ def rejoin_controller(controllers, username, password, isolated):
     :param isolated: Number (starting at one) of the isolated controller isolated.
     :return: If successful, returns "pass", otherwise returns the last failed IPTables text.
     """
-    isolated_controller = controllers[isolated-1]
+    isolated_controller = controllers[isolated - 1]
     for controller in controllers:
         if controller != isolated_controller:
             base_str = 'sudo iptables -D OUTPUT -p all --source '