commit 91d8843f589b0ebef34cb2d69cf3c44f5cac8bf5
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 2 13:42:13 2012 +0200
controller: changes required by the new LoggingServer
NetTestController now needs to have access to the logging server so
nettestctl now passes it as an argument to the constructor.
The function _init_slave_logging now doesn't communicate with the slave
at all. Instead it sends the slaves address to the logging server which
then tries to connect to it.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
NetTest/NetTestController.py | 18 +++++++++---------
nettestctl.py | 13 ++++++-------
2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index e9735b4..2629c40 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -26,6 +26,7 @@ from Common.LoggingServer import LoggingServer
from Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
from Common.Utils import wait_for
from NetTest.MachinePool import MachinePool
+from Common.LoggingHandler import DEFAULT_LOG_PORT
class NetTestError(Exception):
pass
@@ -35,12 +36,13 @@ def ignore_event(**kwarg):
class NetTestController:
def __init__(self, recipe_path, remoteexec=False, cleanup=False,
- res_serializer=None, config=None):
+ res_serializer=None, config=None, logServer=None):
self._remoteexec = remoteexec
self._docleanup = cleanup
self._res_serializer = res_serializer
self._remote_capture_files = {}
self._config = config
+ self._logServer = logServer
self._command_context = NetTestCommandContext()
self._machine_pool = MachinePool(config.get_option('environment',
'pool_dirs'))
@@ -257,15 +259,13 @@ class NetTestController:
def _init_slave_logging(self, machine_id):
info = self._get_machineinfo(machine_id)
+ logServer = self._logServer
+
hostname = info["hostname"]
- logging.info("Setting logging server on machine %s", hostname)
- rpc = self._get_machinerpc(machine_id)
- ip_addr = get_corespond_local_ip(hostname)
- if not rpc.set_logging(ip_addr, self._config.get_option('log',
'port')):
-
logging.error("==================================================")
- logging.error("Machine %s is unable to connect to the logging "\
- "server! Check your firewall settings." % hostname)
-
logging.error("==================================================")
+ port = str(DEFAULT_LOG_PORT)
+
+ logging.info("Connecting to the logging server on machine %s",
hostname)
+ logServer.addSlave(hostname, port)
def _deconfigure_slaves(self):
if 'machines' not in self._recipe:
diff --git a/nettestctl.py b/nettestctl.py
index f9973e4..c4154d4 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -45,12 +45,12 @@ def usage():
print " -x, --result=FILE file to write xml_result"
sys.exit()
-def process_recipe(action, file_path, remoteexec, cleanup,
- res_serializer, packet_capture, config):
+def process_recipe(action, file_path, remoteexec, cleanup, res_serializer,
+ packet_capture, config, loggingServer):
nettestctl = NetTestController(file_path,
remoteexec=remoteexec, cleanup=cleanup,
res_serializer=res_serializer,
- config=config)
+ config=config, logServer=loggingServer)
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
@@ -75,11 +75,10 @@ def get_recipe_result(args, file_path, remoteexec, cleanup,
res_serializer, packet_capture, config):
res_serializer.add_recipe(file_path)
Logs.set_logging_root_path(file_path)
- loggingServer = LoggingServer(config.get_option('log', 'port'),
- Logs.root_path, Logs.debug)
+ loggingServer = LoggingServer(Logs.root_path, Logs.debug)
loggingServer.start()
- res = process_recipe(args, file_path, remoteexec, cleanup,
- res_serializer, packet_capture, config)
+ res = process_recipe(args, file_path, remoteexec, cleanup, res_serializer,
+ packet_capture, config, loggingServer)
loggingServer.stop()
return ((file_path, res))