[VOL-2282]

Python 3 compatibility fixes and reorg

Moved the VOLTHA 1.x testCaseUtils.py to this repo, used by OLT.robot

Change-Id: I6936421e0d3155ad79c74e28058b8c0865daf107
diff --git a/src/test/cord-api/Framework/utils/onosUtils.py b/src/test/cord-api/Framework/utils/onosUtils.py
index 06420a6..ac07dc2 100644
--- a/src/test/cord-api/Framework/utils/onosUtils.py
+++ b/src/test/cord-api/Framework/utils/onosUtils.py
@@ -12,9 +12,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
+
 import paramiko
 
-def onos_command_execute(host, portNum, cmd, user='karaf', passwd='karaf'):
+
+def onos_command_execute(host, portNum, cmd, user="karaf", passwd="karaf"):
     """
     :param host: onos-cord or onos-fabric
     :param portNum: 8102 or 8101
@@ -34,6 +37,7 @@
     finally:
         client.close()
 
+
 def get_compute_node_ip(compute_node):
     """
     :param compute_node: one compute node information from output of 'cordvtn-nodes'
@@ -42,4 +46,4 @@
     for line in compute_node.splitlines():
         columns = line.split()
         if len(columns) >= 2:
-            return columns[2].split("/")[0]
\ No newline at end of file
+            return columns[2].split("/")[0]
diff --git a/src/test/cord-api/Framework/utils/openstackUtils.py b/src/test/cord-api/Framework/utils/openstackUtils.py
index 33e1fbf..3af4063 100644
--- a/src/test/cord-api/Framework/utils/openstackUtils.py
+++ b/src/test/cord-api/Framework/utils/openstackUtils.py
@@ -13,41 +13,39 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
 
-import time
-import json
-import collections
-import sys
-import os.path
 import re
 
+
 def get_neutron_lists(netlist):
-    pairs = re.split("\+-*\+-*\+\n?",netlist)[2:-1]
-    ids,names,subnets = [],[],[]
+    pairs = re.split(r"\+-*\+-*\+\n?", netlist)[2:-1]
+    ids, names, subnets = [], [], []
     for p in pairs:
-      for l in p.split('\n'):
-        pair = l.split('|')
-        if len(pair) > 1:
-          ids.append(pair[1].strip())
-          names.append(pair[2].strip())
-          subnets.append(pair[3].strip())
-    nets = dict(zip(names,subnets))
+        for l in p.split('\n'):
+            pair = l.split('|')
+            if len(pair) > 1:
+                ids.append(pair[1].strip())
+                names.append(pair[2].strip())
+                subnets.append(pair[3].strip())
+    nets = dict(zip(names, subnets))
     return nets
 
-def get_nova_lists(novalist,nameWildCard=None):
-    pairs = re.split("\+-*\+-*\+\n?",novalist)[2:-1]
-    ids,names,status,taskState,powerState,networks = [],[],[],[],[],[]
+
+def get_nova_lists(novalist, nameWildCard=None):
+    pairs = re.split(r"\+-*\+-*\+\n?", novalist)[2:-1]
+    ids, names, status, taskState, powerState, networks = [], [], [], [], [], []
     for p in pairs:
-      for l in p.split('\n'):
-        pair = l.split('|')
-        if len(pair) > 1:
-          ids.append(pair[1].strip())
-          names.append(pair[2].strip())
-          status.append(pair[3].strip())
-          taskState.append(pair[4].strip())
-          powerState.append(pair[5].strip())
-          networks.append(pair[6].strip())
-    instances = dict(zip(names,networks))
+        for l in p.split('\n'):
+            pair = l.split('|')
+            if len(pair) > 1:
+                ids.append(pair[1].strip())
+                names.append(pair[2].strip())
+                status.append(pair[3].strip())
+                taskState.append(pair[4].strip())
+                powerState.append(pair[5].strip())
+                networks.append(pair[6].strip())
+    instances = dict(zip(names, networks))
     if nameWildCard is not None:
         for key in instances.keys():
             if re.match(nameWildCard, key):
@@ -55,23 +53,24 @@
     else:
         return instances
 
-def get_instance_status(novalist,nameWildCard=None):
-    pairs = re.split("\+-*\+-*\+\n?",novalist)[2:-1]
-    ids,names,status,taskState,powerState,networks = [],[],[],[],[],[]
+
+def get_instance_status(novalist, nameWildCard=None):
+    pairs = re.split(r"\+-*\+-*\+\n?", novalist)[2:-1]
+    ids, names, status, taskState, powerState, networks = [], [], [], [], [], []
     for p in pairs:
-      for l in p.split('\n'):
-        pair = l.split('|')
-        if len(pair) > 1:
-          ids.append(pair[1].strip())
-          names.append(pair[2].strip())
-          status.append(pair[3].strip())
-          taskState.append(pair[4].strip())
-          powerState.append(pair[5].strip())
-          networks.append(pair[6].strip())
-    instances = dict(zip(names,status))
+        for l in p.split('\n'):
+            pair = l.split('|')
+            if len(pair) > 1:
+                ids.append(pair[1].strip())
+                names.append(pair[2].strip())
+                status.append(pair[3].strip())
+                taskState.append(pair[4].strip())
+                powerState.append(pair[5].strip())
+                networks.append(pair[6].strip())
+    instances = dict(zip(names, status))
     if nameWildCard is not None:
         for key in instances.keys():
             if re.match(nameWildCard, key):
                 return instances[key]
     else:
-        return instances
\ No newline at end of file
+        return instances
diff --git a/src/test/cord-api/Framework/utils/readProperties.py b/src/test/cord-api/Framework/utils/readProperties.py
index 53fd471..b778dbb 100644
--- a/src/test/cord-api/Framework/utils/readProperties.py
+++ b/src/test/cord-api/Framework/utils/readProperties.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,16 +12,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
 
 import sys
 
+
 class readProperties(object):
     def __init__(self, strPropertiesFile):
         self.strPropertiesFile = strPropertiesFile
 
     @staticmethod
     def parse_line(input):
-        key, value = input.split('=',1)
+        key, value = input.split("=", 1)
         key = key.strip()
         value = value.strip()
         return key, value
@@ -34,8 +35,8 @@
         with open(self.strPropertiesFile) as fp:
             for line in fp:
                 line = line.strip()
-                if not line or line.startswith('#') or line.startswith('import'):
-                   continue
+                if not line or line.startswith("#") or line.startswith("import"):
+                    continue
 
                 key, value = readProperties.parse_line(line)
                 data[key] = value
@@ -47,6 +48,7 @@
         value = datas[key]
         return value
 
-#test
-#test = readProperties("testProperties.py")
-#test.getValueProperties("CORE_INSTANCES")
+
+# test
+# test = readProperties("testProperties.py")
+# test.getValueProperties("CORE_INSTANCES")
diff --git a/src/test/cord-api/Framework/utils/testCaseUtils.py b/src/test/cord-api/Framework/utils/testCaseUtils.py
new file mode 100755
index 0000000..41ed562
--- /dev/null
+++ b/src/test/cord-api/Framework/utils/testCaseUtils.py
@@ -0,0 +1,243 @@
+#
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Test Case Utils module
+"""
+
+from __future__ import absolute_import
+
+import time
+import subprocess
+import pexpect
+import sys
+
+
+def config_dirs(self, log_dir, root_dir=None, voltha_dir=None):
+    self.dirs["log"] = log_dir
+    self.dirs["root"] = root_dir
+    self.dirs["voltha"] = voltha_dir
+
+
+def get_dir(self, directory):
+    return self.dirs.get(directory)
+
+
+def remove_leading_line(log_dir, log_file):
+    with open(log_dir + "/" + log_file, "r+") as FILE:
+        lines = FILE.readlines()
+        FILE.seek(0)
+        lines = lines[1:]
+        for line in lines:
+            FILE.write(line)
+        FILE.truncate()
+        FILE.close()
+
+
+def send_command_to_voltha_cli(
+    log_dir,
+    log_file1,
+    cmd1,
+    log_file2=None,
+    cmd2=None,
+    log_file3=None,
+    cmd3=None,
+    host="localhost",
+):
+    output = open(log_dir + "/" + log_file1, "w")
+    child = pexpect.spawn(
+        "ssh -p 30110 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no voltha@%s"
+        % host
+    )
+    child.expect(r"[pP]assword:")
+    child.sendline("admin")
+    child.expect(r"\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)")
+    time.sleep(10)
+    child.sendline(cmd1)
+    i = child.expect(
+        [
+            r"\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)",
+            r"\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)",
+        ]
+    )
+    if i == 0:
+        output.write(child.before)
+        output.close()
+        remove_leading_line(log_dir, log_file1)
+    elif i == 1:
+        if log_file2 is not None and cmd2 is not None:
+            output = open(log_dir + "/" + log_file2, "w")
+            child.sendline(cmd2)
+            child.expect(
+                r"\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)"
+            )
+            output.write(child.before)
+            output.close()
+            remove_leading_line(log_dir, log_file2)
+        if log_file3 is not None and cmd3 is not None:
+            output = open(log_dir + "/" + log_file3, "w")
+            child.sendline(cmd3)
+            child.expect(
+                r"\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)"
+            )
+            output.write(child.before)
+            output.close()
+            remove_leading_line(log_dir, log_file3)
+    child.close()
+
+
+def send_command_to_onos_cli(log_dir, log_file, cmd, host="localhost"):
+    output = open(log_dir + "/" + log_file, "w")
+    child = pexpect.spawn(
+        "ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no karaf@%s"
+        % host
+    )
+    child.expect(r"[pP]assword:")
+    child.sendline("karaf")
+    child.expect(r"(\\x1b\[\d*;?\d+m){1,2}(onos>|karaf@root >) (\\x1b\[\d*;?\d+m){1,2}")
+    child.sendline(cmd)
+    child.expect(r"(\\x1b\[\d*;?\d+m){1,2}(onos>|karaf@root >) (\\x1b\[\d*;?\d+m){1,2}")
+
+    output.write(child.before)
+
+    output.close()
+    child.close()
+
+
+def get_fields_from_grep_command(self, search_word, log_file):
+    grepCommand = "grep %s %s/%s" % (search_word, get_dir(self, "log"), log_file)
+    statusLines = subprocess.getstatusoutput(grepCommand)[1]
+    return statusLines
+
+
+def parse_fields(status_line, delimiter):
+    statusList = status_line.split(delimiter)
+    return statusList
+
+
+def print_log_file(self, log_file):
+    with open(get_dir(self, "log") + "/" + log_file, "r+") as FILE:
+        lines = FILE.readlines()
+        print
+        for line in lines:
+            sys.stdout.write(line)
+
+
+def extract_pod_ip_addr(pod_name):
+    proc1 = subprocess.Popen(
+        ["/usr/bin/kubectl", "get", "svc", "--all-namespaces"],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc2 = subprocess.Popen(
+        ["grep", "-e", pod_name],
+        stdin=proc1.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc3 = subprocess.Popen(
+        ["awk", "{print $4}"],
+        stdin=proc2.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+
+    proc1.stdout.close()
+    proc2.stdout.close()
+    out, err = proc3.communicate()
+    return out
+
+
+def extract_radius_ip_addr(pod_name):
+    proc1 = subprocess.Popen(
+        ["/usr/bin/kubectl", "describe", "pod", "-n", "voltha", pod_name],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc2 = subprocess.Popen(
+        ["grep", "^IP:"],
+        stdin=proc1.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc3 = subprocess.Popen(
+        ["awk", "{print $2}"],
+        stdin=proc2.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+
+    proc1.stdout.close()
+    proc2.stdout.close()
+    out, err = proc3.communicate()
+    return out
+
+
+def extract_pod_name(short_pod_name):
+    proc1 = subprocess.Popen(
+        ["/usr/bin/kubectl", "get", "pods", "--all-namespaces"],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc2 = subprocess.Popen(
+        ["grep", "-e", short_pod_name],
+        stdin=proc1.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    proc3 = subprocess.Popen(
+        ["awk", "{print $2}"],
+        stdin=proc2.stdout,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+
+    proc1.stdout.close()
+    proc2.stdout.close()
+    out, err = proc3.communicate()
+    return out
+
+
+def modify_radius_ip_in_json_using_sed(self, new_ip_addr):
+    sedCommand = (
+        "sed -i '/radiusIp/c\\      \"radiusIp\":\"'%s'\",' %s/tests/atests/build/aaa_json"
+        % (new_ip_addr, get_dir(self, "voltha"))
+    )
+    status = subprocess.getstatusoutput(sedCommand)[0]
+    return status
+
+
+def discover_rg_pod_name():
+    return extract_pod_name("rg0").strip()
+
+
+def retrieve_authorized_users_device_id_and_port_number(status_line):
+    fields = parse_fields(status_line, ",")
+    deviceField = fields[2].strip()
+    deviceStr, equal, deviceId = deviceField.partition("=")
+    device_Id = deviceId
+    portField = fields[4].strip()
+    portNumStr, equal, portNum = portField.partition("=")
+    portNumber = portNum
+    return device_Id, portNumber
+
+
+def add_subscriber_access(self, device_id, port_number):
+    send_command_to_onos_cli(
+        get_dir(self, "log"),
+        "voltha_add_subscriber_access.log",
+        "volt-add-subscriber-access %s %s" % (device_id, port_number),
+    )
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 6fa9bfe..b475c06 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,24 +12,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import, print_function
 
-import os
-import time
 import json
-import collections
-import sys
-import robot
-import os.path
-from os.path import expanduser
 import uuid
 import random
-import re
 import yaml
 import glob
 import string
 
-class utils(object):
 
+class utils(object):
     @staticmethod
     def listToDict(alist, intListIndex):
         dictInfo = alist[int(intListIndex)]
@@ -39,69 +31,72 @@
     @staticmethod
     def jsonToList(strFile, strListName):
         data = json.loads(open(strFile).read())
-        #print "data...",data
+        # print "data...",data
         dataList = data[strListName]
         return dataList
 
     def readFile(self, path, single=True):
         dataDict = {}
         for fileName in glob.glob(path):
-            print "Reading ", fileName
+            print("Reading ", fileName)
             data = open(fileName).read()
             dataDict[fileName] = data
             if bool(single):
                 return data
         if not dataDict:
-            print "Failed to find the file!"
+            print("Failed to find the file!")
             return None
         return dataDict
 
     def readFiles(self, path):
         return self.readFile(path, single=False)
 
-    '''
+    """
     @method compare_dict
     @Description: validates if contents of dict1 exists in dict2
     @params: dict1 = input_data entered through api
              dict2 = retrieved data from GET method
     returns True if contents of dict1 exists in dict2
-    '''
+    """
+
     def compare_dict(self, dict1, dict2):
-        print "input data", dict1
-        print "get data", dict2
-        if dict1 == None or dict2 == None:
-           return False
-        if type(dict1) is not dict or type(dict2) is not dict:
-           return False
+        print("input data", dict1)
+        print("get data", dict2)
+        if dict1 is None or dict2 is None:
+            return False
+        if not isinstance(dict1, dict) or not isinstance(dict2, dict):
+            return False
         if dict1 == {}:
             return True
         return self.compare_dict_recursive(dict1, dict2)
 
-    '''
+    """
     @method compare_dict_recursive
     @Description: recursive function to validate if dict1 is a subset of dict2
     returns True if contents of dict1 exists in dict2
-    '''
+    """
+
     def compare_dict_recursive(self, dict1, dict2):
-        for key1,value1 in dict1.items():
+        for key1, value1 in dict1.items():
             if key1 not in dict2.keys():
-                print "Missing key", key1, "in dict2"
+                print("Missing key", key1, "in dict2")
                 return False
             value2 = dict2[key1]
-            if type(value1) is dict and type(value2) is dict:
+            if isinstance(value1, dict) and isinstance(value2, dict):
                 if not self.compare_dict_recursive(value1, value2):
                     return False
             else:
                 if value2 != value1:
-                    print "Values of key", key1, "in two dicts are not equal"
+                    print("Values of key", key1, "in two dicts are not equal")
                     return False
         return True
 
-    '''
+    """
     @method compare_list_of_dicts
     @Description: validates if contents of dicts in list1 exists in dicts of list2
     returns True if for each dict in list1, there's a dict in list2 that contains its content
-    '''
+    """
+
     def compare_list_of_dicts(self, list1, list2):
         for dict1 in list1:
             if dict1 == {}:
@@ -110,14 +105,24 @@
             value = dict1[key]
             dict2 = self.getDictFromListOfDict(list2, key, value)
             if dict2 == {}:
-                print "Comparison failed: no dictionaries found in list2 with key", key, "and value", value
+                print(
+                    "Comparison failed: no dictionaries found in list2 with key",
+                    key,
+                    "and value",
+                    value,
+                )
                 return False
-            if self.compare_dict(dict1, dict2) == False:
-                print "Comparison failed: dictionary", dict1, "is not a subset of dictionary", dict2
+            if not self.compare_dict(dict1, dict2):
+                print(
+                    "Comparison failed: dictionary",
+                    dict1,
+                    "is not a subset of dictionary",
+                    dict2,
+                )
                 return False
         return True
 
-    '''
+    """
     @method search_dictionary
     @Description: Searches for a key in the provided nested dictionary
     @params: input_dict = dictionary to be searched
@@ -125,31 +130,35 @@
     returns two values: search_key value and status of the search.
              True if found (False when not found)
 
-    '''
-    def search_dictionary(self,input_dict, search_key):
+    """
+
+    def search_dictionary(self, input_dict, search_key):
         input_keys = input_dict.keys()
-        key_value = ''
+        key_value = ""
         found = False
         for key in input_keys:
             if key == search_key:
-               key_value = input_dict[key]
-               found = True
-               break
-            elif type(input_dict[key]) == dict:
-                 key_value, found = self.search_dictionary(input_dict[key],search_key)
-                 if found == True:
+                key_value = input_dict[key]
+                found = True
+                break
+            elif isinstance(input_dict[key], dict):
+                key_value, found = self.search_dictionary(
+                    input_dict[key], search_key)
+                if found:
                     break
-            elif type(input_dict[key]) == list:
-                 if not input_dict[key]:
+            elif isinstance(input_dict[key], list):
+                if not input_dict[key]:
                     found = False
                     break
-                 for item in input_dict[key]:
-                     if isinstance(item, dict):
-                        key_value, found = self.search_dictionary(item, search_key)
-                        if found == True:
-                           break
-        return key_value,found
-    '''
+                for item in input_dict[key]:
+                    if isinstance(item, dict):
+                        key_value, found = self.search_dictionary(
+                            item, search_key)
+                        if found:
+                            break
+        return key_value, found
+
+    """
     @method getDictFromListOfDict
         return key_value,found
     @Description: Searches for the dictionary in the provided list of dictionaries
@@ -159,104 +168,111 @@
              searchKeyValue - Value of the searchKey (ex: 21)
     @Returns: Dictionary returned when match found for searchKey with the corresponding
              searchKeyValue provided
-    '''
+    """
 
-    def getDictFromListOfDict(self, getJsonDataList, searchKey, searchKeyValue):
+    def getDictFromListOfDict(self, getJsonDataList,
+                              searchKey, searchKeyValue):
         return_dict = {}
-        result = ''
+        result = ""
         for data in getJsonDataList:
-            print "data", data
+            print("data", data)
             return_dict = {}
             found = False
             input_keys = data.keys()
             for key in input_keys:
                 if key == searchKey and str(data[key]) == str(searchKeyValue):
-                   found = True
-                   return_dict = data
-                   print "return_dict",return_dict
-                   break
-                elif type(data[key]) == dict:
-                     result, found = self.search_dictionary(data[key],searchKey)
-                     if found == True and str(result) == str(searchKeyValue):
+                    found = True
+                    return_dict = data
+                    print("return_dict", return_dict)
+                    break
+                elif isinstance(data[key], dict):
+                    result, found = self.search_dictionary(
+                        data[key], searchKey)
+                    if found and str(result) == str(searchKeyValue):
                         return_dict = data
                         break
-                elif type(data[key]) == list:
-                     for item in data[key]:
-                         if isinstance(item, dict):
-                            result, found = self.search_dictionary(data[key], searchKey)
-                            if found == True and str(result) == str(searchKeyValue):
-                               return_dict = data
-                               break
+                elif isinstance(data[key], list):
+                    for item in data[key]:
+                        if isinstance(item, dict):
+                            result, found = self.search_dictionary(
+                                data[key], searchKey)
+                            if found and str(
+                                    result) == str(searchKeyValue):
+                                return_dict = data
+                                break
             if return_dict:
-               break
+                break
         return return_dict
 
-
-    '''
+    """
     @method getFieldValueFromDict
     @params : search_dict - Dictionary to be searched
              field - Key to be searched for (ex: account_num)
     @Returns: Returns the value of the Key that was provided
-    '''
-    def getFieldValueFromDict(self,search_dict, field):
-        results = ''
+    """
+
+    def getFieldValueFromDict(self, search_dict, field):
+        results = ""
         found = False
         input_keys = search_dict.keys()
         for key in input_keys:
-            print "key...", key
+            print("key...", key)
             if key == field:
-               results = search_dict[key]
-               if not results:
-                  found = True
-                  break
-            elif type(search_dict[key]) == dict:
-                 results, found = self.search_dictionary(search_dict[key],field)
-                 if found == True:
+                results = search_dict[key]
+                if not results:
+                    found = True
                     break
-            elif type(search_dict[key]) == list:
-                 if not search_dict[key]:
+            elif isinstance(search_dict[key], dict):
+                results, found = self.search_dictionary(
+                    search_dict[key], field)
+                if found:
+                    break
+            elif isinstance(search_dict[key], list):
+                if not search_dict[key]:
                     found = False
                     continue
-                 for item in search_dict[key]:
-                     if isinstance(item, dict):
+                for item in search_dict[key]:
+                    if isinstance(item, dict):
                         results, found = self.search_dictionary(item, field)
-                        if found == True:
-                           break
+                        if found:
+                            break
             if results:
-               break
+                break
 
         return results
 
-    def setFieldValueInDict(self,input_dict,field,field_value):
-        input_dict[field]=field_value
+    def setFieldValueInDict(self, input_dict, field, field_value):
+        input_dict[field] = field_value
         return input_dict
 
-    '''
+    """
     @method getAllFieldValues
     @params : getJsonDataDictList - List of dictionaries to be searched
              fieldName - Key to be searched for (ex: instance_id)
     @Returns: Returns the unique value of the Key that was provided
-    '''
+    """
 
     def getAllFieldValues(self, getJsonDataDictList, fieldName):
         value_list = []
-        uniqValue = ''
+        uniqValue = ""
         uniq_list = []
         for data in getJsonDataDictList:
-            fieldValue = ''
+            fieldValue = ""
             fieldValue = self.getFieldValueFromDict(data, fieldName)
             value_list.append(fieldValue)
         uniq_list = sorted(set(value_list))
         if len(uniq_list) == 1:
-           uniqValue = uniq_list[0]
+            uniqValue = uniq_list[0]
         else:
-           print "list of values found for ", fieldName, ";", uniq_list
+            print("list of values found for ", fieldName, ";", uniq_list)
         return fieldValue
 
     def generate_uuid(self):
         return uuid.uuid4()
 
-    def generate_random_number_from_blacklist(self, blacklist, min=100, max=500, typeTag=False):
+    def generate_random_number_from_blacklist(
+        self, blacklist, min=100, max=500, typeTag=False
+    ):
         num = None
         while num in blacklist or num is None:
             num = random.randrange(int(min), int(max))
@@ -269,38 +285,45 @@
         resourceNames = []
         names = {}
         dnames = []
-        with open(inputfile, 'r') as f:
+        with open(inputfile, "r") as f:
             contents = yaml.load(f)
         resources = contents[resource]
         for i in resources:
             resourceNames.append(i["name"])
         for i in resourceNames:
-            names['name']=i
+            names["name"] = i
             dnames.append(names.copy())
         return dnames
 
-    def generate_random_value(self, value, max_length=10, min_int=1, max_int=10000):
-        if value == 'string':
-                return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(max_length))
-        if value == 'bool':
-                return random.choice([True, False])
-        if value == 'int32' or value == 'uint32':
-                return random.randint(min_int,max_int)
-        if value == 'float':
-            return random.uniform(1,10)
-        if value == 'role':
-            return 'admin'
-        if value == 'direction':
-            return random.choice(['in', 'out'])
-        if value == 'flavor':
-            return random.choice(['m1.large', 'm1.medium', 'm1.small'])
-        if value == 'vlan_tag':
-            return random.choice(['555', '1-4096', 'ANY'])
-        if value == 'ip_address':
+    def generate_random_value(
+            self, value, max_length=10, min_int=1, max_int=10000):
+        if value == "string":
+            return "".join(
+                random.choice(string.ascii_lowercase + string.digits)
+                for _ in range(max_length)
+            )
+        if value == "bool":
+            return random.choice([True, False])
+        if value == "int32" or value == "uint32":
+            return random.randint(min_int, max_int)
+        if value == "float":
+            return random.uniform(1, 10)
+        if value == "role":
+            return "admin"
+        if value == "direction":
+            return random.choice(["in", "out"])
+        if value == "flavor":
+            return random.choice(["m1.large", "m1.medium", "m1.small"])
+        if value == "vlan_tag":
+            return random.choice(["555", "1-4096", "ANY"])
+        if value == "ip_address":
             return ".".join(str(random.randint(0, 255)) for _ in range(4))
         else:
             return None
 
     def generate_random_slice_name(self):
-        random_name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))
-        return 'testloginbase' + random_name
+        random_name = "".join(
+            random.choice(
+                string.ascii_lowercase +
+                string.digits) for _ in range(10))
+        return "testloginbase" + random_name
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index 5f9727f..4a2b58b 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -15,7 +15,6 @@
 *** Settings ***
 Documentation    Library for various utilities
 Library           SSHLibrary
-Library           HttpLibrary.HTTP
 Library           String
 Library           DateTime
 Library           Process