[lnst] lnst-ctl: Changing underscore to dash in -p option
by Jiří Pírko
commit 82a04dd56989f8bdd7927bce8c1d03a2d8454445
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Sat May 4 00:00:16 2013 +0200
lnst-ctl: Changing underscore to dash in -p option
This patch changes the underscore in the --patcket_capture long option
to a dash. Dashes are much more common.
lnst-ctl | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 68e9bec..dcb4cd2 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -32,7 +32,7 @@ def usage():
print ""
print "OPTIONS"
print " -d, --debug emit debugging messages"
- print " -p, --packet_capture capture and log all ongoing\n" \
+ print " -p, --packet-capture capture and log all ongoing\n" \
" network communication during\n" \
" the test"
print " -h, --help print this message"
@@ -94,7 +94,7 @@ def main():
sys.argv[1:],
"dhr:cx:po",
["debug", "help", "recipe=", "cleanup", "result=",
- "packet_capture", "disable-pool-checks"]
+ "packet-capture", "disable-pool-checks"]
)
except getopt.GetoptError as err:
print str(err)
@@ -133,7 +133,7 @@ def main():
cleanup = True
elif opt in ("-x", "--result"):
result_path = arg
- elif opt in ("-p", "--packet_capture"):
+ elif opt in ("-p", "--packet-capture"):
packet_capture = True
elif opt in ("-o", "--disable-pool-checks"):
pool_checks = False
10 years, 11 months
[lnst] lnst-ctl: Adding match_setup action
by Jiří Pírko
commit c9d4256ebdee45f60b9f63361f3e4bb074a6d940
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Sat May 4 00:00:15 2013 +0200
lnst-ctl: Adding match_setup action
This commit adds a new action called 'match_setup'. With this action,
the controller will only read the pool and try to match the recipe
setup to the pool. In case the match was successfull, it will print
the details of the match.
I didn't really pay that much attention to the format of the report.
That might change in the future. The important thing here are the
backend options for this functionality.
lnst-ctl | 2 +-
lnst/Controller/NetTestController.py | 26 ++++++++++++++++++++++++++
lnst/Controller/RecipeParse.py | 10 ++++++----
3 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index de74c65..68e9bec 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -28,7 +28,7 @@ def usage():
"""
print "Usage: %s [OPTION...] [RECIPE...] ACTION" % sys.argv[0]
print ""
- print "ACTION = [run | dump | config_only]"
+ print "ACTION = [run | dump | config_only | match_setup]"
print ""
print "OPTIONS"
print " -d, --debug emit debugging messages"
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index c446119..9f1c9fa 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -228,6 +228,32 @@ class NetTestController:
self._cleanup_slaves()
return True
+ def match_setup(self):
+ try:
+ self._parser.first_pass()
+ except Exception as exc:
+ logging.error("Exception raised during recipe parsing. "\
+ "Deconfiguring machines.")
+ self._cleanup_slaves()
+ raise
+
+ machines = self._recipe["machines"]
+ if len(machines) <= 0:
+ return
+
+ sp = self._slave_pool
+ machines = sp.provision_machines(machines)
+ if machines == None:
+ msg = "This setup cannot be provisioned with the current pool."
+ raise NetTestError(msg)
+
+ logging.info("Provisioning initialized")
+ for m_id in machines.keys():
+ provisioner = sp.get_provisioner_id(m_id)
+ logging.info(" machine %s matched to %s" % (m_id, provisioner))
+
+ return True
+
def config_only_recipe(self):
self._prepare()
self._cleanup_slaves(deconfigure=False)
diff --git a/lnst/Controller/RecipeParse.py b/lnst/Controller/RecipeParse.py
index 8445a0e..9a91a7c 100644
--- a/lnst/Controller/RecipeParse.py
+++ b/lnst/Controller/RecipeParse.py
@@ -28,18 +28,20 @@ class RecipeParse(LnstParser):
self._rp = RecipePath(None, self._filepath)
self._include_root = self._rp.get_root()
- def parse_recipe(self):
+ def first_pass(self):
dom_init = XmlDomTreeInit()
rp = self._rp
- xml_dom = dom_init.parse_string(rp.to_str(), rp.abs_path())
+ self._xml_dom = dom_init.parse_string(rp.to_str(), rp.abs_path())
first_pass = FirstPass(self)
- first_pass.parse(xml_dom)
+ first_pass.parse(self._xml_dom)
+ def parse_recipe(self):
+ self.first_pass()
self._trigger_event("provisioning_requirements_ready", {})
second_pass = SecondPass(self)
- second_pass.parse(xml_dom)
+ second_pass.parse(self._xml_dom)
class FirstPass(LnstParser):
10 years, 11 months
[lnst] lnst-ctl: Adding disable_pool_checks option
by Jiří Pírko
commit d57b16d443c0bc324eeea71b458b5500f7f48e6b
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Sat May 4 00:00:14 2013 +0200
lnst-ctl: Adding disable_pool_checks option
This commit adds a new option to the controller. Using this option will
disable the checks that are performed by LNST during startup on pool
machines.
Option:
-o
--disable-pool-checks
Some minor cleanup has been done on a few places nearby.
lnst-ctl | 29 ++++++++++++-------
lnst/Controller/NetTestController.py | 4 +-
lnst/Controller/SlavePool.py | 50 +++++++++++++++++++---------------
3 files changed, 48 insertions(+), 35 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 26b15e1..de74c65 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -36,21 +36,26 @@ def usage():
" network communication during\n" \
" the test"
print " -h, --help print this message"
+ print " -o, --disable-pool-checks don't check the availability of\n"\
+ " machines in the pool"
print " -c, --cleanup perform config cleanup\n" \
" machines"
print " -x, --result=FILE file to write xml_result"
sys.exit()
def process_recipe(action, file_path, cleanup, res_serializer,
- packet_capture, config, log_ctl):
+ packet_capture, config, log_ctl, pool_checks):
nettestctl = NetTestController(file_path, log_ctl, cleanup=cleanup,
- res_serializer=res_serializer, config=config)
+ res_serializer=res_serializer,
+ config=config, pool_checks=pool_checks)
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
return nettestctl.dump_recipe()
elif action == "config_only":
return nettestctl.config_only_recipe()
+ elif action == "match_setup":
+ return nettestctl.match_setup()
else:
logging.error("Unknown action \"%s\"" % action)
usage();
@@ -65,15 +70,15 @@ def print_summary(summary):
logging.info("*%s* %s" % (res, recipe_file))
logging.info("=====================================================")
-def get_recipe_result(args, file_path, cleanup,
- res_serializer, packet_capture, config, log_ctl):
+def get_recipe_result(args, file_path, cleanup, res_serializer, packet_capture,
+ config, log_ctl, pool_checks):
res_serializer.add_recipe(file_path)
log_ctl.set_recipe(file_path)
res = None
try:
res = process_recipe(args, file_path, cleanup, res_serializer,
- packet_capture, config, log_ctl)
+ packet_capture, config, log_ctl, pool_checks)
except Exception as err:
log_exc_traceback()
logging.error(err)
@@ -87,9 +92,9 @@ def main():
try:
opts, args = getopt.getopt(
sys.argv[1:],
- "dhr:cx:p",
+ "dhr:cx:po",
["debug", "help", "recipe=", "cleanup", "result=",
- "packet_capture"]
+ "packet_capture", "disable-pool-checks"]
)
except getopt.GetoptError as err:
print str(err)
@@ -113,12 +118,12 @@ def main():
with open(usr_cfg, 'w') as f:
f.write(config.dump_config())
-
debug = 0
recipe_path = None
cleanup = False
result_path = None
packet_capture = False
+ pool_checks = True
for opt, arg in opts:
if opt in ("-d", "--debug"):
debug += 1
@@ -130,7 +135,8 @@ def main():
result_path = arg
elif opt in ("-p", "--packet_capture"):
packet_capture = True
-
+ elif opt in ("-o", "--disable-pool-checks"):
+ pool_checks = False
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
log_ctl = LoggingCtl(debug,
@@ -162,12 +168,13 @@ def main():
cleanup,
res_serializer,
packet_capture,
- config, log_ctl))
+ config, log_ctl,
+ pool_checks))
else:
summary.append(get_recipe_result(action, recipe_path,
cleanup, res_serializer,
packet_capture,
- config, log_ctl))
+ config, log_ctl, pool_checks))
log_ctl.set_recipe("", clean=False)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 169f0af..c446119 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -41,7 +41,7 @@ def ignore_event(**kwarg):
class NetTestController:
def __init__(self, recipe_path, log_ctl, cleanup=False,
- res_serializer=None, config=None):
+ res_serializer=None, config=None, pool_checks=True):
self._docleanup = cleanup
self._res_serializer = res_serializer
self._remote_capture_files = {}
@@ -51,7 +51,7 @@ class NetTestController:
self._msg_dispatcher = MessageDispatcher(log_ctl)
sp = SlavePool(config.get_option('environment', 'pool_dirs'),
- check_process_running("libvirtd"), config)
+ check_process_running("libvirtd"), config, pool_checks)
self._slave_pool = sp
self._machines = {}
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 80a357c..b875d59 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -35,11 +35,14 @@ class SlavePool:
_machine_matches = []
_network_matches = []
- _allow_virtual = False
+ _allow_virt = False
+ _pool_checks = True
- def __init__(self, pool_dirs, allow_virtual=False, config=None):
+ def __init__(self, pool_dirs, allow_virtual=False, config=None,
+ pool_checks=True):
self._config = config
- self._allow_virtual = allow_virtual
+ self._allow_virt = allow_virtual
+ self._pool_checks = pool_checks
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
@@ -61,30 +64,33 @@ class SlavePool:
parser.disable_events()
machine = {"params": {}, "interfaces": {}}
- machine_id = re.sub("\.[xX][mM][lL]$", "", basename)
- parser.set_machine(machine_id, machine)
+ m_id = re.sub("\.[xX][mM][lL]$", "", basename)
+ parser.set_machine(m_id, machine)
slavemachine = dom.getElementsByTagName("slavemachine")[0]
parser.parse(slavemachine)
- hostname = machine["params"]["hostname"]
- if "rpcport" in machine:
- port = machine["params"]["rpcport"]
- else:
- port = self._config.get_option('environment', 'rpcport')
- logging.info("Querying slave machine %s." % machine_id)
- if not test_tcp_connection(hostname, port):
- return
-
- if 'libvirt_domain' not in machine['params'] \
- or self._allow_virtual:
- logging.info("Adding slave machine %s to slave pool."
- % machine_id)
- self._pool[machine_id] = machine
- else:
- logging.warning("libvirtd not found- Machine Pool skipping "\
- "machine %s" % machine_id)
+ if self._pool_checks:
+ hostname = machine["params"]["hostname"]
+ if "rpcport" in machine:
+ port = machine["params"]["rpcport"]
+ else:
+ port = self._config.get_option('environment', 'rpcport')
+
+ logging.info("Querying slave machine %s." % m_id)
+ if not test_tcp_connection(hostname, port):
+ msg = "Machine '%s' not responding. Skipping." % m_id
+ logging.warning(msg)
+ return
+
+ if 'libvirt_domain' in machine['params'] and \
+ not self._allow_virt:
+ msg = "libvird not running. Skipping machine '%s'." % m_id
+ logging.warning(msg)
+
+ logging.info("Adding slave machine %s to slave pool." % m_id)
+ self._pool[m_id] = machine
def provision_machines(self, mreqs):
"""
10 years, 11 months
[PATCH] lnst-ctl: Adding disable_pool_checks option
by Radek Pazdera
This commit adds a new option to the controller. Using this option will
disable the checks that are performed by LNST during startup on pool
machines.
Option:
-o
--disable-pool-checks
Some minor cleanup has been done on a few places nearby.
---
lnst-ctl | 29 ++++++++++++-------
lnst/Controller/NetTestController.py | 4 +-
lnst/Controller/SlavePool.py | 50 +++++++++++++++++++---------------
3 files changed, 48 insertions(+), 35 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 26b15e1..de74c65 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -36,21 +36,26 @@ def usage():
" network communication during\n" \
" the test"
print " -h, --help print this message"
+ print " -o, --disable-pool-checks don't check the availability of\n"\
+ " machines in the pool"
print " -c, --cleanup perform config cleanup\n" \
" machines"
print " -x, --result=FILE file to write xml_result"
sys.exit()
def process_recipe(action, file_path, cleanup, res_serializer,
- packet_capture, config, log_ctl):
+ packet_capture, config, log_ctl, pool_checks):
nettestctl = NetTestController(file_path, log_ctl, cleanup=cleanup,
- res_serializer=res_serializer, config=config)
+ res_serializer=res_serializer,
+ config=config, pool_checks=pool_checks)
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
return nettestctl.dump_recipe()
elif action == "config_only":
return nettestctl.config_only_recipe()
+ elif action == "match_setup":
+ return nettestctl.match_setup()
else:
logging.error("Unknown action \"%s\"" % action)
usage();
@@ -65,15 +70,15 @@ def print_summary(summary):
logging.info("*%s* %s" % (res, recipe_file))
logging.info("=====================================================")
-def get_recipe_result(args, file_path, cleanup,
- res_serializer, packet_capture, config, log_ctl):
+def get_recipe_result(args, file_path, cleanup, res_serializer, packet_capture,
+ config, log_ctl, pool_checks):
res_serializer.add_recipe(file_path)
log_ctl.set_recipe(file_path)
res = None
try:
res = process_recipe(args, file_path, cleanup, res_serializer,
- packet_capture, config, log_ctl)
+ packet_capture, config, log_ctl, pool_checks)
except Exception as err:
log_exc_traceback()
logging.error(err)
@@ -87,9 +92,9 @@ def main():
try:
opts, args = getopt.getopt(
sys.argv[1:],
- "dhr:cx:p",
+ "dhr:cx:po",
["debug", "help", "recipe=", "cleanup", "result=",
- "packet_capture"]
+ "packet_capture", "disable-pool-checks"]
)
except getopt.GetoptError as err:
print str(err)
@@ -113,12 +118,12 @@ def main():
with open(usr_cfg, 'w') as f:
f.write(config.dump_config())
-
debug = 0
recipe_path = None
cleanup = False
result_path = None
packet_capture = False
+ pool_checks = True
for opt, arg in opts:
if opt in ("-d", "--debug"):
debug += 1
@@ -130,7 +135,8 @@ def main():
result_path = arg
elif opt in ("-p", "--packet_capture"):
packet_capture = True
-
+ elif opt in ("-o", "--disable-pool-checks"):
+ pool_checks = False
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
log_ctl = LoggingCtl(debug,
@@ -162,12 +168,13 @@ def main():
cleanup,
res_serializer,
packet_capture,
- config, log_ctl))
+ config, log_ctl,
+ pool_checks))
else:
summary.append(get_recipe_result(action, recipe_path,
cleanup, res_serializer,
packet_capture,
- config, log_ctl))
+ config, log_ctl, pool_checks))
log_ctl.set_recipe("", clean=False)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 62600ca..1f47de5 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -41,7 +41,7 @@ def ignore_event(**kwarg):
class NetTestController:
def __init__(self, recipe_path, log_ctl, cleanup=False,
- res_serializer=None, config=None):
+ res_serializer=None, config=None, pool_checks=True):
self._docleanup = cleanup
self._res_serializer = res_serializer
self._remote_capture_files = {}
@@ -51,7 +51,7 @@ class NetTestController:
self._msg_dispatcher = MessageDispatcher(log_ctl)
sp = SlavePool(config.get_option('environment', 'pool_dirs'),
- check_process_running("libvirtd"), config)
+ check_process_running("libvirtd"), config, pool_checks)
self._slave_pool = sp
self._machines = {}
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 80a357c..b875d59 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -35,11 +35,14 @@ class SlavePool:
_machine_matches = []
_network_matches = []
- _allow_virtual = False
+ _allow_virt = False
+ _pool_checks = True
- def __init__(self, pool_dirs, allow_virtual=False, config=None):
+ def __init__(self, pool_dirs, allow_virtual=False, config=None,
+ pool_checks=True):
self._config = config
- self._allow_virtual = allow_virtual
+ self._allow_virt = allow_virtual
+ self._pool_checks = pool_checks
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
@@ -61,30 +64,33 @@ class SlavePool:
parser.disable_events()
machine = {"params": {}, "interfaces": {}}
- machine_id = re.sub("\.[xX][mM][lL]$", "", basename)
- parser.set_machine(machine_id, machine)
+ m_id = re.sub("\.[xX][mM][lL]$", "", basename)
+ parser.set_machine(m_id, machine)
slavemachine = dom.getElementsByTagName("slavemachine")[0]
parser.parse(slavemachine)
- hostname = machine["params"]["hostname"]
- if "rpcport" in machine:
- port = machine["params"]["rpcport"]
- else:
- port = self._config.get_option('environment', 'rpcport')
- logging.info("Querying slave machine %s." % machine_id)
- if not test_tcp_connection(hostname, port):
- return
-
- if 'libvirt_domain' not in machine['params'] \
- or self._allow_virtual:
- logging.info("Adding slave machine %s to slave pool."
- % machine_id)
- self._pool[machine_id] = machine
- else:
- logging.warning("libvirtd not found- Machine Pool skipping "\
- "machine %s" % machine_id)
+ if self._pool_checks:
+ hostname = machine["params"]["hostname"]
+ if "rpcport" in machine:
+ port = machine["params"]["rpcport"]
+ else:
+ port = self._config.get_option('environment', 'rpcport')
+
+ logging.info("Querying slave machine %s." % m_id)
+ if not test_tcp_connection(hostname, port):
+ msg = "Machine '%s' not responding. Skipping." % m_id
+ logging.warning(msg)
+ return
+
+ if 'libvirt_domain' in machine['params'] and \
+ not self._allow_virt:
+ msg = "libvird not running. Skipping machine '%s'." % m_id
+ logging.warning(msg)
+
+ logging.info("Adding slave machine %s to slave pool." % m_id)
+ self._pool[m_id] = machine
def provision_machines(self, mreqs):
"""
--
1.7.7.6
10 years, 11 months
[lnst] XML: Changing the 'interface' tag
by Jiří Pírko
commit 5daab9280c60ff8a13f0997ac8b72b7f327aadcc
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri May 3 14:14:02 2013 +0200
XML: Changing the 'interface' tag
This commit removes the <interface> tag from both the recipe and the
slavemachine config files. Now the interface tag's names are based
on their type.
For example an interface with type="bond" will now be represented by
a tag <bond ...>.
A slight cleanup of the slavemachine parser was done along with this
patch.
lnst/Controller/RecipeParse.py | 18 ++++++++--
lnst/Controller/SlaveMachineParse.py | 62 ++++++++-------------------------
2 files changed, 29 insertions(+), 51 deletions(-)
---
diff --git a/lnst/Controller/RecipeParse.py b/lnst/Controller/RecipeParse.py
index fe155cb..8445a0e 100644
--- a/lnst/Controller/RecipeParse.py
+++ b/lnst/Controller/RecipeParse.py
@@ -97,7 +97,12 @@ class FirstPass(LnstParser):
def _interfaces(self, node, params):
params = {"id": params["id"]}
- scheme = {"interface": self._interface}
+ scheme = {"eth": self._interface,
+ "bond": self._interface,
+ "team": self._interface,
+ "vlan": self._interface,
+ "macvlan": self._interface,
+ "bridge": self._interface}
self._process_child_nodes(node, scheme, params)
def _interface(self, node, params):
@@ -105,7 +110,7 @@ class FirstPass(LnstParser):
machine = self._data["machines"][m_id]
if_id = self._get_attribute(node, "id")
- if_type = self._get_attribute(node, "type")
+ if_type = node.tagName
if if_id in machine["interfaces"]:
msg = "Two interfaces with the same id '%s', " % if_id
@@ -205,7 +210,12 @@ class MachineParse(LnstParser):
self._process_child_nodes(node, scheme)
def _interfaces(self, node, params):
- scheme = {"interface": self._interface}
+ scheme = {"eth": self._interface,
+ "bond": self._interface,
+ "team": self._interface,
+ "vlan": self._interface,
+ "macvlan": self._interface,
+ "bridge": self._interface}
self._process_child_nodes(node, scheme)
def _interface(self, node, params):
@@ -232,7 +242,7 @@ class InterfaceParse(LnstParser):
self._machine["interfaces"][if_id] = {}
self._iface = iface = self._machine["interfaces"][if_id]
- iface["type"] = self._get_attribute(node, "type")
+ iface["type"] = node.tagName
scheme = {"addresses": self._addresses}
if iface["type"] in ["bond", "bridge", "vlan", "macvlan", "team"]:
diff --git a/lnst/Controller/SlaveMachineParse.py b/lnst/Controller/SlaveMachineParse.py
index 20915c4..4be2dc5 100644
--- a/lnst/Controller/SlaveMachineParse.py
+++ b/lnst/Controller/SlaveMachineParse.py
@@ -47,67 +47,35 @@ class SlaveMachineParse(LnstParser):
subparser.parse(node)
def _interfaces(self, node, params):
- scheme = {"interface": self._interface,
- "libvirt_create": self._libvirt_create}
+ scheme = {"eth": self._eth}
- new_params = {"create": None}
- self._process_child_nodes(node, scheme, new_params)
+ try:
+ self._process_child_nodes(node, scheme)
+ except XmlProcessingError as err:
+ msg = "Interface type other than 'eth' is not allowed here. " \
+ "Other types must be configured in LNST recipes directly."
+ logging.error(msg)
+ raise
- def _libvirt_create(self, node, params):
- scheme = {"interface": self._interface}
-
- new_params = {"create": "libvirt"}
- self._process_child_nodes(node, scheme, new_params)
-
- def _interface(self, node, params):
+ def _eth(self, node, params):
machine = self._machine
iface_id = self._get_attribute(node, "id")
iface = machine["interfaces"][iface_id] = {}
- iface["create"] = params["create"]
iface["network"] = self._get_attribute(node, "network")
iface["params"] = {}
+ iface["type"] = "eth"
# parse interface parameters
scheme = {"params": self._params}
params = {"target": iface["params"]}
self._process_child_nodes(node, scheme, params)
- 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"]:
- iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
+ if "hwaddr" in iface["params"]:
+ iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
else:
- if "hwaddr" in iface["params"]:
- iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
- else:
- msg = "Missing required parameter 'hwaddr'"
- raise XmlProcessingError(msg, node)
+ msg = "Missing required parameter 'hwaddr'"
+ raise XmlProcessingError(msg, node)
- # name parameter is only valid when the interface is not dynamic
if "name" in iface["params"]:
- if iface["create"]:
- msg = "'name' parameter is not valid with dynamic interfaces"
- raise XmlProcessingError(msg, node)
- else:
- iface["name"] = iface["params"]["name"]
-
- # bridge parameter is valid only when the interface is dynamic
- if "libvirt_bridge" in iface["params"]:
- if iface["create"] == "libvirt":
- iface["libvirt_bridge"] = iface["params"]["libvirt_bridge"]
- else:
- msg = "'libvirt_bridge' parameter is not valid with" \
- "dynamic ifaceices"
- raise XmlProcessingError(msg, node)
+ iface["name"] = iface["params"]["name"]
10 years, 11 months
[PATCH] XML: Changing the 'interface' tag
by Radek Pazdera
This commit removes the <interface> tag from both the recipe and the
slavemachine config files. Now the interface tag's names are based
on their type.
For example an interface with type="bond" will now be represented by
a tag <bond ...>.
A slight cleanup of the slavemachine parser was done along with this
patch.
---
lnst/Controller/RecipeParse.py | 18 ++++++++--
lnst/Controller/SlaveMachineParse.py | 62 ++++++++-------------------------
2 files changed, 29 insertions(+), 51 deletions(-)
diff --git a/lnst/Controller/RecipeParse.py b/lnst/Controller/RecipeParse.py
index fe155cb..8445a0e 100644
--- a/lnst/Controller/RecipeParse.py
+++ b/lnst/Controller/RecipeParse.py
@@ -97,7 +97,12 @@ class FirstPass(LnstParser):
def _interfaces(self, node, params):
params = {"id": params["id"]}
- scheme = {"interface": self._interface}
+ scheme = {"eth": self._interface,
+ "bond": self._interface,
+ "team": self._interface,
+ "vlan": self._interface,
+ "macvlan": self._interface,
+ "bridge": self._interface}
self._process_child_nodes(node, scheme, params)
def _interface(self, node, params):
@@ -105,7 +110,7 @@ class FirstPass(LnstParser):
machine = self._data["machines"][m_id]
if_id = self._get_attribute(node, "id")
- if_type = self._get_attribute(node, "type")
+ if_type = node.tagName
if if_id in machine["interfaces"]:
msg = "Two interfaces with the same id '%s', " % if_id
@@ -205,7 +210,12 @@ class MachineParse(LnstParser):
self._process_child_nodes(node, scheme)
def _interfaces(self, node, params):
- scheme = {"interface": self._interface}
+ scheme = {"eth": self._interface,
+ "bond": self._interface,
+ "team": self._interface,
+ "vlan": self._interface,
+ "macvlan": self._interface,
+ "bridge": self._interface}
self._process_child_nodes(node, scheme)
def _interface(self, node, params):
@@ -232,7 +242,7 @@ class InterfaceParse(LnstParser):
self._machine["interfaces"][if_id] = {}
self._iface = iface = self._machine["interfaces"][if_id]
- iface["type"] = self._get_attribute(node, "type")
+ iface["type"] = node.tagName
scheme = {"addresses": self._addresses}
if iface["type"] in ["bond", "bridge", "vlan", "macvlan", "team"]:
diff --git a/lnst/Controller/SlaveMachineParse.py b/lnst/Controller/SlaveMachineParse.py
index 20915c4..4be2dc5 100644
--- a/lnst/Controller/SlaveMachineParse.py
+++ b/lnst/Controller/SlaveMachineParse.py
@@ -47,67 +47,35 @@ class SlaveMachineParse(LnstParser):
subparser.parse(node)
def _interfaces(self, node, params):
- scheme = {"interface": self._interface,
- "libvirt_create": self._libvirt_create}
+ scheme = {"eth": self._eth}
- new_params = {"create": None}
- self._process_child_nodes(node, scheme, new_params)
+ try:
+ self._process_child_nodes(node, scheme)
+ except XmlProcessingError as err:
+ msg = "Interface type other than 'eth' is not allowed here. " \
+ "Other types must be configured in LNST recipes directly."
+ logging.error(msg)
+ raise
- def _libvirt_create(self, node, params):
- scheme = {"interface": self._interface}
-
- new_params = {"create": "libvirt"}
- self._process_child_nodes(node, scheme, new_params)
-
- def _interface(self, node, params):
+ def _eth(self, node, params):
machine = self._machine
iface_id = self._get_attribute(node, "id")
iface = machine["interfaces"][iface_id] = {}
- iface["create"] = params["create"]
iface["network"] = self._get_attribute(node, "network")
iface["params"] = {}
+ iface["type"] = "eth"
# parse interface parameters
scheme = {"params": self._params}
params = {"target": iface["params"]}
self._process_child_nodes(node, scheme, params)
- 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"]:
- iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
+ if "hwaddr" in iface["params"]:
+ iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
else:
- if "hwaddr" in iface["params"]:
- iface["hwaddr"] = normalize_hwaddr(iface["params"]["hwaddr"])
- else:
- msg = "Missing required parameter 'hwaddr'"
- raise XmlProcessingError(msg, node)
+ msg = "Missing required parameter 'hwaddr'"
+ raise XmlProcessingError(msg, node)
- # name parameter is only valid when the interface is not dynamic
if "name" in iface["params"]:
- if iface["create"]:
- msg = "'name' parameter is not valid with dynamic interfaces"
- raise XmlProcessingError(msg, node)
- else:
- iface["name"] = iface["params"]["name"]
-
- # bridge parameter is valid only when the interface is dynamic
- if "libvirt_bridge" in iface["params"]:
- if iface["create"] == "libvirt":
- iface["libvirt_bridge"] = iface["params"]["libvirt_bridge"]
- else:
- msg = "'libvirt_bridge' parameter is not valid with" \
- "dynamic ifaceices"
- raise XmlProcessingError(msg, node)
+ iface["name"] = iface["params"]["name"]
--
1.7.7.6
10 years, 11 months
[lnst] NetTestController: handling of error messages
by Jiří Pírko
commit 22fe53d1e75c41f39220c0282b1ba71accae291e
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Apr 26 13:44:31 2013 +0200
NetTestController: handling of error messages
The communication protocol that was implemented can also send error
messages, however the Controller wasn't handling them and instead raised
an Unknown message exception. This patch fixes that by raising an
exception with the correct message.
I also modified the message that Slave sends when an unsupported method
call is recieved.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Controller/NetTestController.py | 4 ++++
lnst/Slave/NetTestSlave.py | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 62600ca..169f0af 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -394,6 +394,10 @@ class MessageDispatcher(ConnectionHandler):
elif message[1]["type"] == "exception":
msg = "Recieved an exception from slave: %s" % message[0]
raise CommandException(msg)
+ elif message[1]["type"] == "error":
+ msg = "Recieved an error message from slave %s: %s" %\
+ (message[0], message[1]["err"])
+ raise CommandException(msg)
else:
msg = "Unknown message type: %s" % message[1]["type"]
raise NetTestError(msg)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 2b0def5..9b39c0a 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -437,7 +437,7 @@ class NetTestSlave:
self._cmd_context.cleanup()
self._log_ctl.cancel_connection()
else:
- err = "Method not found: %s" % msg["method_name"]
+ err = "Method '%s' not supported." % msg["method_name"]
response = {"type": "error", "err": err}
if not self._server_handler.send_data_to_ctl(response):
self._cmd_context.cleanup()
10 years, 11 months
[lnst] NetTestController: Adding check for root priviledges
by Jiří Pírko
commit 94d6f52e19565f35fb9f176ad76ff41b550dbadf
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Apr 26 10:11:19 2013 +0200
NetTestController: Adding check for root priviledges
In case the match is virtual, LNST will need euid == 0 so it can connect
to qemu and configure the machines. This commit introduces a check for
that.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Controller/NetTestController.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 078746d..62600ca 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -109,6 +109,12 @@ class NetTestController:
msg = "This setup cannot be provisioned with the current pool."
raise NetTestError(msg)
+ if sp.is_setup_virtual() and os.geteuid() != 0:
+ msg = "Provisioning this setup requires additional configuration "\
+ "of the virtual machines in the pool. LNST needs root "\
+ "priviledges so it can connect to qemu."
+ raise NetTestError(msg)
+
for m_id, machine in machines.iteritems():
self._machines[m_id] = machine
10 years, 11 months
[lnst] VirtUtils: Don't log virsh output
by Jiří Pírko
commit 752723b1d91341103399b8d8232cca0018e774ba
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Apr 26 10:11:18 2013 +0200
VirtUtils: Don't log virsh output
The output of virsh commands was redundant as the same information is
alredy being logged, this patch will disable logging it into debug.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Common/VirtUtils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/VirtUtils.py b/lnst/Common/VirtUtils.py
index af290e5..71659ef 100644
--- a/lnst/Common/VirtUtils.py
+++ b/lnst/Common/VirtUtils.py
@@ -38,7 +38,7 @@ def _brctl(cmd):
def _virsh(cmd):
try:
- exec_cmd("virsh %s" % cmd)
+ exec_cmd("virsh %s" % cmd, log_outputs=False)
except ExecCmdFail as err:
raise VirtUtilsError("virsh error: %s" % err)
10 years, 11 months
[lnst] SlavePool: Adding a is_setup_virtual() predicate
by Jiří Pírko
commit 113d2f68ace8b67cbd991f808105eb9642589a23
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Apr 26 10:11:17 2013 +0200
SlavePool: Adding a is_setup_virtual() predicate
This commit adds a new predicate to the SlavePool class to check if the
match is virtual, i.e., whether LNST will need to use libvirt to
configure the setup.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Controller/SlavePool.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index d602027..80a357c 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -80,11 +80,11 @@ class SlavePool:
if 'libvirt_domain' not in machine['params'] \
or self._allow_virtual:
logging.info("Adding slave machine %s to slave pool."
- % machine_id)
+ % machine_id)
self._pool[machine_id] = machine
else:
logging.warning("libvirtd not found- Machine Pool skipping "\
- "machine %s" % machine_id)
+ "machine %s" % machine_id)
def provision_machines(self, mreqs):
"""
@@ -115,6 +115,9 @@ class SlavePool:
return machines
+ def is_setup_virtual(self):
+ return self._map["virtual"]
+
def get_provisioner_id(self, m_id):
try:
return self._get_machine_mapping(m_id)
10 years, 11 months