[lnst] Machine: added methods get_interfaces and get_addresses
by Jiří Pírko
commit 62f68872d2817188a2e18612c2afb0683b64e912
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Oct 27 17:11:44 2014 +0100
Machine: added methods get_interfaces and get_addresses
These methods will be used by the Python Task API. The both return
complete lists of either interfaces or ip addresses (tuple of address
and prefix) which can be iterated.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 26e475a..8c2c41e 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -121,6 +121,9 @@ class Machine(object):
msg = "Interface '%s' not found on machine '%s'" % (if_id, self._id)
raise MachineError(msg)
+ def get_interfaces(self):
+ return self._interfaces
+
def get_ordered_interfaces(self):
ordered_list = list(self._interfaces)
change = True
@@ -556,6 +559,12 @@ class Interface(object):
def get_address(self, num):
return self._addresses[num].split('/')[0]
+ def get_addresses(self):
+ addrs = []
+ for addr in self._addresses:
+ addrs.append(tuple(addr.split('/')))
+ return addrs
+
def set_ovs_conf(self, ovs_conf):
self._ovs_conf = ovs_conf
9 years, 6 months
[lnst] SlavePool: small object construction fixes
by Jiří Pírko
commit b0e03a8119d6d5c0974b182cb5ed3c52e8787337
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Oct 27 17:11:43 2014 +0100
SlavePool: small object construction fixes
This patch fixes some small problems in the SlavePool methods
responsible for Machine object construction.
When the machine isn't virtual it doesn't need the libvirt_domain
parameter. This can could cause exceptions when the match wasn't virtual
but the machine had the parameter defined and lnst-ctl wasn't running
with root privileges.
Proper initialization of the network parameter for interfaces. This is
purely so that it doesn't cause confusion in the future. Unused
interfaces don't have any network.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/SlavePool.py | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 53f402f..cbe177d 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -271,15 +271,11 @@ class SlavePool:
hostname = pm["params"]["hostname"]
- libvirt_domain = None
- if "libvirt_domain" in pm["params"]:
- libvirt_domain = pm["params"]["libvirt_domain"]
-
rpcport = None
if "rpc_port" in pm["params"]:
rpcport = pm["params"]["rpc_port"]
- machine = Machine(tm_id, hostname, libvirt_domain, rpcport)
+ machine = Machine(tm_id, hostname, None, rpcport)
used = []
if_map = self._map["machines"][tm_id]["interfaces"]
@@ -287,19 +283,19 @@ class SlavePool:
used.append(p_if)
if_data = pm["interfaces"][p_if]
+ iface = machine.new_static_interface(t_if, "eth")
+ iface.set_hwaddr(if_data["params"]["hwaddr"])
+
for t_net, p_net in self._map["networks"].iteritems():
if pm["interfaces"][p_if]["network"] == p_net:
+ iface.set_network(t_net)
break
- iface = machine.new_static_interface(t_if, "eth")
- iface.set_hwaddr(if_data["params"]["hwaddr"])
- iface.set_network(t_net)
-
for if_id, if_data in pm["interfaces"].iteritems():
if if_id not in used:
iface = machine.new_unused_interface("eth")
iface.set_hwaddr(if_data["params"]["hwaddr"])
- iface.set_network(t_net)
+ iface.set_network(None)
return machine
@@ -320,7 +316,7 @@ class SlavePool:
for if_id, if_data in pm["interfaces"].iteritems():
iface = machine.new_unused_interface("eth")
iface.set_hwaddr(if_data["params"]["hwaddr"])
- iface.set_network(if_data["network"])
+ iface.set_network(None)
# add all the other devices
for if_id, if_data in tm["interfaces"].iteritems():
9 years, 6 months
[lnst] NetTestResultSerializer: dont print match when there is none
by Jiří Pírko
commit 38357131386d29209bcac5d0199802687fb7cb82
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Oct 27 17:11:42 2014 +0100
NetTestResultSerializer: dont print match when there is none
When the first match of a recipe failed the result serializer still
tried to print the match description resulting in an Exception.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestResultSerializer.py | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index ae8bc7e..c007945 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -86,18 +86,21 @@ class NetTestResultSerializer:
recipe_head = "%s match: %d" % (recipe["name"], recipe["match_num"])
output_pairs.append((recipe_head, recipe["result"]))
- output_pairs.append((4*" " + "Pool match description:", ""))
match = recipe["pool_match"]
- if "virtual" in match and match["virtual"]:
- output_pairs.append((4*" " + "Setup is using virtual machines.",
- ""))
- for m_id, m in match["machines"].iteritems():
- output_pairs.append((4*" " + "host \"%s\" uses \"%s\"" %\
- (m_id, m["target"]), ""))
- for if_id, pool_id in m["interfaces"].iteritems():
- output_pairs.append((6*" " + "interface \"%s\" "\
- "matched to \"%s\"" %\
- (if_id, pool_id), ""))
+ if match != {}:
+ output_pairs.append((4*" " + "Pool match description:", ""))
+ if "virtual" in match and match["virtual"]:
+ output_pairs.append((4*" " +\
+ "Setup is using virtual machines.",
+ ""))
+
+ for m_id, m in match["machines"].iteritems():
+ output_pairs.append((4*" " + "host \"%s\" uses \"%s\"" %\
+ (m_id, m["target"]), ""))
+ for if_id, pool_id in m["interfaces"].iteritems():
+ output_pairs.append((6*" " + "interface \"%s\" "\
+ "matched to \"%s\"" %\
+ (if_id, pool_id), ""))
if recipe["result"] == "FAIL" and \
"err_msg" in recipe and recipe["err_msg"] != "":
9 years, 6 months
[lnst] lnst-ctl: fix get_recipe_results for single matches
by Jiří Pírko
commit 3e30eaa99ce33f43aa1a48f65a9bef2e4fd4bde7
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Oct 27 17:11:41 2014 +0100
lnst-ctl: fix get_recipe_results for single matches
This patch spparates the code for the first match of a recipe from the
code for additional matches. This fixes a few issues introduced in the
multi match support patches, such as wrong error reporting when no
suitable match was found.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 49 ++++++++++++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 9d72503..5f3b22f 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -98,29 +98,40 @@ def get_recipe_result(action, file_path, log_ctl, res_serializer,
no_match = False
while True:
res = {}
- try:
- nettestctl.provision_machines()
- log_ctl.set_recipe(file_path, expand="match_%d" % matches)
- recipe_head_log_entry(file_path, matches)
- nettestctl.print_match_description()
- res_serializer.add_recipe(file_path, matches)
- res = exec_action(action, nettestctl)
- except NoMatchError as err:
- no_match = True
- if matches == 1:
+ if matches == 1:
+ try:
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.provision_machines()
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
res["passed"] = False
+ res["err_msg"] = str(err)
retval = RETVAL_ERR
- raise err
- else:
+ elif matches > 1:
+ try:
+ nettestctl.provision_machines()
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except NoMatchError as err:
+ no_match = True
log_ctl.unset_recipe()
logging.warning("Match %d not possible." % matches)
- except Exception as err:
- no_match = True
- log_exc_traceback()
- logging.error(err)
- res["passed"] = False
- res["err_msg"] = str(err)
- retval = RETVAL_ERR
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
+ retval = RETVAL_ERR
if no_match and matches > 1:
break
9 years, 6 months
[PATCH v2 1/5] lnst-ctl: fix get_recipe_results for single matches
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch spparates the code for the first match of a recipe from the
code for additional matches. This fixes a few issues introduced in the
multi match support patches, such as wrong error reporting when no
suitable match was found.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 9d72503..5f3b22f 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -98,29 +98,40 @@ def get_recipe_result(action, file_path, log_ctl, res_serializer,
no_match = False
while True:
res = {}
- try:
- nettestctl.provision_machines()
- log_ctl.set_recipe(file_path, expand="match_%d" % matches)
- recipe_head_log_entry(file_path, matches)
- nettestctl.print_match_description()
- res_serializer.add_recipe(file_path, matches)
- res = exec_action(action, nettestctl)
- except NoMatchError as err:
- no_match = True
- if matches == 1:
+ if matches == 1:
+ try:
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.provision_machines()
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
res["passed"] = False
+ res["err_msg"] = str(err)
retval = RETVAL_ERR
- raise err
- else:
+ elif matches > 1:
+ try:
+ nettestctl.provision_machines()
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except NoMatchError as err:
+ no_match = True
log_ctl.unset_recipe()
logging.warning("Match %d not possible." % matches)
- except Exception as err:
- no_match = True
- log_exc_traceback()
- logging.error(err)
- res["passed"] = False
- res["err_msg"] = str(err)
- retval = RETVAL_ERR
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
+ retval = RETVAL_ERR
if no_match and matches > 1:
break
--
1.9.3
9 years, 6 months
[PATCH 1/5] lnst-ctl: fix get_recipe_results for single matches
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch spparates the code for the first match of a recipe from the
code for additional matches. This fixes a few issues introduced in the
multi match support patches, such as wrong error reporting when no
suitable match was found.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 9d72503..5f3b22f 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -98,29 +98,40 @@ def get_recipe_result(action, file_path, log_ctl, res_serializer,
no_match = False
while True:
res = {}
- try:
- nettestctl.provision_machines()
- log_ctl.set_recipe(file_path, expand="match_%d" % matches)
- recipe_head_log_entry(file_path, matches)
- nettestctl.print_match_description()
- res_serializer.add_recipe(file_path, matches)
- res = exec_action(action, nettestctl)
- except NoMatchError as err:
- no_match = True
- if matches == 1:
+ if matches == 1:
+ try:
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.provision_machines()
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
res["passed"] = False
+ res["err_msg"] = str(err)
retval = RETVAL_ERR
- raise err
- else:
+ elif matches > 1:
+ try:
+ nettestctl.provision_machines()
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except NoMatchError as err:
+ no_match = True
log_ctl.unset_recipe()
logging.warning("Match %d not possible." % matches)
- except Exception as err:
- no_match = True
- log_exc_traceback()
- logging.error(err)
- res["passed"] = False
- res["err_msg"] = str(err)
- retval = RETVAL_ERR
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
+ retval = RETVAL_ERR
if no_match and matches > 1:
break
--
1.9.3
9 years, 6 months
财源滚滚
by 喻泽麟
{AUTOVALS6}ruhe
═
9 years, 6 months
[PATCH] lnst-ctl: fix long options
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Long options that require an argument should end with '='.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 6a0e924..9d72503 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -154,17 +154,17 @@ def main():
sys.argv[1:],
"A:a:c:dhmoprs:t:ux:",
[
- "override_alias",
- "define_alias",
- "config",
+ "override_alias=",
+ "define_alias=",
+ "config=",
"debug",
"help",
"no-colours",
"disable-pool-checks",
"packet-capture",
"reduce-sync",
- "xslt-url",
- "html",
+ "xslt-url=",
+ "html=",
"multi-match",
"result=",
]
--
1.9.3
9 years, 6 months
[lnst] lnst-ctl: fix long options
by Jiří Pírko
commit efc4c9a5a455c4ec1da82d727d2eb7582892411b
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 24 15:07:36 2014 +0200
lnst-ctl: fix long options
Long options that require an argument should end with '='.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 6a0e924..9d72503 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -154,17 +154,17 @@ def main():
sys.argv[1:],
"A:a:c:dhmoprs:t:ux:",
[
- "override_alias",
- "define_alias",
- "config",
+ "override_alias=",
+ "define_alias=",
+ "config=",
"debug",
"help",
"no-colours",
"disable-pool-checks",
"packet-capture",
"reduce-sync",
- "xslt-url",
- "html",
+ "xslt-url=",
+ "html=",
"multi-match",
"result=",
]
9 years, 6 months