add date to log's filename by default
[tests.git] / qaapi / qa / Config.py
index 16a4eca..ba12682 100644 (file)
@@ -5,12 +5,15 @@ import re
 import socket
 import utils
 import copy
+from logger import logfile
 from PLCs import PLC, PLCs
 from Sites import Site, Sites  
 from Nodes import Node, Nodes
 from Slices import Slice, Slices
 from Persons import Person, Persons    
 
+path = os.path.dirname(os.path.abspath(__file__))
+
 class Config:
 
     path = os.path.dirname(os.path.abspath(__file__))
@@ -18,7 +21,8 @@ class Config:
     node_tests_path = tests_path + os.sep + 'node' + os.sep
     slice_tests_path = tests_path + os.sep + 'slice' + os.sep                          
     vserver_scripts_path = path + os.sep + 'vserver' + os.sep
-
+    log_filename = logfile.filename
+    
     def update_api(self, plc = None):
        # Set up API acccess
        # If plc is specified, find its configuration
@@ -53,7 +57,8 @@ class Config:
             execfile(config_file, self.__dict__)
         except:
             raise "Could not find system config in %s" % config_file
-
+       
+       self.logfile = logfile
        self.auth = {}
        self.auth['Username'] = self.PLC_ROOT_USER
        self.auth['AuthString'] = self.PLC_ROOT_PASSWORD
@@ -63,10 +68,9 @@ class Config:
        # try setting hostname and ip
         self.hostname = socket.gethostname()
         try:
-           (stdout, stderr) = utils.popen("/sbin/ifconfig eth0 | grep 'inet addr'")
-            inet_addr = re.findall('inet addr:[0-9\.^\w]*', stdout[0])[0]
-            parts = inet_addr.split(":")
-            self.ip = parts[1]
+            command = "/sbin/ifconfig eth0 | grep -v inet6 | grep inet | awk '{print$2;}'"
+            (status, output) = utils.commands(command)            
+           self.ip = re.findall(r'[0-9\.]+', output)[0]
        except:
            self.ip = '127.0.0.1'
        
@@ -85,13 +89,14 @@ class Config:
        plc = PLC(self)
        if hasattr(self, 'plcs')  and plc_name in self.plcs.keys():
            plc.update(self.plcs[plc_name])
-           plc.config.update_api(plc)
+           plc.update_api()
        return plc
 
     def get_node(self, hostname):
        node = Node(self)
        if hasattr(self, 'nodes') and hostname in self.nodes.keys():
            node.update(self.nodes[hostname])
+           node.__init_logfile__()
        return node                     
 
     def load(self, conffile):