work around some odd bug when running runtest twice
authorMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 14 Feb 2008 22:31:33 +0000 (22:31 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 14 Feb 2008 22:31:33 +0000 (22:31 +0000)
qaapi/qa/Config.py
qaapi/runtests.py

index e931de3..0e3c747 100644 (file)
@@ -12,19 +12,7 @@ class Config:
     node_tests_path = tests_path + os.sep + 'node'
     slice_tests_path = tests_path + os.sep + 'slice'                           
 
-    def __init__(self, config_file = path+os.sep+'qa_config'):
-       # Load config file
-       try:
-            execfile(config_file, self.__dict__)
-        except:
-            raise "Could not find system config in %s" % config_file
-
-       self.auth = {}
-       self.auth['Username'] = self.PLC_ROOT_USER
-       self.auth['AuthString'] = self.PLC_ROOT_PASSWORD
-       self.auth['AuthMethod'] = 'password'
-       self.verbose = self.VERBOSE     
-       
+    def update_api(self):
        # Set up API acccess
        # Try importing the API shell for direct api access.
        # If that fails fall back to using xmlrpm
@@ -41,6 +29,19 @@ class Config:
            self.api = xmlrpclib.Server('https://%s/PLCAPI/' % self.PLC_API_HOST, allow_none = 1)
            self.api_type = 'xmlrpc'
 
+    def __init__(self, config_file = path+os.sep+'qa_config'):
+       # Load config file
+       try:
+            execfile(config_file, self.__dict__)
+        except:
+            raise "Could not find system config in %s" % config_file
+
+       self.auth = {}
+       self.auth['Username'] = self.PLC_ROOT_USER
+       self.auth['AuthString'] = self.PLC_ROOT_PASSWORD
+       self.auth['AuthMethod'] = 'password'
+       self.verbose = self.VERBOSE     
+       
        # try setting hostname and ip
         self.hostname = socket.gethostname()
         (stdout, stderr) = utils.popen("/sbin/ifconfig eth0 | grep 'inet addr'")
@@ -48,6 +49,11 @@ class Config:
         parts = inet_addr.split(":")
         self.ip = parts[1]
        
+        api_host = self.__dict__.get("PLC_API_HOST",self.ip)
+        self.PLC_API_HOST=api_host
+
+        self.update_api()
+
        # Load list of node tests
        valid_node_test_files = lambda name: not name.startswith('__init__') \
                                             and not name.endswith('pyc')
index bc23bce..dcdaf17 100755 (executable)
@@ -27,6 +27,7 @@ def main(args):
 
     # Add test site, node, person and slice data
     # Adds slice to node and person to slice 
+    config.update_api()
     add_test_data(config)()
 
     # Update plc with tests user's current public key