use specified plc's api
Tony Mack [Tue, 13 May 2008 01:26:23 +0000 (01:26 +0000)]
qaapi/qa/tests/api_unit_test.py

index dc3a523..46f989c 100755 (executable)
@@ -20,42 +20,17 @@ import time
 from Test import Test
 from qa import utils
 from qa.Config import Config
-from qa.logger import Logfile, log, logfile
+from qa.logger import Logfile, log 
 from random import Random
 
 random = Random()
-
-config = Config()
-api = config.api
-auth = api.auth  
-
-try: boot_states = api.GetBootStates(auth)
-except: boot_states = [u'boot', u'dbg', u'inst', u'new', u'rcnf', u'rins']
-
-try: roles = [role['role_id'] for role in api.GetRoles(auth)]
-except: roles = [10,20,30,40]
-
-try: methods = api.GetNetworkMethods(auth)
-except: methods = [u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown']
-
-try: key_types = api.GetKeyTypes(auth)
-except: key_types = [u'ssh']
-
-try:types = api.GetNetworkTypes(auth)
-except: types = [u'ipv4']
-
-try:
-    attribute_types = [a['attribute_type_id'] for a in api.GetSliceAttributeTypes(auth)]
-    attribute_types = filter(lambda x: x['name'] != 'initscript', attribute_types)
-       
-except: 
-    attribute_types = range(6,20)
-
-try:
-    sites = api.GetSites(auth, None, ['login_base'])
-    login_bases = [site['login_base'] for site in sites]
-except: 
-    login_bases = ['pl']
+boot_states = [u'boot', u'dbg', u'inst', u'new', u'rcnf', u'rins']
+roles = [10,20,30,40]
+methods = [u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown']
+key_types = [u'ssh']
+types = [u'ipv4']
+attribute_types = range(6,20)
+login_bases = ['pl']
 
 
 def randfloat(min = 0.0, max = 1.0):
@@ -309,9 +284,8 @@ def random_message():
 
 class api_unit_test(Test):
 
-    logfile = Logfile("api-unittest-summary.log")
-   
     def call(self,
+            plc_name = None,
             boot_states = 2,
             sites = 2,
             peers = 2,
@@ -339,13 +313,18 @@ class api_unit_test(Test):
             keys = 3,
             messages = 2
            ):
+       plc = self.config.get_plc(plc_name)
+        self.api = plc.config.api
+        self.auth = plc.config.auth
+        self.logfile = Logfile(self.config.logfile.dir + 'api-unittest.log')
+
        # Filter out deprecated (Adm) and boot Methods
        current_methods = lambda method: not method.startswith('Adm') and \
                                         not method.startswith('Slice') and \
                                         not method.startswith('Boot') and \
                                         not method.startswith('Anon') and \
                                         not method.startswith('system')
-       self.all_methods = set(filter(current_methods, api.system.listMethods())) 
+       self.all_methods = set(filter(current_methods, self.api.system.listMethods())) 
        self.methods_tested = set()
        self.methods_failed = set()
 
@@ -403,9 +382,6 @@ class api_unit_test(Test):
                if hasattr(self, 'SetPersonPrimarySite'): self.SetPersonPrimarySite()
                if hasattr(self, 'VerifyPerson'): self.VerifyPerson()
                
-               
-               
-                
            except:
                print_exc()
        finally:
@@ -452,18 +428,23 @@ class api_unit_test(Test):
        except:
            self.methods_failed.update([method_name])
            return False
-       return True 
+       return True
     def debug(self, method, method_name=None):
        if method_name is None:
-            method_name = method.name
-
-        self.methods_tested.update([method_name])
+           try: 
+               method_name = method.name
+               self.methods_tested.update([method_name])
+           except:
+               method_name = method._Method__name
+               self.methods_tested.update([method_name])
+               
        def wrapper(*args, **kwds):
            try:
                return method(*args, **kwds)
            except:
                self.methods_failed.update([method_name])
-               print >> logfile, "%s%s: %s\n" % (method_name, tuple(args[1:]), traceback.format_exc()) 
+               print >> self.logfile, "%s%s: %s\n" % (method_name, tuple(args[1:]), traceback.format_exc()) 
                return None
 
        return wrapper
@@ -503,31 +484,32 @@ class api_unit_test(Test):
        for i in range(n):
            # Add Site
            site_fields = random_site()
-           AddSite = self.debug(api.AddSite) 
-           site_id = AddSite(auth, site_fields)
+           AddSite = self.debug(self.api.AddSite) 
+           site_id = AddSite(self.auth, site_fields)
            if site_id is None: continue
 
            # Should return a unique id
            self.isunique(site_id, site_ids, 'AddSite - isunique')
            site_ids.append(site_id)
-           GetSites = self.debug(api.GetSites)
-           sites = GetSites(auth, [site_id])
+           GetSites = self.debug(self.api.GetSites)
+           sites = GetSites(self.auth, [site_id])
            if sites is None: continue
            site = sites[0]
            self.isequal(site, site_fields, 'AddSite - isequal')
        
            # Update site
            site_fields = random_site()
-           UpdateSite = self.debug(api.UpdateSite)
-           result = UpdateSite(auth, site_id, site_fields)
+           UpdateSite = self.debug(self.api.UpdateSite)
+           result = UpdateSite(self.auth, site_id, site_fields)
+                
 
            # Check again
-           sites = GetSites(auth, [site_id])
+           sites = GetSites(self.auth, [site_id])
            if sites is None: continue
            site = sites[0]      
            self.isequal(site, site_fields, 'UpdateSite - isequal')
            
-       sites = GetSites(auth, site_ids)
+       sites = GetSites(self.auth, site_ids)
        if sites is not None: 
            self.islistequal(site_ids, [site['site_id'] for site in sites], 'GetSites - isequal')
        
@@ -539,13 +521,13 @@ class api_unit_test(Test):
 
     def DeleteSites(self):
         # Delete all sites
-        DeleteSite = self.debug(api.DeleteSite)
+        DeleteSite = self.debug(self.api.DeleteSite)
         for site_id in self.site_ids:
-            result = DeleteSite(auth, site_id)
+            result = DeleteSite(self.auth, site_id)
 
         # Check if sites are deleted
-       GetSites = self.debug(api.GetSites)
-       sites = GetSites(auth, self.site_ids) 
+       GetSites = self.debug(self.api.GetSites)
+       sites = GetSites(self.auth, self.site_ids) 
         self.islistequal(sites, [], 'DeleteSite - check')      
 
         if self.config.verbose:
@@ -555,26 +537,26 @@ class api_unit_test(Test):
 
     def NetworkMethods(self, n=2):
         methods = []
-       AddNetworkMethod = self.debug(api.AddNetworkMethod)
-       GetNetworkMethods = self.debug(api.GetNetworkMethods)
+       AddNetworkMethod = self.debug(self.api.AddNetworkMethod)
+       GetNetworkMethods = self.debug(self.api.GetNetworkMethods)
  
         for i in range(n):
             # Add Network Method
             net_method = randstr(10)
-            AddNetworkMethod(auth, net_method)
+            AddNetworkMethod(self.auth, net_method)
             if net_method is None: continue
 
             # Should return a unique id
             self.isunique(net_method, methods, 'AddNetworkMethod - isunique')
             methods.append(net_method)
-            net_methods = GetNetworkMethods(auth)
+            net_methods = GetNetworkMethods(self.auth)
             if net_methods is None: continue
            net_methods = filter(lambda x: x in [net_method], net_methods) 
             method = net_methods[0]
             self.isequal(method, net_method, 'AddNetworkMethod - isequal')
 
 
-        net_methods = GetNetworkMethods(auth)
+        net_methods = GetNetworkMethods(self.auth)
         if net_methods is not None:
            net_methods = filter(lambda x: x in methods, net_methods)
             self.islistequal(methods, net_methods, 'GetNetworkMethods - isequal')
@@ -585,13 +567,13 @@ class api_unit_test(Test):
         return methods
 
     def DeleteNetworkMethods(self):
-       DeleteNetworkMethod = self.debug(api.DeleteNetworkMethod)
-       GetNetworkMethods = self.debug(api.GetNetworkMethods)   
+       DeleteNetworkMethod = self.debug(self.api.DeleteNetworkMethod)
+       GetNetworkMethods = self.debug(self.api.GetNetworkMethods)      
        for method in self.network_methods:
-           DeleteNetworkMethod(auth, method)
+           DeleteNetworkMethod(self.auth, method)
 
        # check 
-       network_methods = GetNetworkMethods(auth)
+       network_methods = GetNetworkMethods(self.auth)
        network_methods = filter(lambda x: x in self.network_methods, network_methods)
        self.islistequal(network_methods, [], 'DeleteNetworkMethods - check')
 
@@ -601,25 +583,25 @@ class api_unit_test(Test):
 
     def NetworkTypes(self, n=2):
        net_types = []
-        AddNetworkType = self.debug(api.AddNetworkType)
-        GetNetworkTypes = self.debug(api.GetNetworkTypes)
+        AddNetworkType = self.debug(self.api.AddNetworkType)
+        GetNetworkTypes = self.debug(self.api.GetNetworkTypes)
          
         for i in range(n):
             # Add Network Type 
             type = randstr(10)
-            AddNetworkType(auth, type)
+            AddNetworkType(self.auth, type)
       
             # Should return a unique id
             self.isunique(type, net_types, 'AddNetworkType - isunique')
             net_types.append(type)
-            types = GetNetworkTypes(auth)
+            types = GetNetworkTypes(self.auth)
             if types is None: continue
            types = filter(lambda x: x in [type], types)
             if types is None: continue
             net_type = types[0]
             self.isequal(net_type, type, 'AddNetworkType - isequal')
     
-        types = GetNetworkTypes(auth)
+        types = GetNetworkTypes(self.auth)
         if types is not None:
            types = filter(lambda x: x in net_types, types)
             self.islistequal(types, net_types, 'GetNetworkTypes - isequal')
@@ -630,13 +612,13 @@ class api_unit_test(Test):
         return net_types       
 
     def DeleteNetworkTypes(self):      
-        DeleteNetworkType = self.debug(api.DeleteNetworkType)
-        GetNetworkTypes = self.debug(api.GetNetworkTypes)
+        DeleteNetworkType = self.debug(self.api.DeleteNetworkType)
+        GetNetworkTypes = self.debug(self.api.GetNetworkTypes)
         for type in self.network_types:
-            DeleteNetworkType(auth, type)
+            DeleteNetworkType(self.auth, type)
 
         # check 
-        network_types = GetNetworkTypes(auth)
+        network_types = GetNetworkTypes(self.auth)
        network_types = filter(lambda x: x in self.network_types, network_types)
         self.islistequal(network_types, [], 'DeleteNetworkTypes - check')
 
@@ -647,35 +629,35 @@ class api_unit_test(Test):
 
     def NodeGroups(self, n = 4):
        nodegroup_ids = []
-       AddNodeGroup = self.debug(api.AddNodeGroup)
-       UpdateNodeGroup = self.debug(api.UpdateNodeGroup)
-       GetNodeGroups = self.debug(api.GetNodeGroups)
+       AddNodeGroup = self.debug(self.api.AddNodeGroup)
+       UpdateNodeGroup = self.debug(self.api.UpdateNodeGroup)
+       GetNodeGroups = self.debug(self.api.GetNodeGroups)
 
        for i in range(n):
            # Add Nodegroups
            nodegroup_fields = random_nodegroup()
-           nodegroup_id = AddNodeGroup(auth, nodegroup_fields)
+           nodegroup_id = AddNodeGroup(self.auth, nodegroup_fields)
            if nodegroup_id is None: continue
        
            # Should return a unique id
            self.isunique(nodegroup_id, nodegroup_ids, 'AddNodeGroup - isunique')
            nodegroup_ids.append(nodegroup_id)
-           nodegroups = GetNodeGroups(auth, [nodegroup_id])
+           nodegroups = GetNodeGroups(self.auth, [nodegroup_id])
            if nodegroups is None: continue
            nodegroup = nodegroups[0]
            self.isequal(nodegroup, nodegroup_fields, 'AddNodeGroup - isequal')
        
            # Update NodeGroups
            nodegroup_fields = random_nodegroup()
-           UpdateNodeGroup(auth, nodegroup_id, nodegroup_fields)
+           UpdateNodeGroup(self.auth, nodegroup_id, nodegroup_fields)
 
            # Check again
-           nodegroups = GetNodeGroups(auth, [nodegroup_id])
+           nodegroups = GetNodeGroups(self.auth, [nodegroup_id])
            if nodegroups is None: continue
            nodegroup = nodegroups[0]
            self.isequal(nodegroup, nodegroup_fields, 'UpdateNodeGroup - isequal')
 
-       nodegroups = GetNodeGroups(auth, nodegroup_ids)
+       nodegroups = GetNodeGroups(self.auth, nodegroup_ids)
        if nodegroups is not None:
            self.islistequal(nodegroup_ids, [n['nodegroup_id'] for n in nodegroups], 'GetNodeGroups - isequal')
        if self.config.verbose:
@@ -685,14 +667,14 @@ class api_unit_test(Test):
 
     def DeleteNodeGroups(self):
        # Delete all NodeGroups
-       GetNodeGroups = self.debug(api.GetNodeGroups)
-       DeleteNodeGroup = self.debug(api.DeleteNodeGroup)
+       GetNodeGroups = self.debug(self.api.GetNodeGroups)
+       DeleteNodeGroup = self.debug(self.api.DeleteNodeGroup)
        
        for nodegroup_id in self.nodegroup_ids:
-           result = DeleteNodeGroup(auth, nodegroup_id)
+           result = DeleteNodeGroup(self.auth, nodegroup_id)
        
        # Check is nodegroups are deleted
-       nodegroups = GetNodeGroups(auth, self.nodegroup_ids)
+       nodegroups = GetNodeGroups(self.auth, self.nodegroup_ids)
        self.islistequal(nodegroups, [], 'DeleteNodeGroup - check')
        
        if self.config.verbose:
@@ -702,36 +684,36 @@ class api_unit_test(Test):
 
     def PCUTypes(self, n=2):
         pcu_type_ids = []
-       AddPCUType = self.debug(api.AddPCUType)
-       UpdatePCUType = self.debug(api.UpdatePCUType)
-       GetPCUTypes = self.debug(api.GetPCUTypes)
+       AddPCUType = self.debug(self.api.AddPCUType)
+       UpdatePCUType = self.debug(self.api.UpdatePCUType)
+       GetPCUTypes = self.debug(self.api.GetPCUTypes)
  
        for i in range(n):
            # Add PCUType
            pcu_type_fields = random_pcu_type()
-           pcu_type_id = AddPCUType(auth, pcu_type_fields)
+           pcu_type_id = AddPCUType(self.auth, pcu_type_fields)
            if pcu_type_id is None: continue
            # Should return a unique id
            self.isunique(pcu_type_id, pcu_type_ids, 'AddPCUType - isunique')
            pcu_type_ids.append(pcu_type_id)
           
            # Check pcu type
-           pcu_types = GetPCUTypes(auth, [pcu_type_id])
+           pcu_types = GetPCUTypes(self.auth, [pcu_type_id])
            if pcu_types is None: continue
            pcu_type = pcu_types[0]
            self.isequal(pcu_type, pcu_type_fields, 'AddPCUType - isequal')
 
            # Update PCUType
            pcu_type_fields = random_pcu_type()
-            UpdatePCUType(auth, pcu_type_id, pcu_type_fields)
+            UpdatePCUType(self.auth, pcu_type_id, pcu_type_fields)
 
            # Check again
-           pcu_types = GetPCUTypes(auth, [pcu_type_id])
+           pcu_types = GetPCUTypes(self.auth, [pcu_type_id])
            if pcu_types is None: continue
             pcu_type = pcu_types[0]
             self.isequal(pcu_type, pcu_type_fields, 'UpdatePCUType - isequal')
 
-       pcu_types = GetPCUTypes(auth, pcu_type_ids)
+       pcu_types = GetPCUTypes(self.auth, pcu_type_ids)
        if pcu_types is not None:
            self.islistequal(pcu_type_ids, [p['pcu_type_id'] for p in pcu_types], 'GetPCUTypes - check')
 
@@ -740,26 +722,26 @@ class api_unit_test(Test):
        return pcu_type_ids
          
     def DeletePCUTypes(self):
-       GetPCUTypes = self.debug(api.GetPCUTypes)
-       DeletePCUType = self.debug(api.DeletePCUType)
+       GetPCUTypes = self.debug(self.api.GetPCUTypes)
+       DeletePCUType = self.debug(self.api.DeletePCUType)
        
        for pcu_type_id in self.pcu_type_ids:
-           DeletePCUType(auth, pcu_type_id)
+           DeletePCUType(self.auth, pcu_type_id)
        
-       pcu_types = GetPCUTypes(auth, self.pcu_type_ids)
+       pcu_types = GetPCUTypes(self.auth, self.pcu_type_ids)
        self.islistequal(pcu_types, [], 'DeletePCUType - check')  
 
     def PCUProtocolTypes(self, n=2):
        protocol_type_ids = []
-       AddPCUProtocolType = self.debug(api.AddPCUProtocolType)
-       UpdatePCUProtocolType = self.debug(api.UpdatePCUProtocolType)
-       GetPCUProtocolTypes = self.debug(api.GetPCUProtocolTypes)
+       AddPCUProtocolType = self.debug(self.api.AddPCUProtocolType)
+       UpdatePCUProtocolType = self.debug(self.api.UpdatePCUProtocolType)
+       GetPCUProtocolTypes = self.debug(self.api.GetPCUProtocolTypes)
        
        for i in range(n):
            # Add PCUProtocolType
            protocol_type_fields = random_pcu_protocol_type()
            pcu_type_id = random.sample(self.pcu_type_ids, 1)[0]
-           protocol_type_id = AddPCUProtocolType(auth, pcu_type_id, protocol_type_fields)          
+           protocol_type_id = AddPCUProtocolType(self.auth, pcu_type_id, protocol_type_fields)     
            if protocol_type_id is None: continue
            
            # Should return a unique id
@@ -767,22 +749,22 @@ class api_unit_test(Test):
            protocol_type_ids.append(protocol_type_id)
 
            # Check protocol type
-           protocol_types = GetPCUProtocolTypes(auth, [protocol_type_id])
+           protocol_types = GetPCUProtocolTypes(self.auth, [protocol_type_id])
            if protocol_types is None: continue
            protocol_type = protocol_types[0]
            self.isequal(protocol_type, protocol_type_fields, 'AddPCUProtocolType - isequal')
                
            # Update protocol type
            protocol_type_fields = random_pcu_protocol_type()
-           UpdatePCUProtocolType(auth, protocol_type_id, protocol_type_fields)
+           UpdatePCUProtocolType(self.auth, protocol_type_id, protocol_type_fields)
            
            # Check again
-           protocol_types = GetPCUProtocolTypes(auth, [protocol_type_id])
+           protocol_types = GetPCUProtocolTypes(self.auth, [protocol_type_id])
             if protocol_types is None: continue
             protocol_type = protocol_types[0]
             self.isequal(protocol_type, protocol_type_fields, 'UpdatePCUProtocolType - isequal')
 
-       protocol_types = GetPCUProtocolTypes(auth, protocol_type_ids)
+       protocol_types = GetPCUProtocolTypes(self.auth, protocol_type_ids)
        if protocol_types is not None: 
            pt_ids = [p['pcu_protocol_type_id'] for p in protocol_types]
            self.islistequal(protocol_type_ids, pt_ids, 'GetPCUProtocolTypes - isequal')
@@ -793,14 +775,14 @@ class api_unit_test(Test):
        return protocol_type_ids                
 
     def DeletePCUProtocolTypes(self):
-       GetPCUProtocolTypes = self.debug(api.GetPCUProtocolTypes)
-       DeletePCUProtocolType = self.debug(api.DeletePCUProtocolType)
+       GetPCUProtocolTypes = self.debug(self.api.GetPCUProtocolTypes)
+       DeletePCUProtocolType = self.debug(self.api.DeletePCUProtocolType)
        
        for protocol_type_id in self.pcu_protocol_type_ids:
-           DeletePCUProtocolType(auth, protocol_type_id)
+           DeletePCUProtocolType(self.auth, protocol_type_id)
        
        # check 
-       protocol_types = GetPCUProtocolTypes(auth, self.pcu_protocol_type_ids)
+       protocol_types = GetPCUProtocolTypes(self.auth, self.pcu_protocol_type_ids)
        self.islistequal(protocol_types, [], 'DeletePCUProtocolType - check')
        
        if self.config.verbose:
@@ -809,14 +791,14 @@ class api_unit_test(Test):
 
     def PCUs(self, n = 4):
        pcu_ids = []
-       AddPCU = self.debug(api.AddPCU)
-       UpdatePCU = self.debug(api.UpdatePCU)
-       GetPCUs = self.debug(api.GetPCUs)
+       AddPCU = self.debug(self.api.AddPCU)
+       UpdatePCU = self.debug(self.api.UpdatePCU)
+       GetPCUs = self.debug(self.api.GetPCUs)
 
        for site_id in self.site_ids:
            # Add PCU           
            pcu_fields = random_pcu()
-           pcu_id = AddPCU(auth, site_id, pcu_fields)
+           pcu_id = AddPCU(self.auth, site_id, pcu_fields)
            if pcu_id is None: continue
 
            # Should return a unique id
@@ -824,22 +806,22 @@ class api_unit_test(Test):
            pcu_ids.append(pcu_id)
 
            # check PCU
-           pcus = GetPCUs(auth, [pcu_id])
+           pcus = GetPCUs(self.auth, [pcu_id])
            if pcus is None: continue
            pcu = pcus[0]
            self.isequal(pcu, pcu_fields, 'AddPCU - isequal')
        
            # Update PCU
            pcu_fields = random_pcu()
-           UpdatePCU(auth, pcu_id, pcu_fields)
+           UpdatePCU(self.auth, pcu_id, pcu_fields)
        
            # Check again
-           pcus = GetPCUs(auth, [pcu_id])
+           pcus = GetPCUs(self.auth, [pcu_id])
             if pcus is None: continue
             pcu = pcus[0]
             self.isequal(pcu, pcu_fields, 'UpdatePCU - isequal')
 
-       pcus = GetPCUs(auth, pcu_ids)
+       pcus = GetPCUs(self.auth, pcu_ids)
        if pcus is not None:
            self.islistequal(pcu_ids, [p['pcu_id'] for p in pcus], 'GetPCUs - isequal')
 
@@ -849,14 +831,14 @@ class api_unit_test(Test):
        return pcu_ids
        
     def DeletePCUs(self):
-       GetPCUs = self.debug(api.GetPCUs)
-       DeletePCU = self.debug(api.DeletePCU)
+       GetPCUs = self.debug(self.api.GetPCUs)
+       DeletePCU = self.debug(self.api.DeletePCU)
 
        for pcu_id in self.pcu_ids:
-           DeletePCU(auth, pcu_id)
+           DeletePCU(self.auth, pcu_id)
 
        # check 
-       pcus = GetPCUs(auth, self.pcu_ids)
+       pcus = GetPCUs(self.auth, self.pcu_ids)
        self.islistequal(pcus, [], 'DeletePCU - check')
        
        if self.config.verbose:
@@ -865,14 +847,14 @@ class api_unit_test(Test):
  
     def Nodes(self, n=4):
        node_ids = []
-       AddNode = self.debug(api.AddNode)
-       GetNodes = self.debug(api.GetNodes)
-       UpdateNode = self.debug(api.UpdateNode)
+       AddNode = self.debug(self.api.AddNode)
+       GetNodes = self.debug(self.api.GetNodes)
+       UpdateNode = self.debug(self.api.UpdateNode)
        for i in range(n):
            # Add Node
            node_fields = random_node()
            site_id = random.sample(self.site_ids, 1)[0]
-           node_id = AddNode(auth, site_id, node_fields)
+           node_id = AddNode(self.auth, site_id, node_fields)
            if node_id is None: continue
            
            # Should return a unique id
@@ -880,43 +862,43 @@ class api_unit_test(Test):
            node_ids.append(node_id)
 
            # Check nodes
-           nodes = GetNodes(auth, [node_id])
+           nodes = GetNodes(self.auth, [node_id])
            if nodes is None: continue
            node = nodes[0]
            self.isequal(node, node_fields, 'AddNode - isequal')
        
            # Update node
            node_fields = random_node()
-           result = UpdateNode(auth, node_id, node_fields)
+           result = UpdateNode(self.auth, node_id, node_fields)
            
            # Check again
-           nodes = GetNodes(auth, [node_id])
+           nodes = GetNodes(self.auth, [node_id])
            if nodes is None: continue
            node = nodes[0]
            self.isequal(node, node_fields, 'UpdateNode - isequal')
 
            # Add node to nodegroup
            nodegroup_id = random.sample(self.nodegroup_ids, 1)[0]
-           AddNodeToNodeGroup = self.debug(api.AddNodeToNodeGroup)
-           AddNodeToNodeGroup(auth, node_id, nodegroup_id)
+           AddNodeToNodeGroup = self.debug(self.api.AddNodeToNodeGroup)
+           AddNodeToNodeGroup(self.auth, node_id, nodegroup_id)
 
            # Add node to PCU
-           sites = api.GetSites(auth, [node['site_id']], ['pcu_ids'])
+           sites = self.api.GetSites(self.auth, [node['site_id']], ['pcu_ids'])
            if not sites: continue
            site = sites[0]   
            pcu_id = random.sample(site['pcu_ids'], 1)[0]
            port = random.sample(range(65535), 1)[0] 
-           AddNodeToPCU = self.debug(api.AddNodeToPCU)
-           AddNodeToPCU(auth, node_id, pcu_id, port)
+           AddNodeToPCU = self.debug(self.api.AddNodeToPCU)
+           AddNodeToPCU(self.auth, node_id, pcu_id, port)
 
            # check nodegroup, pcu
-           nodes = GetNodes(auth, [node_id], ['nodegroup_ids', 'pcu_ids'])
+           nodes = GetNodes(self.auth, [node_id], ['nodegroup_ids', 'pcu_ids'])
            if nodes is None or not nodes: continue
            node = nodes[0]
            self.islistequal([nodegroup_id], node['nodegroup_ids'], 'AddNodeToNodeGroup - check')
            self.islistequal([pcu_id], node['pcu_ids'], 'AddNodeToPCU - check')                         
        
-       nodes = GetNodes(auth, node_ids)
+       nodes = GetNodes(self.auth, node_ids)
        if nodes is not None:
            self.islistequal(node_ids, [node['node_id'] for node in nodes], 'GetNodes - isequal')
 
@@ -928,37 +910,37 @@ class api_unit_test(Test):
     def DeleteNodes(self):
 
        # Delete attributes manually for first node
-       GetNodes = self.debug(api.GetNodes)
-       nodes = GetNodes(auth, self.node_ids)
+       GetNodes = self.debug(self.api.GetNodes)
+       nodes = GetNodes(self.auth, self.node_ids)
        if nodes is None or not nodes: return 0
        node = nodes[0]
 
        if node['nodegroup_ids']:
            # Delete NodeGroup
            nodegroup_id = random.sample(node['nodegroup_ids'], 1)[0]
-           DeleteNodeFromNodeGroup = self.debug(api.DeleteNodeFromNodeGroup)
-           DeleteNodeFromNodeGroup(auth, node['node_id'], nodegroup_id)
+           DeleteNodeFromNodeGroup = self.debug(self.api.DeleteNodeFromNodeGroup)
+           DeleteNodeFromNodeGroup(self.auth, node['node_id'], nodegroup_id)
 
        if node['pcu_ids']:
            # Delete PCU
            pcu_id = random.sample(node['pcu_ids'], 1)[0]
-           DeleteNodeFromPCU = self.debug(api.DeleteNodeFromPCU)
-           DeleteNodeFromPCU(auth, node['node_id'], pcu_id)
+           DeleteNodeFromPCU = self.debug(self.api.DeleteNodeFromPCU)
+           DeleteNodeFromPCU(self.auth, node['node_id'], pcu_id)
 
        # check nodegroup, pcu
-       nodes = GetNodes(auth, [node['node_id']])
+       nodes = GetNodes(self.auth, [node['node_id']])
        if nodes is None or not nodes: return 0
        self.islistequal([], node['nodegroup_ids'], 'DeleteNodeGromNodeGroup - check')
        self.islistequal([], node['pcu_ids'], 'DeleteNodeFromPCU - check')
 
        # Delete rest of nodes  
-       DeleteNode = self.debug(api.DeleteNode)
+       DeleteNode = self.debug(self.api.DeleteNode)
        for node_id in self.node_ids:
-           result = DeleteNode(auth, node_id)
+           result = DeleteNode(self.auth, node_id)
 
        # Check if nodes are deleted
-       GetNodes = self.debug(api.GetNodes)
-       nodes = GetNodes(auth, self.node_ids)
+       GetNodes = self.debug(self.api.GetNodes)
+       nodes = GetNodes(self.auth, self.node_ids)
        self.islistequal(nodes, [], 'DeleteNode Check')
 
        if self.config.verbose:
@@ -970,8 +952,8 @@ class api_unit_test(Test):
         address_type_ids = []
         for i in range(n):
             address_type_fields = random_address_type()
-           AddAddressType = self.debug(api.AddAddressType)
-            address_type_id = AddAddressType(auth, address_type_fields)
+           AddAddressType = self.debug(self.api.AddAddressType)
+            address_type_id = AddAddressType(self.auth, address_type_fields)
            if address_type_id is None: continue
 
             # Should return a unique address_type_id
@@ -979,26 +961,26 @@ class api_unit_test(Test):
            address_type_ids.append(address_type_id)
 
             # Check address type
-           GetAddressTypes = self.debug(api.GetAddressTypes)
-            address_types = GetAddressTypes(auth, [address_type_id])
+           GetAddressTypes = self.debug(self.api.GetAddressTypes)
+            address_types = GetAddressTypes(self.auth, [address_type_id])
            if address_types is None: continue
            address_type = address_types[0]
            self.isequal(address_type, address_type_fields, 'AddAddressType - isequal')
 
             # Update address type
             address_type_fields = random_address_type()
-           UpdateAddressType = self.debug(api.UpdateAddressType)
-            result = UpdateAddressType(auth, address_type_id, address_type_fields)
+           UpdateAddressType = self.debug(self.api.UpdateAddressType)
+            result = UpdateAddressType(self.auth, address_type_id, address_type_fields)
            if result is None: continue
             
             # Check address type again
-            address_types = GetAddressTypes(auth, [address_type_id])
+            address_types = GetAddressTypes(self.auth, [address_type_id])
            if address_types is None: continue
            address_type = address_types[0]     
            self.isequal(address_type, address_type_fields, 'UpdateAddressType - isequal')      
 
        # Check get all address types
-        address_types = GetAddressTypes(auth, address_type_ids)
+        address_types = GetAddressTypes(self.auth, address_type_ids)
        if address_types is not None:
            self.islistequal(address_type_ids, [address_type['address_type_id'] for address_type in address_types], 'GetAddressTypes - isequal')
 
@@ -1009,12 +991,12 @@ class api_unit_test(Test):
 
     def DeleteAddressTypes(self):
 
-       DeleteAddressType = self.debug(api.DeleteAddressType)
+       DeleteAddressType = self.debug(self.api.DeleteAddressType)
         for address_type_id in self.address_type_ids:
-            DeleteAddressType(auth, address_type_id)
+            DeleteAddressType(self.auth, address_type_id)
 
-       GetAddressTypes = self.debug(api.GetAddressTypes)
-       address_types = GetAddressTypes(auth, self.address_type_ids)
+       GetAddressTypes = self.debug(self.api.GetAddressTypes)
+       address_types = GetAddressTypes(self.auth, self.address_type_ids)
        self.islistequal(address_types, [], 'DeleteAddressType - check')
 
         if self.config.verbose:
@@ -1024,14 +1006,14 @@ class api_unit_test(Test):
 
     def Addresses(self, n = 3):
        address_ids = []
-       AddSiteAddress = self.debug(api.AddSiteAddress)
-       GetAddresses = self.debug(api.GetAddresses)  
-       UpdateAddress = self.debug(api.UpdateAddress)
-        AddAddressTypeToAddress = self.debug(api.AddAddressTypeToAddress)
+       AddSiteAddress = self.debug(self.api.AddSiteAddress)
+       GetAddresses = self.debug(self.api.GetAddresses)  
+       UpdateAddress = self.debug(self.api.UpdateAddress)
+        AddAddressTypeToAddress = self.debug(self.api.AddAddressTypeToAddress)
        for i in range(n):
             address_fields = random_address()
            site_id = random.sample(self.site_ids, 1)[0]        
-            address_id = AddSiteAddress(auth, site_id, address_fields)
+            address_id = AddSiteAddress(self.auth, site_id, address_fields)
            if address_id is None: continue 
        
             # Should return a unique address_id
@@ -1039,32 +1021,32 @@ class api_unit_test(Test):
            address_ids.append(address_id)
 
            # Check address
-           addresses = GetAddresses(auth, [address_id])
+           addresses = GetAddresses(self.auth, [address_id])
            if addresses is None: continue
            address = addresses[0]
            self.isequal(address, address_fields, 'AddSiteAddress - isequal')
            
            # Update address
            address_fields = random_address()
-           result = UpdateAddress(auth, address_id, address_fields)
+           result = UpdateAddress(self.auth, address_id, address_fields)
                
            # Check again
-           addresses = GetAddresses(auth, [address_id])
+           addresses = GetAddresses(self.auth, [address_id])
            if addresses is None: continue
            address = addresses[0]
            self.isequal(address, address_fields, 'UpdateAddress - isequal')
              
            # Add Address Type
            address_type_id = random.sample(self.address_type_ids, 1)[0]
-           AddAddressTypeToAddress(auth, address_type_id, address_id)
+           AddAddressTypeToAddress(self.auth, address_type_id, address_id)
            
            # check adress type
-           addresses = GetAddresses(auth, [address_id], ['address_type_ids'])
+           addresses = GetAddresses(self.auth, [address_id], ['address_type_ids'])
            if addresses is None or not addresses: continue
            address = addresses[0]
            self.islistequal([address_type_id], address['address_type_ids'], 'AddAddressTypeToAddress - check')         
         
-       addresses = GetAddresses(auth, address_ids)
+       addresses = GetAddresses(self.auth, address_ids)
        if addresses is not None:  
            self.islistequal(address_ids, [ad['address_id'] for ad in addresses], 'GetAddresses - isequal')     
         
@@ -1075,31 +1057,31 @@ class api_unit_test(Test):
 
     def DeleteAddresses(self):
 
-       DeleteAddress = self.debug(api.DeleteAddress)
-       DeleteAddressTypeFromAddress = self.debug(api.DeleteAddressTypeFromAddress)
-       GetAddresses = self.debug(api.GetAddresses)
+       DeleteAddress = self.debug(self.api.DeleteAddress)
+       DeleteAddressTypeFromAddress = self.debug(self.api.DeleteAddressTypeFromAddress)
+       GetAddresses = self.debug(self.api.GetAddresses)
         
        # Delete attributes mananually first
-       addresses = GetAddresses(auth, self.address_ids, ['address_id', 'address_type_ids'])
+       addresses = GetAddresses(self.auth, self.address_ids, ['address_id', 'address_type_ids'])
        if addresses is None or not addresses: return 0
        address = addresses[0]
 
        if address['address_type_ids']:
            address_type_id = random.sample(address['address_type_ids'], 1)[0]
-           DeleteAddressTypeFromAddress(auth, address_type_id, address['address_id'])  
+           DeleteAddressTypeFromAddress(self.auth, address_type_id, address['address_id'])  
 
        # check address_type_ids
-       addresses = GetAddresses(auth, [address['address_id']], ['address_type_ids'])
+       addresses = GetAddresses(self.auth, [address['address_id']], ['address_type_ids'])
        if addresses is None or not addresses: return 0
        address = addresses[0]
        self.islistequal([], address['address_type_ids'], 'DeleteAddressTypeFromAddress - check') 
 
        # Delete site addresses
         for address_id in self.address_ids:
-           result = DeleteAddress(auth, address_id)
+           result = DeleteAddress(self.auth, address_id)
        
        # Check 
-       addresses = GetAddresses(auth, self.address_ids)
+       addresses = GetAddresses(self.auth, self.address_ids)
        self.islistequal(addresses, [], 'DeleteAddress - check')
         if self.config.verbose:
             utils.header("Deleted addresses: %s" % self.address_ids)
@@ -1108,13 +1090,13 @@ class api_unit_test(Test):
 
     def SliceAttributeTypes(self, n = 2):
         attribute_type_ids = []
-       AddSliceAttributeType = self.debug(api.AddSliceAttributeType)
-       GetSliceAttributeTypes = self.debug(api.GetSliceAttributeTypes)
-       UpdateSliceAttributeType = self.debug(api.UpdateSliceAttributeType)
+       AddSliceAttributeType = self.debug(self.api.AddSliceAttributeType)
+       GetSliceAttributeTypes = self.debug(self.api.GetSliceAttributeTypes)
+       UpdateSliceAttributeType = self.debug(self.api.UpdateSliceAttributeType)
         
        for i in range(n):
             attribute_type_fields = random_attribute_type()
-            attribute_type_id = AddSliceAttributeType(auth, attribute_type_fields)
+            attribute_type_id = AddSliceAttributeType(self.auth, attribute_type_fields)
             if attribute_type_id is None: continue
 
             # Should return a unique slice_attribute_type_id
@@ -1122,22 +1104,22 @@ class api_unit_test(Test):
             attribute_type_ids.append(attribute_type_id)
 
             # Check slice_attribute_type
-            attribute_types = GetSliceAttributeTypes(auth, [attribute_type_id])
+            attribute_types = GetSliceAttributeTypes(self.auth, [attribute_type_id])
             if attribute_types is None: continue
             attribute_type = attribute_types[0]
             self.isequal(attribute_type, attribute_type_fields, 'AddSliceAttributeType - isequal')
 
             # Update slice_attribute_type
             attribute_type_fields = random_attribute_type()
-            result = UpdateSliceAttributeType(auth, attribute_type_id, attribute_type_fields)
+            result = UpdateSliceAttributeType(self.auth, attribute_type_id, attribute_type_fields)
 
             # Check again
-            attribute_types = GetSliceAttributeTypes(auth, [attribute_type_id])
+            attribute_types = GetSliceAttributeTypes(self.auth, [attribute_type_id])
             if attribute_types is None: continue
             attribute_type = attribute_types[0]
             self.isequal(attribute_type, attribute_type_fields, 'UpdateSliceAttributeType - isequal')
 
-        attribute_types = GetSliceAttributeTypes(auth, attribute_type_ids)
+        attribute_types = GetSliceAttributeTypes(self.auth, attribute_type_ids)
         if attribute_types is not None:
            at_ids = [at['attribute_type_id'] for at in attribute_types] 
             self.islistequal(attribute_type_ids, at_ids, 'GetSliceAttributeTypes - isequal')
@@ -1148,15 +1130,15 @@ class api_unit_test(Test):
         return attribute_type_ids
 
     def DeleteSliceAttributeTypes(self):
-       DeleteSliceAttributeType = self.debug(api.DeleteSliceAttributeType)
-       GetSliceAttributeTypes = self.debug(api.GetSliceAttributeTypes)
+       DeleteSliceAttributeType = self.debug(self.api.DeleteSliceAttributeType)
+       GetSliceAttributeTypes = self.debug(self.api.GetSliceAttributeTypes)
 
         # Delete slice_attribute_type
         for slice_attribute_type_id in self.slice_attribute_type_ids:
-            result = DeleteSliceAttributeType(auth, slice_attribute_type_id)
+            result = DeleteSliceAttributeType(self.auth, slice_attribute_type_id)
 
         # Check 
-        slice_attribute_types = GetSliceAttributeTypes(auth, self.slice_attribute_type_ids)
+        slice_attribute_types = GetSliceAttributeTypes(self.auth, self.slice_attribute_type_ids)
         self.islistequal(slice_attribute_types, [], 'DeleteSliceAttributeTypes - check')
         if self.config.verbose:
             utils.header("Deleted slice_attributes: %s" % self.slice_attribute_type_ids)
@@ -1165,24 +1147,24 @@ class api_unit_test(Test):
 
     def SliceInstantiations(self, n = 2):
        insts = []
-        AddSliceInstantiation= self.debug(api.AddSliceInstantiation)
-        GetSliceInstantiations = self.debug(api.GetSliceInstantiations)
+        AddSliceInstantiation= self.debug(self.api.AddSliceInstantiation)
+        GetSliceInstantiations = self.debug(self.api.GetSliceInstantiations)
 
         for i in range(n):
             inst = randstr(10)
-            result = AddSliceInstantiation(auth, inst)
+            result = AddSliceInstantiation(self.auth, inst)
             if result is None: continue
            insts.append(inst)          
 
             # Check slice instantiaton
-            instantiations = GetSliceInstantiations(auth)
+            instantiations = GetSliceInstantiations(self.auth)
             if instantiations is None: continue
            instantiations = filter(lambda x: x in [inst], instantiations)
             instantiation = instantiations[0]
             self.isequal(instantiation, inst, 'AddSliceInstantiation - isequal')
 
        
-        instantiations = GetSliceInstantiations(auth)
+        instantiations = GetSliceInstantiations(self.auth)
         if instantiations is not None:
            instantiations = filter(lambda x: x in insts, instantiations)
             self.islistequal(insts, instantiations, 'GetSliceInstantiations - isequal')
@@ -1193,14 +1175,14 @@ class api_unit_test(Test):
         return insts
        
     def DeleteSliceInstantiations(self):
-       DeleteSliceInstantiation = self.debug(api.DeleteSliceInstantiation)
-       GetSliceInstantiations = self.debug(api.GetSliceInstantiations)
+       DeleteSliceInstantiation = self.debug(self.api.DeleteSliceInstantiation)
+       GetSliceInstantiations = self.debug(self.api.GetSliceInstantiations)
         # Delete slice instantiation
         for instantiation  in self.slice_instantiations:
-            result = DeleteSliceInstantiation(auth, instantiation)
+            result = DeleteSliceInstantiation(self.auth, instantiation)
 
         # Check 
-        instantiations = GetSliceInstantiations(auth)
+        instantiations = GetSliceInstantiations(self.auth)
        instantiations = filter(lambda x: x in self.slice_instantiations, instantiations)
         self.islistequal(instantiations, [], 'DeleteSliceInstantiation - check')
         if self.config.verbose:
@@ -1210,45 +1192,45 @@ class api_unit_test(Test):
 
     def Slices(self, n = 3):
        slice_ids = []
-        AddSlice = self.debug(api.AddSlice)
-        GetSlices = self.debug(api.GetSlices)
-        UpdateSlice = self.debug(api.UpdateSlice)
-       AddSliceToNodes = self.debug(api.AddSliceToNodes)
+        AddSlice = self.debug(self.api.AddSlice)
+        GetSlices = self.debug(self.api.GetSlices)
+        UpdateSlice = self.debug(self.api.UpdateSlice)
+       AddSliceToNodes = self.debug(self.api.AddSliceToNodes)
         for i in range(n):
             # Add Site
             slice_fields = random_slice()
-            slice_id = AddSlice(auth, slice_fields)
+            slice_id = AddSlice(self.auth, slice_fields)
             if slice_id is None: continue
 
             # Should return a unique id
             self.isunique(slice_id, slice_ids, 'AddSlicel - isunique')
             slice_ids.append(slice_id)
-            slices = GetSlices(auth, [slice_id])
+            slices = GetSlices(self.auth, [slice_id])
             if slices is None: continue
             slice = slices[0]
             self.isequal(slice, slice_fields, 'AddSlice - isequal')
 
             # Update slice
             slice_fields = random_slice()
-            result = UpdateSlice(auth, slice_id, slice_fields)
+            result = UpdateSlice(self.auth, slice_id, slice_fields)
 
             # Check again
-            slices = GetSlices(auth, [slice_id])
+            slices = GetSlices(self.auth, [slice_id])
             if slices is None: continue
             slice = slices[0]
             self.isequal(slice, slice_fields, 'UpdateSlice - isequal')
 
            # Add node
            node_id = random.sample(self.node_ids, 1)[0]
-           AddSliceToNodes(auth, slice_id, [node_id])
+           AddSliceToNodes(self.auth, slice_id, [node_id])
        
            # check node
-           slices = GetSlices(auth, [slice_id], ['node_ids'])
+           slices = GetSlices(self.auth, [slice_id], ['node_ids'])
            if slices is None or not slices: continue
            slice = slices[0]
            self.islistequal([node_id], slice['node_ids'], 'AddSliceToNode - check')            
 
-        slices = GetSlices(auth, slice_ids)
+        slices = GetSlices(self.auth, slice_ids)
         if slices is not None:
             self.islistequal(slice_ids, [slice['slice_id'] for slice in slices], 'GetSlices - isequal')
 
@@ -1259,22 +1241,22 @@ class api_unit_test(Test):
 
     def DeleteSlices(self):
        
-       GetSlices = self.debug(api.GetSlices)
-       DeleteSlice = self.debug(api.DeleteSlice)
-       DeleteSliceFromNodes = self.debug(api.DeleteSliceFromNodes)     
+       GetSlices = self.debug(self.api.GetSlices)
+       DeleteSlice = self.debug(self.api.DeleteSlice)
+       DeleteSliceFromNodes = self.debug(self.api.DeleteSliceFromNodes)        
 
        # manually delete attributes for first slice
-       slices = GetSlices(auth, self.slice_ids, ['slice_id', 'node_ids'])
+       slices = GetSlices(self.auth, self.slice_ids, ['slice_id', 'node_ids'])
        if slices is None or not slices: return 0
        slice = slices[0]
        
        if slice['node_ids']:
            # Delete node from slice
            node_id = random.sample(slice['node_ids'], 1)[0]
-           DeleteSliceFromNodes(slice['slice_id'], [node_id])
+           DeleteSliceFromNodes(self.auth, slice['slice_id'], [node_id])
        
        # Check node_ids
-       slices = GetSlices(auth, [slice['slice_id']], ['node_ids'])
+       slices = GetSlices(self.auth, [slice['slice_id']], ['node_ids'])
        if slices is None or not slices: return 0
        slice = slices[0]
        self.islistequal([], slice['node_ids'], 'DeleteSliceFromNode - check')   
@@ -1282,11 +1264,11 @@ class api_unit_test(Test):
         # Have DeleteSlice automatically delete attriubtes for the rest 
         for slice_id in self.slice_ids:
             # Delete account
-            DeleteSlice(auth, slice_id)
+            DeleteSlice(self.auth, slice_id)
 
         # Check if slices are deleted
-        GetSlices = self.debug(api.GetSlices)
-        slices = GetSlices(auth, self.slice_ids)
+        GetSlices = self.debug(self.api.GetSlices)
+        slices = GetSlices(self.auth, self.slice_ids)
         self.islistequal(slices, [], 'DeleteSlice - check')
 
         if self.config.verbose:
@@ -1296,9 +1278,9 @@ class api_unit_test(Test):
 
     def SliceAttributes(self, n = 4):
        attribute_ids = []
-       AddSliceAttribute = self.debug(api.AddSliceAttribute)
-       GetSliceAttributes = self.debug(api.GetSliceAttributes)
-       UpdateSliceAttribute = self.debug(api.UpdateSliceAttribute)
+       AddSliceAttribute = self.debug(self.api.AddSliceAttribute)
+       GetSliceAttributes = self.debug(self.api.GetSliceAttributes)
+       UpdateSliceAttribute = self.debug(self.api.UpdateSliceAttribute)
 
         for i in range(n):
             # Add slice attribute
@@ -1306,7 +1288,7 @@ class api_unit_test(Test):
             slice_id = random.sample(self.slice_ids, 1)[0]
            type = attribute_fields['attribute_type_id']
            value = attribute_fields['value']   
-            attribute_id = AddSliceAttribute(auth, slice_id, type, value)
+            attribute_id = AddSliceAttribute(self.auth, slice_id, type, value)
             if attribute_id is None: continue
 
             # Should return a unique id
@@ -1314,7 +1296,7 @@ class api_unit_test(Test):
             attribute_ids.append(attribute_id)
 
             # Check attribute
-            attributes = GetSliceAttributes(auth, [attribute_id])
+            attributes = GetSliceAttributes(self.auth, [attribute_id])
             if attributes is None: continue
             attribute = attributes[0]
             self.isequal(attribute, attribute_fields, 'AddSliceAttribute - isequal')
@@ -1323,15 +1305,15 @@ class api_unit_test(Test):
             attribute_fields = random_slice_attribute()
            type = attribute_fields['attribute_type_id']
             value = attribute_fields['value']  
-            result = UpdateSliceAttribute(auth, attribute_id, value)
+            result = UpdateSliceAttribute(self.auth, attribute_id, value)
 
             # Check again
-            attributes = GetSliceAttributes(auth, [attribute_id])
+            attributes = GetSliceAttributes(self.auth, [attribute_id])
             if attributes is None: continue
             attribute = attributes[0]
             self.isequal(attribute, attribute_fields, 'UpdateSliceAttribute - isequal')
 
-       attributes = GetSliceAttributes(auth, attribute_ids)
+       attributes = GetSliceAttributes(self.auth, attribute_ids)
        if attributes is not None:
            attr_ids = [a['slice_attribute_id'] for a in attributes]
            self.islistequal(attribute_ids, attr_ids, 'GetSliceAttributes - isequal')
@@ -1341,13 +1323,13 @@ class api_unit_test(Test):
        return attribute_ids 
 
     def DeleteSliceAttributes(self):
-       DeleteSliceAttribute = self.debug(api.DeleteSliceAttribute)
-        GetSliceAttributes = self.debug(api.GetSliceAttributes)
+       DeleteSliceAttribute = self.debug(self.api.DeleteSliceAttribute)
+        GetSliceAttributes = self.debug(self.api.GetSliceAttributes)
 
         for attribute_id in self.slice_attribute_ids:
-            DeleteSliceAttribute(auth, attribute_id)
+            DeleteSliceAttribute(self.auth, attribute_id)
 
-        attributes = GetSliceAttributes(auth, self.slice_attribute_ids)
+        attributes = GetSliceAttributes(self.auth, self.slice_attribute_ids)
         self.islistequal(attributes, [], 'DeleteSliceAttribute - check')
 
         if self.config.verbose:
@@ -1357,33 +1339,33 @@ class api_unit_test(Test):
 
     def InitScripts(self, n = 2):
         initscript_ids = []
-        AddInitScript = self.debug(api.AddInitScript)
-        GetInitScripts = self.debug(api.GetInitScripts)
-        UpdateInitScript = self.debug(api.UpdateInitScript)
+        AddInitScript = self.debug(self.api.AddInitScript)
+        GetInitScripts = self.debug(self.api.GetInitScripts)
+        UpdateInitScript = self.debug(self.api.UpdateInitScript)
         for i in range(n):
             # Add Peer
             initscript_fields = random_initscript()
-            initscript_id = AddInitScript(auth, initscript_fields)
+            initscript_id = AddInitScript(self.auth, initscript_fields)
 
             # Should return a unique id
             self.isunique(initscript_id, initscript_ids, 'AddInitScript - isunique')
             initscript_ids.append(initscript_id)
-            initscripts = GetInitScripts(auth, [initscript_id])
+            initscripts = GetInitScripts(self.auth, [initscript_id])
             if initscripts is None: continue
             initscript = initscripts[0]
             self.isequal(initscript, initscript_fields, 'AddInitScript - isequal')
 
             # Update Peer
             initscript_fields = random_initscript()
-            result = UpdateInitScript(auth, initscript_id, initscript_fields)
+            result = UpdateInitScript(self.auth, initscript_id, initscript_fields)
 
             # Check again
-            initscripts = GetInitScripts(auth, [initscript_id])
+            initscripts = GetInitScripts(self.auth, [initscript_id])
             if initscripts is None: continue
             initscript = initscripts[0]
             self.isequal(initscript, initscript_fields, 'UpdateInitScript - isequal')
 
-        initscripts = GetInitScripts(auth, initscript_ids)
+        initscripts = GetInitScripts(self.auth, initscript_ids)
         if initscripts is not None:
             self.islistequal(initscript_ids, [i['initscript_id'] for i in initscripts], 'GetInitScripts -isequal')
 
@@ -1394,13 +1376,13 @@ class api_unit_test(Test):
 
     def DeleteInitScripts(self):
        # Delete all initscripts
-        DeleteInitScript = self.debug(api.DeleteInitScript)
-        GetInitScripts = self.debug(api.GetInitScripts)
+        DeleteInitScript = self.debug(self.api.DeleteInitScript)
+        GetInitScripts = self.debug(self.api.GetInitScripts)
         for initscript_id in self.initscript_ids:
-            result = DeleteInitScript(auth, initscript_id)
+            result = DeleteInitScript(self.auth, initscript_id)
 
         # Check if peers are deleted
-        initscripts = GetInitScripts(auth, self.initscript_ids)
+        initscripts = GetInitScripts(self.auth, self.initscript_ids)
         self.islistequal(initscripts, [], 'DeletInitScript - check')
 
         if self.config.verbose:
@@ -1409,25 +1391,25 @@ class api_unit_test(Test):
 
     def Roles(self, n = 2):
        role_ids = []
-        AddRole = self.debug(api.AddRole)
-        GetRoles = self.debug(api.GetRoles)
+        AddRole = self.debug(self.api.AddRole)
+        GetRoles = self.debug(self.api.GetRoles)
         for i in range(n):
             # Add Role
             role_fields = random_role()
            role_id = role_fields['role_id']
            name = role_fields['name']
-            AddRole(auth, role_id, name)
+            AddRole(self.auth, role_id, name)
 
             # Should return a unique id
             self.isunique(role_id, role_ids, 'AddRole - isunique')
             role_ids.append(role_id)
-            roles = GetRoles(auth)
+            roles = GetRoles(self.auth)
             if roles is None: continue
             roles = filter(lambda x: x['role_id'] in [role_id], roles)
            role = roles[0]
             self.isequal(role, role_fields, 'AddRole - isequal')
 
-        roles = GetRoles(auth)
+        roles = GetRoles(self.auth)
         if roles is not None:
            roles = filter(lambda x: x['role_id'] in role_ids, roles) 
             self.islistequal(role_ids, [r['role_id'] for r in roles], 'GetRoles - isequal')
@@ -1439,13 +1421,13 @@ class api_unit_test(Test):
 
     def DeleteRoles(self):
        # Delete all roles
-        DeleteRole = self.debug(api.DeleteRole)
-        GetRoles = self.debug(api.GetRoles)
+        DeleteRole = self.debug(self.api.DeleteRole)
+        GetRoles = self.debug(self.api.GetRoles)
         for role_id in self.role_ids:
-            result = DeleteRole(auth, role_id)
+            result = DeleteRole(self.auth, role_id)
 
         # Check if peers are deleted
-        roles = GetRoles(auth)
+        roles = GetRoles(self.auth)
        roles = filter(lambda x: x['role_id'] in self.role_ids, roles) 
         self.islistequal(roles, [], 'DeleteRole - check' % self.role_ids)
 
@@ -1460,15 +1442,15 @@ class api_unit_test(Test):
 
             # Add account
             person_fields = random_person()
-           AddPerson = self.debug(api.AddPerson)
-            person_id = AddPerson(auth, person_fields)
+           AddPerson = self.debug(self.api.AddPerson)
+            person_id = AddPerson(self.auth, person_fields)
            if person_id is None: continue
        
             # Should return a unique person_id
             self.isunique(person_id, person_ids, 'AddPerson - isunique')
            person_ids.append(person_id)
-           GetPersons = self.debug(api.GetPersons)
-           persons = GetPersons(auth, [person_id])
+           GetPersons = self.debug(self.api.GetPersons)
+           persons = GetPersons(self.auth, [person_id])
            if persons is None: continue
            person = persons[0]
            self.isequal(person, person_fields, 'AddPerson - isequal')
@@ -1476,31 +1458,31 @@ class api_unit_test(Test):
             # Update account
             person_fields = random_person()
            person_fields['enabled'] = True
-           UpdatePerson = self.debug(api.UpdatePerson)
-            result = UpdatePerson(auth, person_id, person_fields)
+           UpdatePerson = self.debug(self.api.UpdatePerson)
+            result = UpdatePerson(self.auth, person_id, person_fields)
        
             # Add random role 
-           AddRoleToPerson = self.debug(api.AddRoleToPerson)   
+           AddRoleToPerson = self.debug(self.api.AddRoleToPerson)      
             role = random.sample(roles, 1)[0]
-            result = AddRoleToPerson(auth, role, person_id)
+            result = AddRoleToPerson(self.auth, role, person_id)
 
            # Add key to person
            key = random_key()
-           key_id = AddPersonKey = self.debug(api.AddPersonKey)
-           AddPersonKey(auth, person_id, key)
+           key_id = AddPersonKey = self.debug(self.api.AddPersonKey)
+           AddPersonKey(self.auth, person_id, key)
        
            # Add person to site
            site_id = random.sample(self.site_ids, 1)[0]
-           AddPersonToSite = self.debug(api.AddPersonToSite)
-           AddPersonToSite(auth, person_id, site_id)    
+           AddPersonToSite = self.debug(self.api.AddPersonToSite)
+           AddPersonToSite(self.auth, person_id, site_id)       
        
            # Add person to slice
            slice_id = random.sample(self.slice_ids, 1)[0]
-           AddPersonToSlice = self.debug(api.AddPersonToSlice)
-           AddPersonToSlice(auth, person_id, slice_id)
+           AddPersonToSlice = self.debug(self.api.AddPersonToSlice)
+           AddPersonToSlice(self.auth, person_id, slice_id)
 
            # check role, key, site, slice
-           persons = GetPersons(auth, [person_id], ['roles', 'key_ids', 'site_ids', 'slice_ids'])
+           persons = GetPersons(self.auth, [person_id], ['roles', 'key_ids', 'site_ids', 'slice_ids'])
            if persons is None or not persons: continue
            person = persons[0]
            self.islistequal([role], person['roles'], 'AddRoleToPerson - check')
@@ -1508,7 +1490,7 @@ class api_unit_test(Test):
            self.islistequal([site_id], person['site_ids'], 'AddPersonToSite - check')
            self.islistequal([slice_id], person['slice_ids'], 'AddPersonToSlice - check')
 
-       persons = GetPersons(auth, person_ids)
+       persons = GetPersons(self.auth, person_ids)
        if persons is not None:
            self.islistequal(person_ids, [p['person_id'] for p in persons], 'GetPersons - isequal')
 
@@ -1520,37 +1502,37 @@ class api_unit_test(Test):
     def DeletePersons(self):
         
        # Delete attributes manually for first person
-       GetPersons = self.debug(api.GetPersons)
-       persons = GetPersons(auth, self.person_ids, ['person_id' , 'key_ids', 'site_ids', 'slice_ids', 'roles'])
+       GetPersons = self.debug(self.api.GetPersons)
+       persons = GetPersons(self.auth, self.person_ids, ['person_id' , 'key_ids', 'site_ids', 'slice_ids', 'roles'])
        if persons is None or not persons: return 0
        person = persons[0]
 
        if person['roles']:        
            # Delete role
            role = random.sample(person['roles'], 1)[0]
-            DeleteRoleFromPerson = self.debug(api.DeleteRoleFromPerson)
-            DeleteRoleFromPerson(auth, role, person['person_id'])
+            DeleteRoleFromPerson = self.debug(self.api.DeleteRoleFromPerson)
+            DeleteRoleFromPerson(self.auth, role, person['person_id'])
 
        if person['key_ids']:
             # Delete key
            key_id = random.sample(person['key_ids'], 1)[0] 
-            DeleteKey = self.debug(api.DeleteKey)
-            DeleteKey(auth, key_id)
+            DeleteKey = self.debug(self.api.DeleteKey)
+            DeleteKey(self.auth, key_id)
        
        if person['site_ids']:
             # Remove person from site
            site_id = random.sample(person['site_ids'], 1)[0]
-            DeletePersonFromSite = self.debug(api.DeletePersonFromSite)
-            DeletePersonFromSite(auth, person['person_id'], site_id)
+            DeletePersonFromSite = self.debug(self.api.DeletePersonFromSite)
+            DeletePersonFromSite(self.auth, person['person_id'], site_id)
 
        if person['slice_ids']:
             # Remove person from slice
            slice_id = random.sample(person['slice_ids'], 1)[0]
-            DeletePersonFromSlice = self.debug(api.DeletePersonFromSlice)
-            DeletePersonFromSlice(auth, person['person_id'], slice_id)
+            DeletePersonFromSlice = self.debug(self.api.DeletePersonFromSlice)
+            DeletePersonFromSlice(self.auth, person['person_id'], slice_id)
 
         # check role, key, site, slice
-        persons = GetPersons(auth, [person['person_id']], ['roles', 'key_ids', 'site_ids', 'slice_ids'])
+        persons = GetPersons(self.auth, [person['person_id']], ['roles', 'key_ids', 'site_ids', 'slice_ids'])
         if persons is None or not persons: return 0
         person = persons[0]
         self.islistequal([], person['roles'], 'DeleteRoleFromPerson - check')
@@ -1558,15 +1540,15 @@ class api_unit_test(Test):
         self.islistequal([], person['site_ids'], 'DeletePersonFromSite - check')
         self.islistequal([], person['slice_ids'], 'DeletePersonFromSlice - check')
        
-       DeletePerson = self.debug(api.DeletePerson)
+       DeletePerson = self.debug(self.api.DeletePerson)
         # Have DeletePeson automatically delete attriubtes for all other persons 
         for person_id in self.person_ids:
             # Delete account
-            DeletePerson(auth, person_id)
+            DeletePerson(self.auth, person_id)
 
         # Check if persons are deleted
-       GetPersons = self.debug(api.GetPersons)
-       persons = GetPersons(auth, self.person_ids)
+       GetPersons = self.debug(self.api.GetPersons)
+       persons = GetPersons(self.auth, self.person_ids)
        self.islistequal(persons, [], 'DeletePerson - check')
  
        if self.config.verbose:
@@ -1576,24 +1558,24 @@ class api_unit_test(Test):
 
     def KeyTypes(self, n = 2):
        key_types = []
-        AddKeyType = self.debug(api.AddKeyType)
-        GetKeyTypes = self.debug(api.GetKeyTypes)
+        AddKeyType = self.debug(self.api.AddKeyType)
+        GetKeyTypes = self.debug(self.api.GetKeyTypes)
         for i in range(n):
             # Add key type
             keytype = randstr(10)
-            result = AddKeyType(auth, keytype)
+            result = AddKeyType(self.auth, keytype)
             if result is None: continue
 
             # Check key types
             key_types.append(keytype)
-            keytypes  = GetKeyTypes(auth)
+            keytypes  = GetKeyTypes(self.auth)
             if not keytypes: continue
             keytypes = filter(lambda x: x in [keytype], keytypes)
             if not keytypes: continue
             self.isequal(keytype, keytypes[0], 'AddKeyType - isequal')
 
         # Check all
-        keytypes = GetKeyTypes(auth)
+        keytypes = GetKeyTypes(self.auth)
         if keytypes is not None:
             keytypes = filter(lambda x: x in key_types, keytypes)
             self.islistequal(key_types, keytypes, 'GetKeyTypes - isequal')
@@ -1604,13 +1586,13 @@ class api_unit_test(Test):
         return key_types
 
     def DeleteKeyTypes(self):
-       DeleteKeyType = self.debug(api.DeleteKeyType)
-        GetKeyTypes = self.debug(api.GetKeyTypes)
+       DeleteKeyType = self.debug(self.api.DeleteKeyType)
+        GetKeyTypes = self.debug(self.api.GetKeyTypes)
         for key_type in self.key_types:
-            result = DeleteKeyType(auth, key_type)
+            result = DeleteKeyType(self.auth, key_type)
 
         # Check if key types are deleted
-        key_types = GetKeyTypes(auth)
+        key_types = GetKeyTypes(self.auth)
        key_types = filter(lambda x: x in self.key_types, key_types)
         self.islistequal(key_types, [], 'DeleteKeyType - check')
 
@@ -1625,30 +1607,30 @@ class api_unit_test(Test):
            # Add a key to an account
            key_fields = random_key()
            person_id = random.sample(self.person_ids, 1)[0]
-           AddPersonKey = self.debug(api.AddPersonKey)
-           key_id = AddPersonKey(auth, person_id, key_fields)   
+           AddPersonKey = self.debug(self.api.AddPersonKey)
+           key_id = AddPersonKey(self.auth, person_id, key_fields)   
            if key_id is None: continue
                
            # Should return a unique key_id
            self.isunique(key_id, key_ids, 'AddPersonKey - isunique')
            key_ids.append(key_id)
-           GetKeys = self.debug(api.GetKeys)
-           keys = GetKeys(auth, [key_id])
+           GetKeys = self.debug(self.api.GetKeys)
+           keys = GetKeys(self.auth, [key_id])
            if keys is None: continue
            key = keys[0]
            self.isequal(key, key_fields, 'AddPersonKey - isequal')
            
            # Update Key
            key_fields = random_key()
-           UpdateKey = self.debug(api.UpdateKey)
-           result = UpdateKey(auth, key_id, key_fields)
+           UpdateKey = self.debug(self.api.UpdateKey)
+           result = UpdateKey(self.auth, key_id, key_fields)
            
-           keys = GetKeys(auth, [key_id])
+           keys = GetKeys(self.auth, [key_id])
            if keys is None or not keys: continue                
            key = keys[0]
            self.isequal(key, key_fields, 'UpdatePersonKey - isequal')
            
-       keys = GetKeys(auth, key_ids)
+       keys = GetKeys(self.auth, key_ids)
        if keys is not None:
            self.islistequal(key_ids, [key['key_id'] for key in keys], 'GetKeys - isequal')
        
@@ -1660,22 +1642,22 @@ class api_unit_test(Test):
     def DeleteKeys(self):
        
        # Blacklist first key, Delete rest
-       GetKeys = self.debug(api.GetKeys)
-       DeleteKey = self.debug(api.DeleteKey)
-       BlacklistKey = self.debug(api.BlacklistKey)
+       GetKeys = self.debug(self.api.GetKeys)
+       DeleteKey = self.debug(self.api.DeleteKey)
+       BlacklistKey = self.debug(self.api.BlacklistKey)
        
        key_id = self.key_ids.pop()
-       BlacklistKey(auth, key_id)  
-       keys = GetKeys(auth, [key_id])
+       BlacklistKey(self.auth, key_id)  
+       keys = GetKeys(self.auth, [key_id])
        self.islistequal(keys, [], 'BlacklistKey - check')
        
        if self.config.verbose:
            utils.header("Blacklisted key: %s" % key_id)
 
        for key_id in self.key_ids:
-           DeleteKey(auth, key_id)
+           DeleteKey(self.auth, key_id)
        
-       keys = GetKeys(auth, self.key_ids)
+       keys = GetKeys(self.auth, self.key_ids)
        self.islistequal(keys, [], 'DeleteKey - check')
        
        if self.config.verbose:
@@ -1685,17 +1667,17 @@ class api_unit_test(Test):
 
     def BootStates(self, n = 3):
        boot_states = []
-       AddBootState = self.debug(api.AddBootState)
-       GetBootStates = self.debug(api.GetBootStates)
+       AddBootState = self.debug(self.api.AddBootState)
+       GetBootStates = self.debug(self.api.GetBootStates)
        for i in range(n):
            # Add boot state
            bootstate_fields = randstr(10)
-           result = AddBootState(auth, bootstate_fields)
+           result = AddBootState(self.auth, bootstate_fields)
            if result is None: continue
        
            # Check boot states
            boot_states.append(bootstate_fields)      
-           bootstates = GetBootStates(auth)
+           bootstates = GetBootStates(self.auth)
            if not bootstates: continue
            bootstates = filter(lambda x: x in [bootstate_fields], bootstates)
            if not bootstates: continue
@@ -1703,7 +1685,7 @@ class api_unit_test(Test):
            self.isequal(bootstate, bootstate_fields, 'AddBootState - isequal')
                
        # Check all
-       bs = GetBootStates(auth)
+       bs = GetBootStates(self.auth)
        if bs is not None:
            bs = filter(lambda x: x in [boot_states], bs)
            self.islistequal(boot_states, bs, 'GetBootStates - isequal')
@@ -1714,13 +1696,13 @@ class api_unit_test(Test):
        return boot_states
 
     def DeleteBootStates(self):
-       DeleteBootState = self.debug(api.DeleteBootState)
-       GetBootStates = self.debug(api.GetBootStates)
+       DeleteBootState = self.debug(self.api.DeleteBootState)
+       GetBootStates = self.debug(self.api.GetBootStates)
        for boot_state in self.boot_states:
-           result = DeleteBootState(auth, boot_state)
+           result = DeleteBootState(self.auth, boot_state)
        
        # Check if bootsates are deleted
-       boot_states = GetBootStates(auth)
+       boot_states = GetBootStates(self.auth)
        boot_states = filter(lambda x: x in self.boot_states, boot_states)
        self.islistequal(boot_states, [], 'DeleteBootState check')
        
@@ -1732,33 +1714,33 @@ class api_unit_test(Test):
         
     def Peers(self, n = 2):
        peer_ids = []
-       AddPeer = self.debug(api.AddPeer)
-       GetPeers = self.debug(api.GetPeers)
-       UpdatePeer = self.debug(api.UpdatePeer)
+       AddPeer = self.debug(self.api.AddPeer)
+       GetPeers = self.debug(self.api.GetPeers)
+       UpdatePeer = self.debug(self.api.UpdatePeer)
        for i in range(n):
            # Add Peer
            peer_fields = random_peer()
-           peer_id = AddPeer(auth, peer_fields)
+           peer_id = AddPeer(self.auth, peer_fields)
        
            # Should return a unique id
            self.isunique(peer_id, peer_ids, 'AddPeer - isunique')
            peer_ids.append(peer_id)
-           peers = GetPeers(auth, [peer_id])
+           peers = GetPeers(self.auth, [peer_id])
            if peers is None: continue
            peer = peers[0]
            self.isequal(peer, peer_fields, 'AddPeer - isequal')
            
            # Update Peer
            peer_fields = random_peer()
-           result = UpdatePeer(auth, peer_id, peer_fields)
+           result = UpdatePeer(self.auth, peer_id, peer_fields)
            
            # Check again
-           peers = GetPeers(auth, [peer_id])
+           peers = GetPeers(self.auth, [peer_id])
            if peers is None: continue
            peer = peers[0]
            self.isequal(peer, peer_fields, 'UpdatePeer - isequal')
 
-       peers = GetPeers(auth, peer_ids)
+       peers = GetPeers(self.auth, peer_ids)
        if peers is not None:
            self.islistequal(peer_ids, [peer['peer_id'] for peer in peers], 'GetPeers -isequal')
        
@@ -1770,13 +1752,13 @@ class api_unit_test(Test):
 
     def DeletePeers(self):
        # Delete all peers
-       DeletePeer = self.debug(api.DeletePeer)
-       GetPeers = self.debug(api.GetPeers)
+       DeletePeer = self.debug(self.api.DeletePeer)
+       GetPeers = self.debug(self.api.GetPeers)
        for peer_id in self.peer_ids:
-           result = DeletePeer(auth, peer_id)
+           result = DeletePeer(self.auth, peer_id)
        
        # Check if peers are deleted
-       peers = GetPeers(auth, self.peer_ids)
+       peers = GetPeers(self.auth, self.peer_ids)
        self.islistequal(peers, [], 'DeletePeer - check' % self.peer_ids)
        
        if self.config.verbose:
@@ -1788,8 +1770,8 @@ class api_unit_test(Test):
        for i in range(n):
            # Add ConfFile
            conf_file_fields = random_conf_file()
-           AddConfFile = self.debug(api.AddConfFile)
-           conf_file_id = AddConfFile(auth, conf_file_fields)
+           AddConfFile = self.debug(self.api.AddConfFile)
+           conf_file_id = AddConfFile(self.auth, conf_file_fields)
            if conf_file_id is None: continue
        
            # Should return a unique id
@@ -1797,19 +1779,19 @@ class api_unit_test(Test):
            conf_file_ids.append(conf_file_id)
            
            # Get ConfFiles
-           GetConfFiles = self.debug(api.GetConfFiles)
-           conf_files = GetConfFiles(auth, [conf_file_id])
+           GetConfFiles = self.debug(self.api.GetConfFiles)
+           conf_files = GetConfFiles(self.auth, [conf_file_id])
            if conf_files is None: continue
            conf_file = conf_files[0]
            self.isequal(conf_file, conf_file_fields, 'AddConfFile - isunique')
            
            # Update ConfFile
            conf_file_fields = random_conf_file()
-           UpdateConfFile = self.debug(api.UpdateConfFile)
-           result = UpdateConfFile(auth, conf_file_id, conf_file_fields)
+           UpdateConfFile = self.debug(self.api.UpdateConfFile)
+           result = UpdateConfFile(self.auth, conf_file_id, conf_file_fields)
           
            # Check again
-           conf_files = GetConfFiles(auth, [conf_file_id])
+           conf_files = GetConfFiles(self.auth, [conf_file_id])
             if conf_files is None: continue
             conf_file = conf_files[0]
             self.isequal(conf_file, conf_file_fields, 'UpdateConfFile - isunique')
@@ -1817,16 +1799,16 @@ class api_unit_test(Test):
 
            # Add this conf file to a random node
            node_id = random.sample(self.node_ids, 1)[0]
-           AddConfFileToNode = self.debug(api.AddConfFileToNode)
-           AddConfFileToNode(auth, conf_file_id, node_id)
+           AddConfFileToNode = self.debug(self.api.AddConfFileToNode)
+           AddConfFileToNode(self.auth, conf_file_id, node_id)
 
            # Add this conf file to a random node group
            nodegroup_id = random.sample(self.nodegroup_ids, 1)[0]
-           AddConfFileToNodeGroup = self.debug(api.AddConfFileToNodeGroup)
-           AddConfFileToNodeGroup(auth, conf_file_id, nodegroup_id)
+           AddConfFileToNodeGroup = self.debug(self.api.AddConfFileToNodeGroup)
+           AddConfFileToNodeGroup(self.auth, conf_file_id, nodegroup_id)
 
            # Check node, nodegroup
-           conf_files = GetConfFiles(auth, [conf_file_id], ['node_ids', 'nodegroup_ids'])
+           conf_files = GetConfFiles(self.auth, [conf_file_id], ['node_ids', 'nodegroup_ids'])
            if conf_files is None or not conf_files: continue
            conf_file = conf_files[0]
            self.islistequal([node_id], conf_file['node_ids'], 'AddConfFileToNode - check')
@@ -1834,7 +1816,7 @@ class api_unit_test(Test):
        
 
 
-       conf_files = GetConfFiles(auth, conf_file_ids)
+       conf_files = GetConfFiles(self.auth, conf_file_ids)
        if conf_files is not None:
            self.islistequal(conf_file_ids, [c['conf_file_id'] for c in conf_files], 'GetConfFiles - isequal')
        if self.config.verbose:
@@ -1844,33 +1826,33 @@ class api_unit_test(Test):
 
     def DeleteConfFiles(self):
        
-           GetConfFiles = self.debug(api.GetConfFiles)
-           DeleteConfFile = self.debug(api.DeleteConfFile)
-           DeleteConfFileFromNode = self.debug(api.DeleteConfFileFromNode)
-            DeleteConfFileFromNodeGroup = self.debug(api.DeleteConfFileFromNodeGroup)
+           GetConfFiles = self.debug(self.api.GetConfFiles)
+           DeleteConfFile = self.debug(self.api.DeleteConfFile)
+           DeleteConfFileFromNode = self.debug(self.api.DeleteConfFileFromNode)
+            DeleteConfFileFromNodeGroup = self.debug(self.api.DeleteConfFileFromNodeGroup)
 
-           conf_files = GetConfFiles(auth, self.conf_file_ids)
+           conf_files = GetConfFiles(self.auth, self.conf_file_ids)
            if conf_files is None or not conf_files: return 0           
            conf_file = conf_files[0]
            if conf_file['node_ids']:
                node_id = random.sample(conf_file['node_ids'], 1)[0]
-               DeleteConfFileFromNode(auth, conf_file['conf_file_id'], node_id)
+               DeleteConfFileFromNode(self.auth, conf_file['conf_file_id'], node_id)
            if conf_file['nodegroup_ids']:
                 nodegroup_id = random.sample(conf_file['nodegroup_ids'], 1)[0]
-                DeleteConfFileFromNodeGroup(auth, conf_file['conf_file_id'], nodegroup_id)
+                DeleteConfFileFromNodeGroup(self.auth, conf_file['conf_file_id'], nodegroup_id)
 
            # check
-           conf_files = GetConfFiles(auth, [conf_file['conf_file_id']], ['node_ids', 'nodegroup_ids'])
+           conf_files = GetConfFiles(self.auth, [conf_file['conf_file_id']], ['node_ids', 'nodegroup_ids'])
             if conf_files is None or not conf_files: return 0 
             conf_file = conf_files[0]
             self.islistequal([], conf_file['node_ids'], 'AddConfFileToNode - check')
             self.islistequal([], conf_file['nodegroup_ids'], 'AddConfFileToNodeGroup - check')
 
            for conf_file_id in self.conf_file_ids:
-               DeleteConfFile(auth, conf_file_id)
+               DeleteConfFile(self.auth, conf_file_id)
 
            # check 
-           conf_files = GetConfFiles(auth, self.conf_file_ids)
+           conf_files = GetConfFiles(self.auth, self.conf_file_ids)
            self.islistequal(conf_files, [], 'DeleteConfFile - check')
            
            if self.config.verbose:
@@ -1880,15 +1862,15 @@ class api_unit_test(Test):
     
     def NodeNetworks(self, n = 4):
        nodenetwork_ids = []
-        AddNodeNetwork = self.debug(api.AddNodeNetwork)
-        UpdateNodeNetwork = self.debug(api.UpdateNodeNetwork)
-        GetNodeNetworks = self.debug(api.GetNodeNetworks)
+        AddNodeNetwork = self.debug(self.api.AddNodeNetwork)
+        UpdateNodeNetwork = self.debug(self.api.UpdateNodeNetwork)
+        GetNodeNetworks = self.debug(self.api.GetNodeNetworks)
 
         for i in range(n):
             # Add Node Network          
             nodenetwork_fields = random_nodenetwork()
            node_id = random.sample(self.node_ids, 1)[0]
-            nodenetwork_id = AddNodeNetwork(auth, node_id, nodenetwork_fields)
+            nodenetwork_id = AddNodeNetwork(self.auth, node_id, nodenetwork_fields)
             if nodenetwork_id is None: continue
 
             # Should return a unique id
@@ -1896,22 +1878,22 @@ class api_unit_test(Test):
             nodenetwork_ids.append(nodenetwork_id)
 
             # check Node Network
-            nodenetworks = GetNodeNetworks(auth, [nodenetwork_id])
+            nodenetworks = GetNodeNetworks(self.auth, [nodenetwork_id])
             if nodenetworks is None: continue
             nodenetwork = nodenetworks[0]
             self.isequal(nodenetwork, nodenetwork_fields, 'AddNodeNetwork - isequal')
         
             # Update NodeNetwork
             nodenetwork_fields = random_nodenetwork()
-            UpdateNodeNetwork(auth, nodenetwork_id, nodenetwork_fields)
+            UpdateNodeNetwork(self.auth, nodenetwork_id, nodenetwork_fields)
 
             # Check again
-            nodenetworks = GetNodeNetworks(auth, [nodenetwork_id])
+            nodenetworks = GetNodeNetworks(self.auth, [nodenetwork_id])
             if nodenetworks is None: continue
             nodenetwork = nodenetworks[0]
             self.isequal(nodenetwork,  nodenetwork_fields, 'UpdateNodeNetwork - isequal')
 
-        nodenetworks = GetNodeNetworks(auth, nodenetwork_ids)
+        nodenetworks = GetNodeNetworks(self.auth, nodenetwork_ids)
         if nodenetworks is not None:
             self.islistequal(nodenetwork_ids, [n['nodenetwork_id'] for n in nodenetworks], 'GetNodeNetworks - isequal')
 
@@ -1921,14 +1903,14 @@ class api_unit_test(Test):
         return nodenetwork_ids
 
     def DeleteNodeNetworks(self):
-       GetNodeNetworks = self.debug(api.GetNodeNetworks)
-        DeleteNodeNetwork = self.debug(api.DeleteNodeNetwork)
+       GetNodeNetworks = self.debug(self.api.GetNodeNetworks)
+        DeleteNodeNetwork = self.debug(self.api.DeleteNodeNetwork)
 
         for nodenetwork_id in self.nodenetwork_ids:
-            DeleteNodeNetwork(auth, nodenetwork_id)
+            DeleteNodeNetwork(self.auth, nodenetwork_id)
 
         # check 
-        nodenetworks = GetNodeNetworks(auth, self.nodenetwork_ids)
+        nodenetworks = GetNodeNetworks(self.auth, self.nodenetwork_ids)
         self.islistequal(nodenetworks, [], 'DeleteNodeNetwork - check')
 
         if self.config.verbose:
@@ -1937,9 +1919,9 @@ class api_unit_test(Test):
        
     def NodeNetworkSettings(self, n=2):
        nodenetwork_setting_ids = []
-        AddNodeNetworkSetting = self.debug(api.AddNodeNetworkSetting)
-        UpdateNodeNetworkSetting = self.debug(api.UpdateNodeNetworkSetting)
-        GetNodeNetworkSettings = self.debug(api.GetNodeNetworkSettings)
+        AddNodeNetworkSetting = self.debug(self.api.AddNodeNetworkSetting)
+        UpdateNodeNetworkSetting = self.debug(self.api.UpdateNodeNetworkSetting)
+        GetNodeNetworkSettings = self.debug(self.api.GetNodeNetworkSettings)
 
         for nodenetwork_id in self.nodenetwork_ids:
             # Add Node Network          
@@ -1947,7 +1929,7 @@ class api_unit_test(Test):
             #nodenetwork_id = random.sample(self.nodenetwork_ids, 1)[0]
            nodenetwork_setting_type_id = random.sample(self.nodenetwork_setting_type_ids, 1)[0]
            value = nodenetwork_setting_fields['value']
-            nodenetwork_setting_id = AddNodeNetworkSetting(auth, nodenetwork_id, nodenetwork_setting_type_id, value)
+            nodenetwork_setting_id = AddNodeNetworkSetting(self.auth, nodenetwork_id, nodenetwork_setting_type_id, value)
             if nodenetwork_setting_id is None: continue
 
             # Should return a unique id
@@ -1955,7 +1937,7 @@ class api_unit_test(Test):
             nodenetwork_setting_ids.append(nodenetwork_setting_id)
 
             # check Node Network
-            nodenetwork_settings = GetNodeNetworkSettings(auth, [nodenetwork_setting_id])
+            nodenetwork_settings = GetNodeNetworkSettings(self.auth, [nodenetwork_setting_id])
             if nodenetwork_settings is None: continue
             nodenetwork_setting = nodenetwork_settings[0]
             self.isequal(nodenetwork_setting, nodenetwork_setting_fields, 'AddNodeNetworkSetting - isequal')
@@ -1963,15 +1945,15 @@ class api_unit_test(Test):
             # Update NodeNetworkSetting
             nodenetwork_setting_fields = random_nodenetwork_setting()
            value = nodenetwork_setting_fields['value'] 
-            UpdateNodeNetworkSetting(auth, nodenetwork_setting_id, value)
+            UpdateNodeNetworkSetting(self.auth, nodenetwork_setting_id, value)
 
             # Check again
-            nodenetwork_settings = GetNodeNetworkSettings(auth, [nodenetwork_setting_id])
+            nodenetwork_settings = GetNodeNetworkSettings(self.auth, [nodenetwork_setting_id])
             if nodenetwork_settings is None: continue
             nodenetwork_setting = nodenetwork_settings[0]
             self.isequal(nodenetwork_setting,  nodenetwork_setting_fields, 'UpdateNodeNetworkSetting - isequal')
 
-        nodenetwork_settings = GetNodeNetworkSettings(auth, nodenetwork_setting_ids)
+        nodenetwork_settings = GetNodeNetworkSettings(self.auth, nodenetwork_setting_ids)
         if nodenetwork_settings is not None:
             self.islistequal(nodenetwork_setting_ids, [n['nodenetwork_setting_id'] for n in nodenetwork_settings], 'GetNodeNetworkSettings - isequal')
 
@@ -1981,14 +1963,14 @@ class api_unit_test(Test):
         return nodenetwork_setting_ids
 
     def DeleteNodeNetworkSettings(self):
-       GetNodeNetworkSettings = self.debug(api.GetNodeNetworkSettings)
-        DeleteNodeNetworkSetting = self.debug(api.DeleteNodeNetworkSetting)
+       GetNodeNetworkSettings = self.debug(self.api.GetNodeNetworkSettings)
+        DeleteNodeNetworkSetting = self.debug(self.api.DeleteNodeNetworkSetting)
 
         for nodenetwork_setting_id in self.nodenetwork_setting_ids:
-            DeleteNodeNetworkSetting(auth, nodenetwork_setting_id)
+            DeleteNodeNetworkSetting(self.auth, nodenetwork_setting_id)
 
         # check 
-        nodenetwork_settings = GetNodeNetworkSettings(auth, self.nodenetwork_setting_ids)
+        nodenetwork_settings = GetNodeNetworkSettings(self.auth, self.nodenetwork_setting_ids)
         self.islistequal(nodenetwork_settings, [], 'DeleteNodeNetworkSetting - check')
 
         if self.config.verbose:
@@ -1997,14 +1979,14 @@ class api_unit_test(Test):
        
     def NodeNetworkSettingTypes(self, n = 2):
        nodenetwork_setting_type_ids = []
-       AddNodeNetworkSettingType = self.debug(api.AddNodeNetworkSettingType)
-        UpdateNodeNetworkSettingType = self.debug(api.UpdateNodeNetworkSettingType)
-        GetNodeNetworkSettingTypes = self.debug(api.GetNodeNetworkSettingTypes)
+       AddNodeNetworkSettingType = self.debug(self.api.AddNodeNetworkSettingType)
+        UpdateNodeNetworkSettingType = self.debug(self.api.UpdateNodeNetworkSettingType)
+        GetNodeNetworkSettingTypes = self.debug(self.api.GetNodeNetworkSettingTypes)
 
         for i in range(n):
             # Add Node Network Settings Type         
             nodenetwork_setting_type_fields = random_nodenetwork_setting_type()
-            nodenetwork_setting_type_id = AddNodeNetworkSettingType(auth, nodenetwork_setting_type_fields)
+            nodenetwork_setting_type_id = AddNodeNetworkSettingType(self.auth, nodenetwork_setting_type_fields)
             if nodenetwork_setting_type_id is None: continue
 
             # Should return a unique id
@@ -2012,22 +1994,22 @@ class api_unit_test(Test):
             nodenetwork_setting_type_ids.append(nodenetwork_setting_type_id)
 
             # check Node Network Settings Type
-            nodenetwork_setting_types = GetNodeNetworkSettingTypes(auth, [nodenetwork_setting_type_id])
+            nodenetwork_setting_types = GetNodeNetworkSettingTypes(self.auth, [nodenetwork_setting_type_id])
             if nodenetwork_setting_types is None: continue
             nodenetwork_setting_type = nodenetwork_setting_types[0]
             self.isequal(nodenetwork_setting_type, nodenetwork_setting_type_fields, 'AddNodeNetworkSettingType - isequal')
 
             # Update NodeNetworkSetting
             nodenetwork_setting_type_fields = random_nodenetwork_setting_type()
-            UpdateNodeNetworkSettingType(auth, nodenetwork_setting_type_id, nodenetwork_setting_type_fields)
+            UpdateNodeNetworkSettingType(self.auth, nodenetwork_setting_type_id, nodenetwork_setting_type_fields)
 
             # Check again
-            nodenetwork_setting_types = GetNodeNetworkSettingTypes(auth, [nodenetwork_setting_type_id])
+            nodenetwork_setting_types = GetNodeNetworkSettingTypes(self.auth, [nodenetwork_setting_type_id])
             if nodenetwork_setting_types is None: continue
             nodenetwork_setting_type = nodenetwork_setting_types[0]
             self.isequal(nodenetwork_setting_type,  nodenetwork_setting_type_fields, 'UpdateNodeNetworkSettingType - isequal')
 
-        nodenetwork_setting_types = GetNodeNetworkSettingTypes(auth, nodenetwork_setting_type_ids)
+        nodenetwork_setting_types = GetNodeNetworkSettingTypes(self.auth, nodenetwork_setting_type_ids)
         if nodenetwork_setting_types is not None:
             self.islistequal(nodenetwork_setting_type_ids, [n['nodenetwork_setting_type_id'] for n in nodenetwork_setting_types], 'GetNodeNetworkSettingTypes - isequal')
 
@@ -2037,14 +2019,14 @@ class api_unit_test(Test):
         return nodenetwork_setting_type_ids
 
     def DeleteNodeNetworkSettingTypes(self):
-       GetNodeNetworkSettingTypes = self.debug(api.GetNodeNetworkSettingTypes)
-        DeleteNodeNetworkSettingType = self.debug(api.DeleteNodeNetworkSettingType)
+       GetNodeNetworkSettingTypes = self.debug(self.api.GetNodeNetworkSettingTypes)
+        DeleteNodeNetworkSettingType = self.debug(self.api.DeleteNodeNetworkSettingType)
 
         for nodenetwork_setting_type_id in self.nodenetwork_setting_type_ids:
-            DeleteNodeNetworkSettingType(auth, nodenetwork_setting_type_id)
+            DeleteNodeNetworkSettingType(self.auth, nodenetwork_setting_type_id)
 
         # check 
-        nodenetwork_setting_types = GetNodeNetworkSettingTypes(auth, self.nodenetwork_setting_type_ids)
+        nodenetwork_setting_types = GetNodeNetworkSettingTypes(self.auth, self.nodenetwork_setting_type_ids)
         self.islistequal(nodenetwork_setting_types, [], 'DeleteNodeNetworkSettingType - check')
 
         if self.config.verbose:
@@ -2053,35 +2035,35 @@ class api_unit_test(Test):
 
     def Messages(self, n = 2):
        message_ids = []
-        AddMessage = self.debug(api.AddMessage)
-        GetMessages = self.debug(api.GetMessages)
-        UpdateMessage = self.debug(api.UpdateMessage)
+        AddMessage = self.debug(self.api.AddMessage)
+        GetMessages = self.debug(self.api.GetMessages)
+        UpdateMessage = self.debug(self.api.UpdateMessage)
         for i in range(n):
             # Add Message
             message_fields = random_message()
             message_id = message_fields['message_id']
-           AddMessage(auth, message_fields)
+           AddMessage(self.auth, message_fields)
             if message_id is None: continue
 
             # Should return a unique id
             self.isunique(message_id, message_ids, 'AddMessage - isunique')
             message_ids.append(message_id)
-            messages = GetMessages(auth, [message_id])
+            messages = GetMessages(self.auth, [message_id])
             if messages is None: continue
             message = messages[0]
             self.isequal(message, message_fields, 'AddMessage - isequal')
 
             # Update message
             message_fields = random_message()
-            result = UpdateMessage(auth, message_id, message_fields)
+            result = UpdateMessage(self.auth, message_id, message_fields)
 
             # Check again
-            messages = GetMessages(auth, [message_id])
+            messages = GetMessages(self.auth, [message_id])
             if messages is None: continue
             message = messages[0]
             self.isequal(message, message_fields, 'UpdateMessage - isequal')
 
-        messages = GetMessages(auth, message_ids)
+        messages = GetMessages(self.auth, message_ids)
         if messages is not None:
             self.islistequal(message_ids, [m['message_id'] for m in messages], 'GetMessages - isequal')
 
@@ -2092,13 +2074,13 @@ class api_unit_test(Test):
 
     def DeleteMessages(self):
        # Delete all messages
-        DeleteMessage = self.debug(api.DeleteMessage)
-        GetMessages = self.debug(api.GetMessages)
+        DeleteMessage = self.debug(self.api.DeleteMessage)
+        GetMessages = self.debug(self.api.GetMessages)
         for message_id in self.message_ids:
-            result = DeleteMessage(auth, message_id)
+            result = DeleteMessage(self.auth, message_id)
 
         # Check if messages are deleted
-        messages = GetMessages(auth, self.message_ids)
+        messages = GetMessages(self.auth, self.message_ids)
         self.islistequal(messages, [], 'DeleteMessage - check')
 
         if self.config.verbose:
@@ -2108,37 +2090,37 @@ class api_unit_test(Test):
 
     def Sessions(self, n = 2):
        session_ids = []
-        AddSession = self.debug(api.AddSession)
-        GetSession = self.debug(api.GetSession)
-       GetSessions = self.debug(api.GetSessions)
+        AddSession = self.debug(self.api.AddSession)
+        GetSession = self.debug(self.api.GetSession)
+       GetSessions = self.debug(self.api.GetSessions)
         for i in range(n):
             # Add session
             person_id = random.sample(self.person_ids, 1)[0]
-            session_id = AddSession(auth, person_id)
+            session_id = AddSession(self.auth, person_id)
             if session_id is None: continue
             session_ids.append(session_id)
        
             # Check session 
-            sessions = GetSessions(auth, [person_id])
+            sessions = GetSessions(self.auth, [person_id])
             if not sessions: continue
             session = sessions[0]
            sess_id = session['session_id']
             self.islistequal([sess_id], [session_id], 'AddSession - isequal')
 
            # GetSession creates session_id based on auth, so we must use the current auth
-           session_id = GetSession(auth)
+           session_id = GetSession(self.auth)
            if session_id is None: continue
            session_ids.append(session_id)
            
            # Check session
-           sessions = GetSessions(auth, [auth['Username']])
+           sessions = GetSessions(self.auth, [self.auth['Username']])
            if not sessions: continue
            session = sessions[0]
            sess_id = session['session_id']
            self.islistequal([sess_id], [session_id], 'GetSession - isequal')     
                 
         # Check all
-        sessions = GetSessions(auth, session_ids)
+        sessions = GetSessions(self.auth, session_ids)
         if sessions is not None:
            sess_ids = [s['session_id'] for s in sessions]      
             self.islistequal(sess_ids, session_ids, 'GetSessions - isequal')
@@ -2149,12 +2131,12 @@ class api_unit_test(Test):
         return session_ids             
 
     def DeleteSessions(self):
-       DeleteSession = self.debug(api.DeleteSession)
-        GetSessions = self.debug(api.GetSessions)
+       DeleteSession = self.debug(self.api.DeleteSession)
+        GetSessions = self.debug(self.api.GetSessions)
 
        # DeleteSession deletes based on auth, so we must create auths for the sessions we delete
         for session_id  in self.session_ids:
-           sessions = GetSessions(auth, [session_id])
+           sessions = GetSessions(self.auth, [session_id])
            if not sessions: continue
            session = sessions[0]
            tmpauth = { 
@@ -2165,7 +2147,7 @@ class api_unit_test(Test):
             DeleteSession(tmpauth)
 
         # Check if sessions are deleted
-        sessions = GetSessions(auth, self.session_ids)
+        sessions = GetSessions(self.auth, self.session_ids)
         self.islistequal(sessions, [], 'DeleteBootState check')
 
         if self.config.verbose:
@@ -2174,15 +2156,15 @@ class api_unit_test(Test):
         self.session_ids = []  
 
     def GenerateNodeConfFile(self):
-       GetNodes = self.debug(api.GetNodes)
-       GetNodeNetworks = self.debug(api.GetNodeNetworks)
-       GenerateNodeConfFile = self.debug(api.GenerateNodeConfFile)
+       GetNodes = self.debug(self.api.GetNodes)
+       GetNodeNetworks = self.debug(self.api.GetNodeNetworks)
+       GenerateNodeConfFile = self.debug(self.api.GenerateNodeConfFile)
  
-       nodes = GetNodes(auth, self.node_ids)
+       nodes = GetNodes(self.auth, self.node_ids)
        nodes = filter(lambda n: n['nodenetwork_ids'], nodes)
        if not nodes: return 0
        node = nodes[0]
-       nodenetworks = GetNodeNetworks(auth, node['nodenetwork_ids'])
+       nodenetworks = GetNodeNetworks(self.auth, node['nodenetwork_ids'])
        nodenetwork = nodenetworks[0]
        parts = node['hostname'].split(".", 1)
        host = parts[0]
@@ -2201,7 +2183,7 @@ class api_unit_test(Test):
                'HOSTNAME': host,
                'DOMAIN_NAME': domain
                }
-       node_config_file = GenerateNodeConfFile(auth, node['node_id'])
+       node_config_file = GenerateNodeConfFile(self.auth, node['node_id'])
        self.isequal(node_config_file, node_config, 'GenerateNodeConfFile - isequal') 
        
        if self.config.verbose:
@@ -2212,27 +2194,27 @@ class api_unit_test(Test):
 
 
     def GetEventObjects(self):
-       GetEventObjects = self.debug(api.GetEventObjects)
-       GetEventObjects(auth)
+       GetEventObjects = self.debug(self.api.GetEventObjects)
+       GetEventObjects(self.auth)
        
        if self.config.verbose:
            utils.header("GetEventObjects")
 
     def GetEvents(self):
-       GetEvents = self.debug(api.GetEvents)
-       GetEvents(auth)
+       GetEvents = self.debug(self.api.GetEvents)
+       GetEvents(self.auth)
        
        if self.config.verbose:
            utils.header("GetEvents")
 
     def GetPeerData(self):
-       GetPeers = self.debug(api.GetPeers)
-       GetPeerData = self.debug(api.GetPeerData)
+       GetPeers = self.debug(self.api.GetPeers)
+       GetPeerData = self.debug(self.api.GetPeerData)
        
-       peers = GetPeers(auth)
+       peers = GetPeers(self.auth)
        if peers is None or not peers: return 0
        peer = peers[0]
-       peer_data = GetPeerData(auth)
+       peer_data = GetPeerData(self.auth)
 
        # Manuall construt peer data
 
@@ -2241,63 +2223,63 @@ class api_unit_test(Test):
 
     def GetPeerName(self):
        # GetPeerName should return the same as api.config.PLC_NAME 
-       GetPeerName = self.debug(api.GetPeerName)               
-       peer_name = GetPeerName(auth)
-       self.islistequal([peer_name], [api.config.PLC_NAME], 'GetPeerName - isequal')
+       GetPeerName = self.debug(self.api.GetPeerName)          
+       peer_name = GetPeerName(self.auth)
+       self.islistequal([peer_name], [self.api.config.PLC_NAME], 'GetPeerName - isequal')
        
        if self.config.verbose:
            utils.header("GetPeerName") 
  
     def GetPlcRelease(self):
-       GetPlcRelease = self.debug(api.GetPlcRelease)
-       plc_release = GetPlcRelease(auth)
+       GetPlcRelease = self.debug(self.api.GetPlcRelease)
+       plc_release = GetPlcRelease(self.auth)
 
        if self.config.verbose:
            utils.header("GetPlcRelease")
 
     def GetSliceKeys(self):
-       GetSliceKeys = self.debug(api.GetSliceKeys)
-       GetSlices = self.debug(api.GetSlices)
+       GetSliceKeys = self.debug(self.api.GetSliceKeys)
+       GetSlices = self.debug(self.api.GetSlices)
 
-       slices = GetSlices(auth, self.slice_ids)
+       slices = GetSlices(self.auth, self.slice_ids)
        if not slices: return 0
        slices = filter(lambda s: s['person_ids'], slices)
        if not slices: return 0
        slice = slices[0]
        
-       slice_keys = GetSliceKeys(auth, [slice['slice_id']])
+       slice_keys = GetSliceKeys(self.auth, [slice['slice_id']])
        # XX Manually construct slice_keys for this slice and compare
        
        if self.config.verbose:
            utils.header("GetSliceKeys(%s)" % [slice['slice_id']])
 
     def GetSliceTicket(self):
-       GetSliceTicket = self.debug(api.GetSliceTicket)
+       GetSliceTicket = self.debug(self.api.GetSliceTicket)
 
        slice_id = random.sample(self.slice_ids, 1)[0] 
-       slice_ticket = GetSliceTicket(auth, slice_id)
+       slice_ticket = GetSliceTicket(self.auth, slice_id)
 
        if self.config.verbose:
            utils.header("GetSliceTicket(%s)" % slice_id)
 
     def GetSlicesMD5(self):
-       GetSlicesMD5 = self.debug(api.GetSlicesMD5)
+       GetSlicesMD5 = self.debug(self.api.GetSlicesMD5)
 
-       slices_md5 = GetSlicesMD5(auth)
+       slices_md5 = GetSlicesMD5(self.auth)
 
        if self.config.verbose:
            utils.header("GetSlicesMD5")
 
     def GetSlivers(self):
-       GetSlivers = self.debug(api.GetSlivers)
-       GetNodes = self.debug(api.GetNodes)
-       nodes = GetNodes(auth, self.node_ids)
+       GetSlivers = self.debug(self.api.GetSlivers)
+       GetNodes = self.debug(self.api.GetNodes)
+       nodes = GetNodes(self.auth, self.node_ids)
        if nodes is None or not nodes: return 0
        nodes = filter(lambda n: n['slice_ids'], nodes)
        if not nodes: return 0
        node = nodes[0]
 
-       slivers = GetSlivers(auth, node['node_id'])
+       slivers = GetSlivers(self.auth, node['node_id'])
        
        # XX manually create slivers object and compare
 
@@ -2305,11 +2287,11 @@ class api_unit_test(Test):
            utils.header("GetSlivers(%s)" % node['node_id'])
 
     def GetWhitelist(self):
-       GetWhitelist = self.debug(api.GetWhitelist)
-       GetNodes = self.debug(api.GetNodes)
+       GetWhitelist = self.debug(self.api.GetWhitelist)
+       GetNodes = self.debug(self.api.GetNodes)
 
-       whitelists = GetWhitelist(auth, self.node_ids)
-       nodes = GetNodes(auth, self.node_ids)
+       whitelists = GetWhitelist(self.auth, self.node_ids)
+       nodes = GetNodes(self.auth, self.node_ids)
        if nodes is None or not nodes: return 0
        nodes = filter(lambda n: n['slice_ids_whitelist'], nodes)
        self.islistequal(whitelists, nodes, 'GetWhitelist - isequal')
@@ -2318,62 +2300,62 @@ class api_unit_test(Test):
            utils.header("GetWhitelist")
 
     def NotifyPersons(self):
-       NotifyPersons = self.debug(api.NotifyPersons)
+       NotifyPersons = self.debug(self.api.NotifyPersons)
        person_id = random.sample(self.person_ids, 1)[0]
 
-       NotifyPersons(auth, [person_id], 'QA Test', 'Welcome')
+       NotifyPersons(self.auth, [person_id], 'QA Test', 'Welcome')
 
        if self.config.verbose:
            utils.header('NotifyPersons(%s)' % [person_id])             
         
     def NotifySupport(self):
-       NotifySupport = self.debug(api.NotifySupport)
-       NotifySupport(auth, 'QA Test', 'Support Request')
+       NotifySupport = self.debug(self.api.NotifySupport)
+       NotifySupport(self.auth, 'QA Test', 'Support Request')
        
        if self.config.verbose:
            utils.header('NotifSupport')
 
     def RebootNode(self):
-       RebootNode = self.debug(api.RebootNode)
+       RebootNode = self.debug(self.api.RebootNode)
        node_id = random.sample(self.node_ids, 1)[0]
-       RebootNode(auth, node_id)
+       RebootNode(self.auth, node_id)
        
        if self.config.verbose:
            utils.header('RebootNode(%s)' % node_id)
 
     def ResetPassword(self):
-       ResetPassword = self.debug(api.ResetPassword)
+       ResetPassword = self.debug(self.api.ResetPassword)
        person_id = random.sample(self.person_ids, 1)[0]
-       ResetPassword(auth, person_id)
+       ResetPassword(self.auth, person_id)
 
        if self.config.verbose:
            utils.header('ResetPassword(%s)' % person_id)
 
     def SetPersonPrimarySite(self):
-       SetPersonPrimarySite = self.debug(api.SetPersonPrimarySite)
-       GetPersons = self.debug(api.GetPersons)
+       SetPersonPrimarySite = self.debug(self.api.SetPersonPrimarySite)
+       GetPersons = self.debug(self.api.GetPersons)
        person_id = random.sample(self.person_ids, 1)[0]
-       persons = GetPersons(auth, person_id)
+       persons = GetPersons(self.auth, person_id)
        if not persons: return 0
        person = persons[0] 
        site_id = random.sample(person['site_ids'], 1)[0]
-       SetPersonPrimarySite(auth, person_id, site_id)
+       SetPersonPrimarySite(self.auth, person_id, site_id)
 
        if self.config.verbose:
            utils.header('SetPersonPrimarySite(%s, %s)' % (person_id, site_id))
 
     def VerifyPerson(self):
-       VerifyPerson = self.debug(api.VerifyPerson)
-       UpdatePerson = self.debug(api.UpdatePerson)
-       GetPersons = self.debug(api.GetPersons)
+       VerifyPerson = self.debug(self.api.VerifyPerson)
+       UpdatePerson = self.debug(self.api.UpdatePerson)
+       GetPersons = self.debug(self.api.GetPersons)
 
        # can only verify new (disabled) accounts 
        person_id = random.sample(self.person_ids, 1)[0]
-       persons = GetPersons(auth, [person_id])
+       persons = GetPersons(self.auth, [person_id])
        if persons is None or not persons: return 0
        person = persons[0]
-       UpdatePerson(auth, person['person_id'], {'enabled': False})
-       VerifyPerson(auth, person['person_id'])
+       UpdatePerson(self.auth, person['person_id'], {'enabled': False})
+       VerifyPerson(self.auth, person['person_id'])
 
        if self.config.verbose:
            utils.header('VerifyPerson(%s)' % person_id)