[lnst] Remove LoggingServer.py
by Jiří Pírko
commit 7fbb1756c0cb2df8aceddd8c5dca879393321bb1
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Oct 18 16:16:22 2012 +0200
Remove LoggingServer.py
The LoggingServer is no longer needed therefore this patch removes it.
The patch also removes code related to the logging server. Other than
imports this includes the DEFAULT_LOG_PORT constant, and the
configuration option of logging port.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/Config.py | 5 +-
Common/LoggingHandler.py | 2 -
Common/LoggingServer.py | 158 ------------------------------------------
NetTest/NetTestController.py | 1 -
lnst.conf.example | 1 -
nettestctl.py | 1 -
6 files changed, 1 insertions(+), 167 deletions(-)
---
diff --git a/Common/Config.py b/Common/Config.py
index cf79c6c..e76fbef 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -28,7 +28,6 @@ class Config():
self.options = dict()
self.options['log'] = dict()
- self.options['log']['port'] = 9998
self.options['log']['path'] = os.path.join(
os.path.dirname(sys.argv[0]), './')
@@ -76,9 +75,7 @@ class Config():
config.pop('__name__', None)
for option in config:
- if option == 'port':
- section['port'] = self.optionPort(config[option])
- elif option == 'path':
+ if option == 'path':
section['path'] = self.optionLogPath(config[option], cfg_path)
else:
msg = "Unknown option: %s in section log" % option
diff --git a/Common/LoggingHandler.py b/Common/LoggingHandler.py
index cfcacb3..dae27bf 100644
--- a/Common/LoggingHandler.py
+++ b/Common/LoggingHandler.py
@@ -24,8 +24,6 @@ import socket, struct, pickle
import logging
import xmlrpclib
-DEFAULT_LOG_PORT = 9998
-
class LogBuffer(logging.Handler):
"""
Handler used for buffering log messages. Compared to the BufferingHandler
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 888a5ba..5e5a134 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -23,7 +23,6 @@ from NetTest.NetTestParse import NetTestParse
from Common.SlaveUtils import prepare_client_session
from Common.NetUtils import MacPool
from NetTest.NetTestCommand import NetTestCommandContext, NetTestCommand, str_command
-from Common.LoggingServer import LoggingServer
from Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
from Common.Utils import wait_for
from NetTest.MachinePool import MachinePool
diff --git a/lnst.conf.example b/lnst.conf.example
index af64aa8..422804c 100644
--- a/lnst.conf.example
+++ b/lnst.conf.example
@@ -4,4 +4,3 @@ rpcport = 9999
machine_pool_dirs =
[log]
path = ./
-port = 9998
diff --git a/nettestctl.py b/nettestctl.py
index 4a32d99..d4178f4 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -19,7 +19,6 @@ import re
from NetTest.NetTestController import NetTestController, NetTestError
from NetTest.NetTestResultSerializer import NetTestResultSerializer
from Common.Logs import Logs
-from Common.LoggingServer import LoggingServer
import Common.ProcessManager
from Common.Config import Config
11 years, 6 months
[PATCH 0/7] Logs cleanup pachset
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Here is the promised cleanup patch. Most of the changes involve removing old or
unused code. Other than that there are a few minor tweaks that shouldn't really
change anything significant.
After this patch set is commited I will finally close the ticket regarding the
reversal of the logs retrieval.
I wanted to change a few other things and add comments where they would be
usefull but seeing as there will be a few more changes to the logs I will leave
this for later.
Ondrej Lichtner (7):
Remove LoggingServer.py
LoggingHandler: remove ServerHandler
LoggingHandler: forgotten change of makePickle docstring
NetTestController: fix a small Logs interface error
NetTestSlave: remove method set_logging
Logs: remove unused code
Logs: small path change
Common/Config.py | 7 +-
Common/LoggingHandler.py | 103 +---------------------------
Common/LoggingServer.py | 158 -------------------------------------------
Common/Logs.py | 40 ++---------
NetTest/NetTestController.py | 5 +-
NetTest/NetTestSlave.py | 11 ---
lnst.conf.example | 1 -
nettestctl.py | 1 -
8 files changed, 10 insertions(+), 316 deletions(-)
delete mode 100644 Common/LoggingServer.py
--
1.7.11.7
11 years, 6 months
[lnst] NetTestController: disable LoggingServer
by Jiří Pírko
commit 7ae12941ea1326a08b9bb624b65693d0cea54e51
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 12 12:51:10 2012 +0200
NetTestController: disable LoggingServer
The LoggingServer is no longer used and logs are retrieved through rpc.
This means it is no longer needed to create and start the server.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
NetTest/NetTestController.py | 4 ++--
nettestctl.py | 11 +++--------
2 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 1a70e6b..888a5ba 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -21,7 +21,7 @@ from pprint import pprint, pformat
from Common.XmlRpc import ServerProxy, ServerException
from NetTest.NetTestParse import NetTestParse
from Common.SlaveUtils import prepare_client_session
-from Common.NetUtils import get_corespond_local_ip, MacPool
+from Common.NetUtils import MacPool
from NetTest.NetTestCommand import NetTestCommandContext, NetTestCommand, str_command
from Common.LoggingServer import LoggingServer
from Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
@@ -36,7 +36,7 @@ def ignore_event(**kwarg):
class NetTestController:
def __init__(self, recipe_path, remoteexec=False, cleanup=False,
- res_serializer=None, config=None, logServer=None):
+ res_serializer=None, config=None):
self._remoteexec = remoteexec
self._docleanup = cleanup
self._res_serializer = res_serializer
diff --git a/nettestctl.py b/nettestctl.py
index 201ed7f..4a32d99 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -46,11 +46,10 @@ def usage():
sys.exit()
def process_recipe(action, file_path, remoteexec, cleanup, res_serializer,
- packet_capture, config, loggingServer):
+ packet_capture, config):
nettestctl = NetTestController(file_path,
remoteexec=remoteexec, cleanup=cleanup,
- res_serializer=res_serializer,
- config=config, logServer=loggingServer)
+ res_serializer=res_serializer, config=config)
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
@@ -75,18 +74,14 @@ 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(Logs.root_path, Logs.debug)
- loggingServer.start()
res = None
try:
res = process_recipe(args, file_path, remoteexec, cleanup,
- res_serializer, packet_capture,
- config, loggingServer)
+ res_serializer, packet_capture, config)
except NetTestError as err:
logging.error(err)
- loggingServer.stop()
return ((file_path, res))
def main():
11 years, 6 months
[lnst] NetTestController: retrieve slave logs through rpc
by Jiří Pírko
commit b03a8a298a716f70a738613cc9e91a3a2aab55bd
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 12 12:51:09 2012 +0200
NetTestController: retrieve slave logs through rpc
The RPC server on the slaves now supports a new method get_new_logs that
is used for retrieving stored logs on the slave machine.
The controller now uses this method to retrieve the logs. Retrieved logs
are then passed to the method _add_client_logs that modifies the source
address and logges them on the controller.
The method _init_slave_logging had to be changed so that the directory
hierarchy for logs wouldn't be changed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
NetTest/NetTestController.py | 39 +++++++++++++++++++++++++++++++--------
NetTest/NetTestSlave.py | 5 +++++
2 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 9b95798..1a70e6b 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -14,6 +14,7 @@ jpirko(a)redhat.com (Jiri Pirko)
import logging
import socket
import os
+import pickle
from Common.Logs import Logs, log_exc_traceback
from Common.SshUtils import scp_from_remote
from pprint import pprint, pformat
@@ -26,7 +27,6 @@ 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
@@ -42,7 +42,7 @@ class NetTestController:
self._res_serializer = res_serializer
self._remote_capture_files = {}
self._config = config
- self._logServer = logServer
+ self._log_root_path = Logs.root_path
self._command_context = NetTestCommandContext()
self._machine_pool = MachinePool(config.get_option('environment',
'pool_dirs'))
@@ -236,8 +236,8 @@ class NetTestController:
self._init_slave_session(machine_id)
if not "rpc" in info:
- self._init_slave_rpc(machine_id)
self._init_slave_logging(machine_id)
+ self._init_slave_rpc(machine_id)
info["configured_interfaces"] = []
@@ -290,13 +290,20 @@ class NetTestController:
def _init_slave_logging(self, machine_id):
info = self._get_machineinfo(machine_id)
- logServer = self._logServer
+ address = socket.gethostbyname(info["hostname"])
- hostname = info["hostname"]
- port = str(DEFAULT_LOG_PORT)
+ slave_root_path = os.path.join(self._log_root_path, address)
+ try:
+ os.mkdir(slave_root_path)
+ except OSError, e:
+ if e.errno != 17:
+ raise
+
+ logger = logging.getLogger(address)
+ Logs(Logs.debug, False, logger, log_root=slave_root_path,
+ to_display=False, date="")
- logging.info("Connecting to the logging server on machine %s", hostname)
- logServer.addSlave(hostname, port)
+ info['logger'] = logger
def _deconfigure_slaves(self):
if 'machines' not in self._recipe:
@@ -526,5 +533,21 @@ class NetTestController:
def _rpc_call(self, machine_id, method_name, *args):
rpc = self._get_machinerpc(machine_id)
rpc_method = getattr(rpc, method_name)
+
result = rpc_method(*args)
+
+ logs = rpc.get_new_logs()
+ self._add_client_logs(machine_id, logs)
return result
+
+ def _add_client_logs(self, machine_id, logs):
+ info = self._get_machineinfo(machine_id)
+ address = socket.gethostbyname(info['hostname'])
+ logger = info['logger']
+
+ for log in logs:
+ data = log.data
+ data = pickle.loads(data)
+ data['address'] = '(' + address + ')'
+ record = logging.makeLogRecord(data)
+ logger.handle(record)
diff --git a/NetTest/NetTestSlave.py b/NetTest/NetTestSlave.py
index de44618..cca32a9 100644
--- a/NetTest/NetTestSlave.py
+++ b/NetTest/NetTestSlave.py
@@ -40,6 +40,11 @@ class NetTestSlaveXMLRPC:
def hello(self):
return "hello"
+ def get_new_logs(self):
+ buffer = Logs.get_buffer()
+ logs = buffer.flush()
+ return logs
+
def set_logging(self, logger_address, port):
"""
Server side setup logging to server side.
11 years, 6 months
[lnst] LoggingHandler: add a new handler
by Jiří Pírko
commit d27ec26c8f6bac53db63a9345db15872fb8a9d30
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 12 12:51:08 2012 +0200
LoggingHandler: add a new handler
This patch adds a new handler that is used for storing logged messages
so that they can be retrieved later.
It also replases the ServerHandler that was used by the slave machines
to send logs to the controller.
For now the Server handler can stay as I don't know if it might come in
handy later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/LoggingHandler.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++
Common/Logs.py | 10 ++++++--
2 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/Common/LoggingHandler.py b/Common/LoggingHandler.py
index 9b08f9d..cfcacb3 100644
--- a/Common/LoggingHandler.py
+++ b/Common/LoggingHandler.py
@@ -1,4 +1,11 @@
"""
+Custom logging handlers we use.
+
+LogBuffer
+Handler used solely for temporarily storing messages so that they can be
+retrieved later.
+
+ServerHandler
Server-like logging handler.
Stores logged messages in a buffer. Every time a new message is emitted it
checks for incoming connections. If a connection is established it flushes the
@@ -15,9 +22,53 @@ olichtne(a)redhat.com (Ondrej Lichtner)
import socket, struct, pickle
import logging
+import xmlrpclib
DEFAULT_LOG_PORT = 9998
+class LogBuffer(logging.Handler):
+ """
+ Handler used for buffering log messages. Compared to the BufferingHandler
+ defined in Python it doesn't have a capacity. It is intended to be used
+ solely as a temporary storage of logged messages so that they can be later
+ retrieved.
+ """
+ def __init__(self):
+ logging.Handler.__init__(self)
+ self.buffer = []
+
+ def makePickle(self, record):
+ """
+ Pickles the record in binary format with a length prefix, and
+ returns it ready for transmission across the socket.
+
+ Function taken from class SocketHandler from standard python
+ library logging.handlers
+ """
+ d = dict(record.__dict__)
+ d['msg'] = record.getMessage()
+ d['args'] = None
+ d['exc_info'] = None
+ s = pickle.dumps(d, 1)
+ return xmlrpclib.Binary(s)
+
+ def emit(self, record):
+ s = self.makePickle(record)
+ self.buffer.append(s)
+
+ def flush(self):
+ self.acquire()
+
+ buf = list(self.buffer)
+ self.buffer = []
+
+ self.release()
+ return buf
+
+ def close(self):
+ self.flush()
+ logging.Handler.close(self)
+
class ServerHandler(logging.Handler):
def __init__(self, port=DEFAULT_LOG_PORT):
logging.Handler.__init__(self)
diff --git a/Common/Logs.py b/Common/Logs.py
index 85099d4..0badfe5 100644
--- a/Common/Logs.py
+++ b/Common/Logs.py
@@ -13,7 +13,7 @@ import os, sys, shutil, datetime
from logging import Formatter
import logging.handlers
import traceback
-from Common.LoggingHandler import ServerHandler
+from Common.LoggingHandler import ServerHandler, LogBuffer
LOCAL_IP = "(127.0.0.1)"
@@ -267,6 +267,9 @@ class Logs:
def get_logging_root_path(cls):
return cls.root_path
+ @classmethod
+ def get_buffer(cls):
+ return cls.buffer
@classmethod
def prepare_logging(cls, debug=0, waitForNet=False,
@@ -290,8 +293,9 @@ class Logs:
root_logger.addHandler(display)
if waitForNet:
- server_handler = ServerHandler()
- root_logger.addHandler(server_handler)
+ handler = LogBuffer()
+ cls.buffer = handler
+ root_logger.addHandler(handler)
log_root_folder = cls.set_logging_root_path(recipe_path)
11 years, 6 months
[lnst] NetTestController: encapsulate rpc calls into a new method
by Jiří Pírko
commit 36466aa9860ead1b080a071d3b78ca7859b8b90c
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 12 12:51:07 2012 +0200
NetTestController: encapsulate rpc calls into a new method
This patch adds a new function _rpc_call to the class NetTestController
which is now used to make rpc method calls. The reason behind this is
that we want to collect slave logs using a new rpc method that will be
added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
NetTest/NetTestController.py | 55 +++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index dbbaffc..9b95798 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -117,7 +117,6 @@ class NetTestController:
def _prepare_device(self, machine_id, dev_id):
info = self._get_machineinfo(machine_id)
- rpc = self._get_machinerpc(machine_id)
dev = self._recipe["machines"][machine_id]["netdevices"][dev_id]
dev_net_name = dev["network"]
@@ -135,7 +134,8 @@ class NetTestController:
raise NetTestError(msg)
if "hwaddr" in dev:
- query_result = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ query_result = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if query_result:
msg = "Device with hwaddr %s already exists" \
% dev["hwaddr"]
@@ -143,7 +143,8 @@ class NetTestController:
else:
while True:
dev["hwaddr"] = self._mac_pool.get_addr()
- query_result = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ query_result = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if not len(query_result):
break
@@ -178,7 +179,8 @@ class NetTestController:
info['created_devices'] = []
info['created_devices'].append((dev_id, dev))
- phys_devs = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ phys_devs = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if len(phys_devs) == 1:
pass
elif len(phys_devs) < 1:
@@ -191,21 +193,21 @@ class NetTestController:
raise NetTestError(msg)
def _device_ready(self, machine_id, dev_id):
- rpc = self._get_machinerpc(machine_id)
dev = self._recipe["machines"][machine_id]["netdevices"][dev_id]
- devs = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ devs = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
return len(devs) > 0
def _prepare_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
info = self._get_machineinfo(machine_id)
logging.info("Configuring interface %s on %s", netdev_config_id,
info["hostname"])
self._configure_interface(machine_id, netdev_config_id)
- if_info = rpc.get_interface_info(netdev_config_id)
+ if_info = self._rpc_call(machine_id,
+ 'get_interface_info', netdev_config_id)
machine = self._recipe["machines"][machine_id]
if "name" in if_info:
machine["netconfig"][netdev_config_id]["name"] = if_info["name"]
@@ -213,15 +215,14 @@ class NetTestController:
info["configured_interfaces"].append(netdev_config_id)
def _configure_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
netconfig = self._recipe["machines"][machine_id]["netconfig"]
dev_config = netconfig[netdev_config_id]
- rpc.configure_interface(netdev_config_id, dev_config)
+ self._rpc_call(machine_id,
+ 'configure_interface', netdev_config_id, dev_config)
def _deconfigure_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
- rpc.deconfigure_interface(netdev_config_id)
+ self._rpc_call(machine_id, 'deconfigure_interface', netdev_config_id)
def _prepare_slave(self, machine_id):
logging.info("Preparing machine %s", machine_id)
@@ -240,8 +241,6 @@ class NetTestController:
info["configured_interfaces"] = []
- rpc = self._get_machinerpc(machine_id)
-
# Some additional initialization is necessary in case the
# underlying machine is provisioned from the pool
prov_id = self._machine_pool.get_provisioner_id(machine_id)
@@ -249,10 +248,10 @@ class NetTestController:
provisioner = self._machine_pool.get_provisioner(machine_id)
logging.info("Initializing provisioned system (%s)" % prov_id)
for device in provisioner["netdevices"].itervalues():
- rpc.set_device_down(device["hwaddr"])
+ self._rpc_call(machine_id, 'set_device_down', device["hwaddr"])
if self._docleanup:
- rpc.machine_cleanup()
+ self._rpc_call(machine_id, 'machine_cleanup')
def _init_slave_session(self, machine_id):
info = self._get_machineinfo(machine_id)
@@ -282,14 +281,13 @@ class NetTestController:
url = "http://%s:%d" % (hostname, port)
rpc = ServerProxy(url, allow_none = True)
- if rpc.hello() != "hello":
+ info["rpc"] = rpc
+ if self._rpc_call(machine_id, 'hello') != "hello":
msg = "Unable to establish RPC connection to machine %s. " \
% hostname
msg += "Handshake failed"
raise NetTestError(msg)
- info["rpc"] = rpc
-
def _init_slave_logging(self, machine_id):
info = self._get_machineinfo(machine_id)
logServer = self._logServer
@@ -307,9 +305,8 @@ class NetTestController:
info = self._get_machineinfo(machine_id)
if "rpc" not in info:
continue
- rpc = self._get_machinerpc(machine_id)
for if_id in reversed(info["configured_interfaces"]):
- rpc.deconfigure_interface(if_id)
+ self._rpc_call(machine_id, 'deconfigure_interface', if_id)
# detach dynamically created devices
if "created_devices" not in info:
@@ -359,13 +356,12 @@ class NetTestController:
if machine_id == "0":
cmd_res = NetTestCommand(self._command_context, command).run()
else:
- rpc = self._get_machinerpc(machine_id)
if "timeout" in command:
timeout = command["timeout"]
logging.debug("Setting socket timeout to \"%d\"", timeout)
socket.setdefaulttimeout(timeout)
try:
- cmd_res = rpc.run_command(command)
+ cmd_res = self._rpc_call(machine_id, 'run_command', command)
except socket.timeout:
msg = "RPC connection to machine %s timed out" % machine_id
raise NetTestError(msg)
@@ -462,15 +458,14 @@ class NetTestController:
def _start_packet_capture(self):
logging.info("Starting packet capture")
for machine_id in self._recipe["machines"]:
- rpc = self._get_machinerpc(machine_id)
- capture_files = rpc.start_packet_capture("")
+ capture_files = self._rpc_call(machine_id,
+ 'start_packet_capture', "")
self._remote_capture_files[machine_id] = capture_files
def _stop_packet_capture(self):
logging.info("Stopping packet capture")
for machine_id in self._recipe["machines"]:
- rpc = self._get_machinerpc(machine_id)
- rpc.stop_packet_capture()
+ self._rpc_call(machine_id, 'stop_packet_capture')
def _gather_capture_files(self):
logging_root = Logs.get_logging_root_path()
@@ -527,3 +522,9 @@ class NetTestController:
seq = {"commands": [command], "quit_on_fail": "no"}
self._run_command_sequence(seq)
info["system_config"] = {}
+
+ def _rpc_call(self, machine_id, method_name, *args):
+ rpc = self._get_machinerpc(machine_id)
+ rpc_method = getattr(rpc, method_name)
+ result = rpc_method(*args)
+ return result
11 years, 6 months
LNST Packaging Issues
by Radek Pazdera
Hi!
I dived into packaging LNST for Fedora. Right now I'm exploring the
standard python way of installing packages through distutils (setup.py).
There's a couple of problems that we need to address before we proceed
to the packaging itself.
Installation of a python program works like this:
* packages (in our case Common, NetConfig, NetTest etc.) go to
/usr/lib/python2.7/site-packages/lnst/
* scripts (in our case nettestctl.py, nettestslave.py, netconfig.py)
go directly to
/usr/bin/
* data files (in our case test_tools/*, lnst.conf.example etc.) go
to wherever we want, so probably
/usr/share/lnst/
So we need to remove any fixed paths from the code. This will be
necessary at least for the multicast test suite. We already discussed
it.
We will probably need the system-wide configuration anyway to tell
LNST where to look for the /usr/share data (because the installation
can be performed with a different prefix).
We should also think about removing the '.py' from the executables,
since they will be available system-wide from $PATH.
Another problem is with remote execution of nettestslave.py. Currently,
LNST wraps up everything it has and sends itself over to all the slave
machines. This will not be possible any more since it will be scattered
all over the system. The executable doesn't know where are the packages
loaded from (since they're in sys.path).
We will probably need to create the archive during the installation and
keep it in /usr/share/lnst.
We should definitely discuss this at some meeting. Maybe tomorrow?
-Radek
11 years, 6 months
[lnst trac] #40: Doc: Recipe XML Format Reference on Wiki
by fedora-badges
#40: Doc: Recipe XML Format Reference on Wiki
------------------------+-------------------------------------------------
Reporter: rpazdera | Owner: somebody
Type: task | Status: new
Priority: major | Milestone: Push LNST as a package into Fedora
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
------------------------+-------------------------------------------------
There should be a detailed recipe format reference/guide for users to
learn what options do they have.
This could be also a good documentation for us.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/40>
lnst <http://example.org/>
My example project
11 years, 6 months
[lnst trac] #38: Catch Exceptions on the Top Level in nettestctl.py
by fedora-badges
#38: Catch Exceptions on the Top Level in nettestctl.py
------------------------+-------------------------------------------------
Reporter: rpazdera | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone: Push LNST as a package into Fedora
Component: component1 | Version:
Keywords: | Blocked By:
Blocking: |
------------------------+-------------------------------------------------
If something goes wrong in LNST, it exits with a traceback. This can be
very annoying as well as intimidating to the (potential) users. Standard
configuration and user errors should be caught and only the message should
be printed to stderr.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/38>
lnst <http://example.org/>
My example project
11 years, 6 months
[PATCH 1/4] NetTestController: encapsulate rpc calls into a new method
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch adds a new function _rpc_call to the class NetTestController
which is now used to make rpc method calls. The reason behind this is
that we want to collect slave logs using a new rpc method that will be
added later.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
NetTest/NetTestController.py | 55 ++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index dbbaffc..9b95798 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -117,7 +117,6 @@ class NetTestController:
def _prepare_device(self, machine_id, dev_id):
info = self._get_machineinfo(machine_id)
- rpc = self._get_machinerpc(machine_id)
dev = self._recipe["machines"][machine_id]["netdevices"][dev_id]
dev_net_name = dev["network"]
@@ -135,7 +134,8 @@ class NetTestController:
raise NetTestError(msg)
if "hwaddr" in dev:
- query_result = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ query_result = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if query_result:
msg = "Device with hwaddr %s already exists" \
% dev["hwaddr"]
@@ -143,7 +143,8 @@ class NetTestController:
else:
while True:
dev["hwaddr"] = self._mac_pool.get_addr()
- query_result = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ query_result = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if not len(query_result):
break
@@ -178,7 +179,8 @@ class NetTestController:
info['created_devices'] = []
info['created_devices'].append((dev_id, dev))
- phys_devs = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ phys_devs = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
if len(phys_devs) == 1:
pass
elif len(phys_devs) < 1:
@@ -191,21 +193,21 @@ class NetTestController:
raise NetTestError(msg)
def _device_ready(self, machine_id, dev_id):
- rpc = self._get_machinerpc(machine_id)
dev = self._recipe["machines"][machine_id]["netdevices"][dev_id]
- devs = rpc.get_devices_by_hwaddr(dev["hwaddr"])
+ devs = self._rpc_call(machine_id,
+ 'get_devices_by_hwaddr', dev["hwaddr"])
return len(devs) > 0
def _prepare_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
info = self._get_machineinfo(machine_id)
logging.info("Configuring interface %s on %s", netdev_config_id,
info["hostname"])
self._configure_interface(machine_id, netdev_config_id)
- if_info = rpc.get_interface_info(netdev_config_id)
+ if_info = self._rpc_call(machine_id,
+ 'get_interface_info', netdev_config_id)
machine = self._recipe["machines"][machine_id]
if "name" in if_info:
machine["netconfig"][netdev_config_id]["name"] = if_info["name"]
@@ -213,15 +215,14 @@ class NetTestController:
info["configured_interfaces"].append(netdev_config_id)
def _configure_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
netconfig = self._recipe["machines"][machine_id]["netconfig"]
dev_config = netconfig[netdev_config_id]
- rpc.configure_interface(netdev_config_id, dev_config)
+ self._rpc_call(machine_id,
+ 'configure_interface', netdev_config_id, dev_config)
def _deconfigure_interface(self, machine_id, netdev_config_id):
- rpc = self._get_machinerpc(machine_id)
- rpc.deconfigure_interface(netdev_config_id)
+ self._rpc_call(machine_id, 'deconfigure_interface', netdev_config_id)
def _prepare_slave(self, machine_id):
logging.info("Preparing machine %s", machine_id)
@@ -240,8 +241,6 @@ class NetTestController:
info["configured_interfaces"] = []
- rpc = self._get_machinerpc(machine_id)
-
# Some additional initialization is necessary in case the
# underlying machine is provisioned from the pool
prov_id = self._machine_pool.get_provisioner_id(machine_id)
@@ -249,10 +248,10 @@ class NetTestController:
provisioner = self._machine_pool.get_provisioner(machine_id)
logging.info("Initializing provisioned system (%s)" % prov_id)
for device in provisioner["netdevices"].itervalues():
- rpc.set_device_down(device["hwaddr"])
+ self._rpc_call(machine_id, 'set_device_down', device["hwaddr"])
if self._docleanup:
- rpc.machine_cleanup()
+ self._rpc_call(machine_id, 'machine_cleanup')
def _init_slave_session(self, machine_id):
info = self._get_machineinfo(machine_id)
@@ -282,14 +281,13 @@ class NetTestController:
url = "http://%s:%d" % (hostname, port)
rpc = ServerProxy(url, allow_none = True)
- if rpc.hello() != "hello":
+ info["rpc"] = rpc
+ if self._rpc_call(machine_id, 'hello') != "hello":
msg = "Unable to establish RPC connection to machine %s. " \
% hostname
msg += "Handshake failed"
raise NetTestError(msg)
- info["rpc"] = rpc
-
def _init_slave_logging(self, machine_id):
info = self._get_machineinfo(machine_id)
logServer = self._logServer
@@ -307,9 +305,8 @@ class NetTestController:
info = self._get_machineinfo(machine_id)
if "rpc" not in info:
continue
- rpc = self._get_machinerpc(machine_id)
for if_id in reversed(info["configured_interfaces"]):
- rpc.deconfigure_interface(if_id)
+ self._rpc_call(machine_id, 'deconfigure_interface', if_id)
# detach dynamically created devices
if "created_devices" not in info:
@@ -359,13 +356,12 @@ class NetTestController:
if machine_id == "0":
cmd_res = NetTestCommand(self._command_context, command).run()
else:
- rpc = self._get_machinerpc(machine_id)
if "timeout" in command:
timeout = command["timeout"]
logging.debug("Setting socket timeout to \"%d\"", timeout)
socket.setdefaulttimeout(timeout)
try:
- cmd_res = rpc.run_command(command)
+ cmd_res = self._rpc_call(machine_id, 'run_command', command)
except socket.timeout:
msg = "RPC connection to machine %s timed out" % machine_id
raise NetTestError(msg)
@@ -462,15 +458,14 @@ class NetTestController:
def _start_packet_capture(self):
logging.info("Starting packet capture")
for machine_id in self._recipe["machines"]:
- rpc = self._get_machinerpc(machine_id)
- capture_files = rpc.start_packet_capture("")
+ capture_files = self._rpc_call(machine_id,
+ 'start_packet_capture', "")
self._remote_capture_files[machine_id] = capture_files
def _stop_packet_capture(self):
logging.info("Stopping packet capture")
for machine_id in self._recipe["machines"]:
- rpc = self._get_machinerpc(machine_id)
- rpc.stop_packet_capture()
+ self._rpc_call(machine_id, 'stop_packet_capture')
def _gather_capture_files(self):
logging_root = Logs.get_logging_root_path()
@@ -527,3 +522,9 @@ class NetTestController:
seq = {"commands": [command], "quit_on_fail": "no"}
self._run_command_sequence(seq)
info["system_config"] = {}
+
+ def _rpc_call(self, machine_id, method_name, *args):
+ rpc = self._get_machinerpc(machine_id)
+ rpc_method = getattr(rpc, method_name)
+ result = rpc_method(*args)
+ return result
--
1.7.11.7
11 years, 6 months