From: Tony Mack Date: Tue, 8 Apr 2008 18:10:14 +0000 (+0000) Subject: call update_api() on plc before returning it in get_plc() X-Git-Tag: tests-4.2-4~70 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7bec44eef3702704cbef8a900352740ef166580f;p=tests.git call update_api() on plc before returning it in get_plc() --- diff --git a/qaapi/qa/Config.py b/qaapi/qa/Config.py index 16a4eca..7a8e4dc 100644 --- a/qaapi/qa/Config.py +++ b/qaapi/qa/Config.py @@ -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,6 +21,7 @@ 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 @@ -63,10 +67,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,7 +88,7 @@ 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):