commit 881ec6610375d20e7f36917486d5a5207c2bf2ba
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Apr 19 12:49:26 2013 +0200
lnst-ctl: Allow only eth interfaces in pool
This patch restricts putting any other interfaces than eth to the pool
configuration files.
These change required some changes in the error handling. The exceptions
are now logged in the lnst-ctl file directly, so all exceptions comming
from the NetTestController class will be caught.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst-ctl | 9 +++++----
lnst/Controller/NetTestController.py | 31 +++++++++++--------------------
lnst/Controller/SlaveMachineParse.py | 11 ++++++++---
3 files changed, 24 insertions(+), 27 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 17ce6cd..26b15e1 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -17,7 +17,7 @@ import logging
import os
import re
import datetime
-from lnst.Common.Logs import LoggingCtl
+from lnst.Common.Logs import LoggingCtl, log_exc_traceback
from lnst.Common.Config import Config
from lnst.Controller.NetTestController import NetTestController, NetTestError
from lnst.Controller.NetTestResultSerializer import NetTestResultSerializer
@@ -72,9 +72,10 @@ def get_recipe_result(args, file_path, cleanup,
res = None
try:
- res = process_recipe(args, file_path, cleanup,
- res_serializer, packet_capture, config, log_ctl)
- except NetTestError as err:
+ res = process_recipe(args, file_path, cleanup, res_serializer,
+ packet_capture, config, log_ctl)
+ except Exception as err:
+ log_exc_traceback()
logging.error(err)
return ((file_path, res))
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index bf80fbe..8adde13 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -20,7 +20,6 @@ import tempfile
from time import sleep
from xmlrpclib import Binary
from pprint import pprint, pformat
-from lnst.Common.Logs import log_exc_traceback
from lnst.Common.XmlRpc import ServerProxy, ServerException
from lnst.Common.NetUtils import MacPool
from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
@@ -179,11 +178,10 @@ class NetTestController:
try:
self._parser.parse_recipe()
except Exception as exc:
- logging.debug("Exception raised during recipe parsing. "\
- "Deconfiguring machines.")
- log_exc_traceback()
+ logging.error("Exception raised during recipe parsing. "\
+ "Deconfiguring machines.")
self._cleanup_slaves()
- raise NetTestError(exc)
+ raise
def _run_command(self, command):
if "desc" in command:
@@ -237,23 +235,16 @@ class NetTestController:
err = None
try:
res = self._run_recipe()
- except ServerException as exc:
- err = NetTestError(exc)
except Exception as exc:
- logging.info("Recipe execution terminated by unexpected
exception")
- log_exc_traceback()
- err = exc
-
- if packet_capture:
- self._stop_packet_capture()
- self._gather_capture_files()
-
- self._cleanup_slaves()
+ logging.error("Recipe execution terminated by unexpected
exception")
+ raise
+ finally:
+ if packet_capture:
+ self._stop_packet_capture()
+ self._gather_capture_files()
+ self._cleanup_slaves()
- if not err:
- return res
- else:
- raise err
+ return res
def _run_recipe(self):
overall_res = True
diff --git a/lnst/Controller/SlaveMachineParse.py b/lnst/Controller/SlaveMachineParse.py
index 0be18d6..20915c4 100644
--- a/lnst/Controller/SlaveMachineParse.py
+++ b/lnst/Controller/SlaveMachineParse.py
@@ -73,12 +73,17 @@ class SlaveMachineParse(LnstParser):
params = {"target": iface["params"]}
self._process_child_nodes(node, scheme, params)
- if "type" in iface["params"]:
- iface["type"] = iface["params"]["type"]
- else:
+ if "type" not in iface["params"]:
msg = "Missing required parameter 'type'"
raise XmlProcessingError(msg, node)
+ iface["type"] = iface["params"]["type"]
+ if iface["type"] not in ["eth"]:
+ msg = "Interface type '%s' is not allowed here. " \
+ "Interface types other than 'eth' mus be configured "
\
+ "in LNST recipes directly." % iface["type"]
+ raise XmlProcessingError(msg, node)
+
# hwaddr parameter is optional for dynamic interface,
# but it is required by non-dynamic interfaces
if iface["create"] and "hwaddr" in
iface["params"]:
Show replies by date