diff --git a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
index bf55618..a53197f 100644
--- a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
+++ b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
@@ -19,8 +19,8 @@
 Library           OperatingSystem
 Library           XML
 Library           RequestsLibrary
-Library           ../Framework/utils/utils.py
-Library           ../Framework/restApi.py
+Library           utils/utils.py
+Library           restApi.py
 
 *** Variable ***
 ${ONU_STATE_VAR}    admin_onu_state
diff --git a/src/test/cord-api/Framework/Kubernetes.robot b/src/test/cord-api/Framework/Kubernetes.robot
index 432bbc7..35b05cf 100644
--- a/src/test/cord-api/Framework/Kubernetes.robot
+++ b/src/test/cord-api/Framework/Kubernetes.robot
@@ -21,7 +21,7 @@
 Library           RequestsLibrary
 Library           utils/utils.py
 Library           restApi.py
-Resource          ../../Framework/utils/utils.robot
+Resource          utils/utils.robot
 
 *** Keywords ***
 Helm Chart is Removed
diff --git a/src/test/cord-api/Framework/OLT.robot b/src/test/cord-api/Framework/OLT.robot
index 6d16381..2301b98 100644
--- a/src/test/cord-api/Framework/OLT.robot
+++ b/src/test/cord-api/Framework/OLT.robot
@@ -20,6 +20,7 @@
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           utils/utils.py
+Library           utils/testCaseUtils.py
 Library           restApi.py
 
 *** Keywords ***
diff --git a/src/test/cord-api/Framework/ONU.robot b/src/test/cord-api/Framework/ONU.robot
index 15bcf8d..6633273 100644
--- a/src/test/cord-api/Framework/ONU.robot
+++ b/src/test/cord-api/Framework/ONU.robot
@@ -32,7 +32,7 @@
     ${getJsonDict}=    utils.getDictFromListOfDict    ${json_result_list}    serial_number    ${onu_device}
     ${operational_status}=  Get From Dictionary    ${getJsonDict}   oper_status
     ${admin_status}=  Get From Dictionary    ${getJsonDict}   admin_state
-    [Return]    ${operational_status}    ${admin_status} 
+    [Return]    ${operational_status}    ${admin_status}
 
 Create ONU Device
     [Arguments]    ${device_list}    ${list_index}
diff --git a/src/test/cord-api/Framework/Subscriber.robot b/src/test/cord-api/Framework/Subscriber.robot
index c6072dd..e1e9044 100644
--- a/src/test/cord-api/Framework/Subscriber.robot
+++ b/src/test/cord-api/Framework/Subscriber.robot
@@ -17,8 +17,8 @@
 Library           OperatingSystem
 Library           SSHLibrary
 Library           restApi.py
-Resource          ../../Framework/utils/utils.robot
-Resource          ../../Framework/DHCP.robot
+Resource          utils/utils.robot
+Resource          DHCP.robot
 
 *** Keywords ***
 Subscriber Status Check
diff --git a/src/test/cord-api/Framework/restApi.py b/src/test/cord-api/Framework/restApi.py
index aaebbc6..8e7007d 100644
--- a/src/test/cord-api/Framework/restApi.py
+++ b/src/test/cord-api/Framework/restApi.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,33 +12,42 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import, print_function
 
-#!/usr/bin/env python
-import requests, json, os, sys, time
-#sys.path.append('common-utils')
-sys.path.append(os.path.join(sys.path[0],'utils'))
-from readProperties import readProperties
+import requests
+import json
+import os
+
+from utils.readProperties import readProperties
+
 
 class restApi(object):
-    '''
+    """
     Functions for testing CORD API with POST, GET, PUT, DELETE method
-    '''
+    """
+
     def __init__(self, propertyFile="RestApiProperties.py"):
-        self.rp = readProperties(os.path.abspath(os.path.dirname(__file__))+"/../Properties/"+ propertyFile)
+        self.rp = readProperties(
+            os.path.abspath(os.path.join(
+                os.path.dirname(__file__),
+                "../Properties/",
+                propertyFile,
+            ))
+        )
         self.controllerIP = self.getValueFromProperties("SERVER_IP")
         self.controllerPort = self.getValueFromProperties("SERVER_PORT")
         self.user = self.getValueFromProperties("XOS_USER")
         self.password = self.getValueFromProperties("XOS_PASSWD")
-        self.jsonHeader = {'Content-Type': 'application/json'}
+        self.jsonHeader = {"Content-Type": "application/json"}
 
     def getValueFromProperties(self, key):
-        '''
+        """
         Get and return values from properties file
-        '''
+        """
         try:
             rawValue = self.rp.getValueProperties(key)
-            value = rawValue.replace("'","")
-        except:
+            value = rawValue.replace("'", "")
+        except BaseException:
             value = None
 
         # Allow override from environment
@@ -49,47 +57,55 @@
         return value
 
     def getURL(self, key):
-        '''
+        """
         Get REST API suffix from key and return the full URL
-        '''
-        urlSuffix =  self.getValueFromProperties(key)
+        """
+        urlSuffix = self.getValueFromProperties(key)
         url = "http://" + self.controllerIP + ":" + self.controllerPort + urlSuffix
         return url
 
     def checkResult(self, resp, expectedStatus):
-        '''
+        """
         Check if the status code in resp equals to the expected number.
         Return True or False based on the check result.
-        '''
+        """
         if resp.status_code == expectedStatus:
-            print "Test passed: " + str(resp.status_code) + ": " + resp.text
+            print("Test passed: " + str(resp.status_code) + ": " + resp.text)
             return True
         else:
-            print "Test failed: " + str(resp.status_code) + ": " + resp.text
+            print("Test failed: " + str(resp.status_code) + ": " + resp.text)
             return False
 
     def ApiPost(self, key, jsonData):
         url = self.getURL(key)
         data = json.dumps(jsonData)
-        print "url, data..", url, data
-        resp = requests.post(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
-        print "requests.codes.....",requests.codes.created
-        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
+        print("url, data..", url, data)
+        resp = requests.post(
+            url, data=data, headers=self.jsonHeader, auth=(self.user, self.password)
+        )
+        print("requests.codes.....", requests.codes.created)
+        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(
+            resp, requests.codes.ok
+        )
         return passed
 
     def ApiPostReturnJson(self, key, jsonData):
         url = self.getURL(key)
         data = json.dumps(jsonData)
-        print "url, data..", url, data
-        resp = requests.post(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
-        print "requests.codes.....",requests.codes.created
-        print "posted data...", resp.json()
-        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
+        print("url, data..", url, data)
+        resp = requests.post(
+            url, data=data, headers=self.jsonHeader, auth=(self.user, self.password)
+        )
+        print("requests.codes.....", requests.codes.created)
+        print("posted data...", resp.json())
+        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(
+            resp, requests.codes.ok
+        )
         return passed, resp.json()
 
     def ApiGet(self, key, urlSuffix=""):
         url = self.getURL(key) + str(urlSuffix)
-        print "get url...",url
+        print("get url...", url)
         resp = requests.get(url, auth=(self.user, self.password))
         passed = self.checkResult(resp, requests.codes.ok)
         if not passed:
@@ -99,7 +115,7 @@
 
     def ApiChameleonGet(self, key, urlSuffix=""):
         url = self.getURL(key) + "/" + str(urlSuffix)
-        print "get url...",url
+        print("get url...", url)
         resp = requests.get(url, auth=(self.user, self.password))
         passed = self.checkResult(resp, requests.codes.ok)
         if not passed:
@@ -108,34 +124,38 @@
             return resp.json()
 
     def ApiPut(self, key, jsonData, urlSuffix=""):
-        print "urlSuffix....",type(urlSuffix)
+        print("urlSuffix....", type(urlSuffix))
         url = self.getURL(key) + str(urlSuffix) + "/"
         data = json.dumps(jsonData)
-        resp = requests.put(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
+        resp = requests.put(
+            url, data=data, headers=self.jsonHeader, auth=(self.user, self.password)
+        )
         passed = self.checkResult(resp, requests.codes.ok)
         return passed
 
     def ApiChameleonPut(self, key, jsonData, urlSuffix=""):
-        print "urlSuffix....",type(urlSuffix)
+        print("urlSuffix....", type(urlSuffix))
         url = self.getURL(key) + "/" + str(urlSuffix)
-        print "url", url
+        print("url", url)
         data = json.dumps(jsonData)
-        resp = requests.put(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
+        resp = requests.put(
+            url, data=data, headers=self.jsonHeader, auth=(self.user, self.password)
+        )
         passed = self.checkResult(resp, requests.codes.ok)
         return passed
 
     def ApiDelete(self, key, urlSuffix=""):
         url = self.getURL(key) + str(urlSuffix)
-        print "url",url
+        print("url", url)
         resp = requests.delete(url, auth=(self.user, self.password))
         passed = self.checkResult(resp, requests.codes.no_content)
         return passed
 
     def ApiChameleonDelete(self, key, urlSuffix=""):
         url = self.getURL(key) + "/" + str(urlSuffix)
-        print "url",url
+        print("url", url)
         resp = requests.delete(url, auth=(self.user, self.password))
-        #passed = self.checkResult(resp, requests.codes.no_content)
-        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
+        passed = self.checkResult(resp, requests.codes.created) or self.checkResult(
+            resp, requests.codes.ok
+        )
         return passed
-
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
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index 1046cbf..0767de7 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,9 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-#!/usr/bin/env python
-
 SERVER_IP = '127.0.0.1'
 SERVER_PORT = '30006'
 XOS_USER = 'admin@opencord.org'
diff --git a/src/test/cord-api/Tests/BBSim/bbsim_utils.py b/src/test/cord-api/Tests/BBSim/bbsim_utils.py
index 78b1d81..3facb51 100644
--- a/src/test/cord-api/Tests/BBSim/bbsim_utils.py
+++ b/src/test/cord-api/Tests/BBSim/bbsim_utils.py
@@ -12,9 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-class bbsim_utils(object):
+from __future__ import absolute_import
 
-    def generate_subscribers(self, num_subs, rcord_service_id, stag=999, ctag_start=900, pon_id=0):
+from six.moves import range
+
+
+class bbsim_utils(object):
+    def generate_subscribers(
+        self, num_subs, rcord_service_id, stag=999, ctag_start=900, pon_id=0
+    ):
         """
         :param num_subs: Number of subscribers to create
         :param rcord_service_id: ID of the rcord service
@@ -23,36 +29,50 @@
         :return: List of subscribers to POST
         """
         subscribers = []
-        for index in xrange(1, int(num_subs) + 1):
+        for index in range(1, int(num_subs) + 1):
             sub = {
-                "name" : "Sub_BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)),
-                "status" : "pre-provisioned",
-                "c_tag" : ctag_start + int(index),
-                "s_tag" : stag,
-                "onu_device" : "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)),
-                "circuit_id" : "circuit" + '{0:02x}'.format(int(index)),
-                "remote_id" : "remote" + '{0:02x}'.format(int(index)),
-                "nas_port_id" : "PON 2/1/01/1:1.1." + '{0:0x}'.format(int(index)),
-	            "upstream_bps_id" : 1,
-                "downstream_bps_id" : 1,
-                "tech_profile_id" : 64
+                "name": "Sub_BBSM"
+                + str("00000")
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "status": "pre-provisioned",
+                "c_tag": ctag_start + int(index),
+                "s_tag": stag,
+                "onu_device": "BBSM"
+                + str("00000")
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "circuit_id": "circuit" + "{0:02x}".format(int(index)),
+                "remote_id": "remote" + "{0:02x}".format(int(index)),
+                "nas_port_id": "PON 2/1/01/1:1.1." + "{0:0x}".format(int(index)),
+                "upstream_bps_id": 1,
+                "downstream_bps_id": 1,
+                "tech_profile_id": 64,
             }
             subscribers.append(sub)
             if index == 10:
                 break
         for index in range(11, int(num_subs) + 1):
             sub = {
-                "name" : "Sub_BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)),
-                "status" : "pre-provisioned",
-                "c_tag" : ctag_start + int(index),
-                "s_tag" : stag,
-                "onu_device" : "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)),
-                "circuit_id" : "circuit" + '{0:02x}'.format(int(index)),
-                "remote_id" : "remote" + '{0:02x}'.format(int(index)),
-                "nas_port_id" : "PON 2/1/01/1:1.1." + str(pon_id) + '{0:02x}'.format(int(index)),
-                "upstream_bps_id" : 1,
-                "downstream_bps_id" : 1,
-                "tech_profile_id" : 64
+                "name": "Sub_BBSM"
+                + str("00000")
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "status": "pre-provisioned",
+                "c_tag": ctag_start + int(index),
+                "s_tag": stag,
+                "onu_device": "BBSM"
+                + str("00000")
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "circuit_id": "circuit" + "{0:02x}".format(int(index)),
+                "remote_id": "remote" + "{0:02x}".format(int(index)),
+                "nas_port_id": "PON 2/1/01/1:1.1."
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "upstream_bps_id": 1,
+                "downstream_bps_id": 1,
+                "tech_profile_id": 64,
             }
             subscribers.append(sub)
         return subscribers
@@ -67,10 +87,13 @@
         whitelists = []
         for index in range(1, int(num_onus) + 1):
             onu = {
-                "serial_number": "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)),
-                "device_id" : "of:0000626273696d76",
-                "pon_port_id" : 536870912,
-                "owner_id" : att_service_id
+                "serial_number": "BBSM"
+                + str("00000")
+                + str(pon_id)
+                + "{0:02x}".format(int(index)),
+                "device_id": "of:0000626273696d76",
+                "pon_port_id": 536870912,
+                "owner_id": att_service_id,
             }
             whitelists.append(onu)
         return whitelists
