[PATCH 1/2] NetTestSlave: check if NetworkManager is running
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds function check_process_running that checks if there is
a process with a specified name running on the system.
This function is then used in the slaves rpc method hello() to check if
NetworkManager is running. NetworkManager is know for causing problem s
during automatic network testing when he interferes with the testing
network interfaces. The slave now logs a warning message to point out
these potential problems.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Utils.py | 8 ++++++++
lnst/Slave/NetTestSlave.py | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 00f7428..65d5902 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -15,6 +15,7 @@ import re
import os
import hashlib
import tempfile
+import subprocess
from lnst.Common.ExecCmd import exec_cmd
def die_when_parent_die():
@@ -148,3 +149,10 @@ def has_changed_since(filepath, threshold):
def _is_newer_than(f, threshold):
stat = os.stat(f)
return stat.st_mtime > threshold
+
+def check_process_running(process_name):
+ try:
+ proc = subprocess.check_call(["pgrep", process_name])
+ return True
+ except subprocess.CalledProcessError:
+ return False
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 4106f2d..9d3a9d8 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -28,6 +28,7 @@ from lnst.Common.NetTestCommand import NetTestCommandContext
from lnst.Common.NetTestCommand import CommandException, NetTestCommand
from lnst.Slave.NetConfig import NetConfig
from lnst.Slave.NetConfigDevice import NetConfigDeviceAllCleanup
+from lnst.Common.Utils import check_process_running
DefaultRPCPort = 9999
@@ -53,6 +54,12 @@ class NetTestSlaveXMLRPC:
self.clear_resource_table()
self._cache.del_old_entries()
self.reset_file_transfers()
+
+ if check_process_running("NetworkManager"):
+ logging.error("=============================================")
+ logging.error("NetworkManager is running on a slave machine!")
+ logging.error("This might effect test results!")
+ logging.error("=============================================")
return "hello"
def bye(self):
--
1.7.11.7
11 years, 4 months
[lnst] add command ctl_wait for the controller
by Jiří Pírko
commit 6c3aa33ee124c182bbbbc8ffc04715545730b59a
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Nov 23 16:52:47 2012 +0100
add command ctl_wait for the controller
Sometimes it is necessary for the controller to wait and do nothing
while the slaves do stuff in the background. Until now we were using the
exec type command. However recently we made a change that forbid the
controller to run commands.
This patch adds a new command type "ctl_wait" that accepts an integer
value indicating for how many seconds will the controller sleep. To
ensure the usage of this command only for the controller the only
accepted attributes are: type, value and desc. The attribute machine_id
is not supported since the command can only be used by the controller.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Controller/NetTestController.py | 6 ++++++
lnst/Controller/NetTestParse.py | 27 +++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 14c706f..1b3bad0 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -17,6 +17,7 @@ import os
import re
import pickle
import tempfile
+from time import sleep
from xmlrpclib import Binary
from pprint import pprint, pformat
from lnst.Common.Logs import Logs, log_exc_traceback
@@ -378,6 +379,11 @@ class NetTestController:
except KeyError:
pass
+ if command["type"] == "ctl_wait":
+ sleep(command["value"])
+ cmd_res = {"passed" : True}
+ return cmd_res
+
if "timeout" in command:
timeout = command["timeout"]
logging.debug("Setting socket timeout to \"%d\"", timeout)
diff --git a/lnst/Controller/NetTestParse.py b/lnst/Controller/NetTestParse.py
index 03fedd1..2f77284 100644
--- a/lnst/Controller/NetTestParse.py
+++ b/lnst/Controller/NetTestParse.py
@@ -551,13 +551,21 @@ class CommandParse(RecipeParser):
recipe["sequences"][self._seq_num]["commands"].append(command)
self._cmd_num = len(recipe["sequences"][self._seq_num]["commands"]) - 1
- machine_id = self._get_attribute(node, "machine_id")
- if machine_id and not machine_id in recipe["machines"]:
+ if self._has_attribute(node, "machine_id"):
+ machine_id = self._get_attribute(node, "machine_id")
+ else:
+ machine_id = None
+
+ if machine_id and machine_id not in recipe["machines"]:
raise XmlProcessingError("Invalid machine_id", node)
command["machine_id"] = machine_id
command["type"] = self._get_attribute(node, "type")
+ if (command["type"] != "ctl_wait" and not machine_id) or\
+ (machine_id and machine_id not in recipe["machines"]):
+ raise XmlProcessingError("Invalid machine_id", node)
+
command["value"] = None
if self._has_attribute(node, "value"):
command["value"] = self._get_attribute(node, "value")
@@ -583,6 +591,21 @@ class CommandParse(RecipeParser):
elif command["type"] == "exec":
if self._has_attribute(node, "from"):
command["from"] = self._get_attribute(node, "from")
+ elif command["type"] == "ctl_wait":
+ if command["machine_id"] != None:
+ msg = "Invalid attribute machine_id for command ctl_wait"
+ raise XmlProcessingError(msg, node)
+
+ try:
+ command["value"] = int(command["value"])
+ except ValueError:
+ msg = "Invalid value for command ctl_wait"
+ raise XmlProcessingError(msg, node)
+ for key in command.keys():
+ if key != "type" and key != "value" and\
+ key != "desc" and key != "machine_id":
+ msg = "Invalid attribute %s for command ctl_wait" % key
+ raise XmlProcessingError(msg, node)
scheme = {"options": self._options}
self._process_child_nodes(node, scheme)
11 years, 4 months
[lnst] NetTestController: prepare_slave() cleanup fix
by Jiří Pírko
commit 1da9df2204ee54c996c2e903a67a0259a210e53b
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Nov 23 16:21:04 2012 +0100
NetTestController: prepare_slave() cleanup fix
Make sure that cleanup phase happens before any slave configuration,
so the configuration doesn't get wiped out by accident.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Controller/NetTestController.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index b0ffd90..14c706f 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -246,6 +246,9 @@ class NetTestController:
self._rpc_call(machine_id, "clear_resource_table")
required = self._resource_table
+ if self._docleanup:
+ self._rpc_call(machine_id, 'machine_cleanup')
+
for res_type, resources in self._resource_table.iteritems():
for res_name, res in resources.iteritems():
has_resource = self._rpc_call(machine_id, "has_resource",
@@ -285,9 +288,6 @@ class NetTestController:
for device in provisioner["netdevices"].itervalues():
self._rpc_call(machine_id, 'set_device_down', device["hwaddr"])
- if self._docleanup:
- self._rpc_call(machine_id, 'machine_cleanup')
-
def _init_slave_rpc(self, machine_id):
info = self._get_machineinfo(machine_id)
hostname = info["hostname"]
11 years, 4 months
[lnst] Recipes: Remove rootpass
by Jiří Pírko
commit 8fbe5bb6100a48762895e91968284fbf2e04bc15
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Nov 23 16:16:27 2012 +0100
Recipes: Remove rootpass
Rootpass parameter is no longer used. This removes it from parser and
also from all example recipes.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Controller/MachinePool.py | 2 +-
lnst/Controller/NetTestController.py | 1 -
lnst/Controller/NetTestParse.py | 3 ---
recipes/examples/quick_guides/ping_check.xml | 8 ++++----
recipes/multicast/multicast-all.xml | 6 ++----
recipes/team/machineconfig-test1.xml | 2 +-
recipes/team/machineconfig-test2.xml | 2 +-
7 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/lnst/Controller/MachinePool.py b/lnst/Controller/MachinePool.py
index 6b7bf67..7ed6272 100644
--- a/lnst/Controller/MachinePool.py
+++ b/lnst/Controller/MachinePool.py
@@ -119,7 +119,7 @@ class MachinePool:
mcfg = dom.createElement("machineconfig")
info = dom.createElement("info")
- supported = ["hostname", "libvirt_domain", "rpcport", "rootpass"]
+ supported = ["hostname", "libvirt_domain", "rpcport"]
for attr_name, attr_val in self._pool[pm_id]["info"].iteritems():
if attr_name in supported:
info.setAttribute(attr_name, attr_val)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 469db04..b0ffd90 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -494,7 +494,6 @@ class NetTestController:
logging.info("Retrieving capture files from slaves")
for machine_id in self._recipe["machines"]:
hostname = self._recipe["machines"][machine_id]['info']['hostname']
- rootpass = self._recipe["machines"][machine_id]['info']['rootpass']
slave_logging_dir = os.path.join(logging_root, hostname)
try:
diff --git a/lnst/Controller/NetTestParse.py b/lnst/Controller/NetTestParse.py
index 40223f5..03fedd1 100644
--- a/lnst/Controller/NetTestParse.py
+++ b/lnst/Controller/NetTestParse.py
@@ -285,9 +285,6 @@ class MachineConfigParse(RecipeParser):
info["libvirt_domain"] = self._get_attribute(node,
"libvirt_domain")
- if self._has_attribute(node, "rootpass"):
- info["rootpass"] = self._get_attribute(node, "rootpass")
-
if self._has_attribute(node, "rpcport"):
info["rpcport"] = self._get_attribute(node, "rpcport", int)
diff --git a/recipes/examples/quick_guides/ping_check.xml b/recipes/examples/quick_guides/ping_check.xml
index 8960b63..9a0022c 100644
--- a/recipes/examples/quick_guides/ping_check.xml
+++ b/recipes/examples/quick_guides/ping_check.xml
@@ -8,8 +8,8 @@ is available on LNST wiki page:
<machines>
<machine id="testmachine1">
<machineconfig>
- <!-- Change hostname and rootpass bellow -->
- <info hostname="192.168.1.2" rootpass="r00t"/>
+ <!-- Change hostname bellow -->
+ <info hostname="192.168.1.2"/>
<netdevices>
<!-- Change hwaddr here -->
<netdevice type="eth" network="tnet" hwaddr="52:54:01:00:00:05"
@@ -27,8 +27,8 @@ is available on LNST wiki page:
<machine id="testmachine2">
<machineconfig>
- <!-- Change hostname and rootpass bellow -->
- <info hostname="192.168.1.3" rootpass="r00t"/>
+ <!-- Change hostname bellow -->
+ <info hostname="192.168.1.3"/>
<netdevices>
<!-- Change hwaddr here -->
<netdevice type="eth" network="tnet" hwaddr="52:54:01:00:00:06"
diff --git a/recipes/multicast/multicast-all.xml b/recipes/multicast/multicast-all.xml
index af9aae9..cd8da19 100644
--- a/recipes/multicast/multicast-all.xml
+++ b/recipes/multicast/multicast-all.xml
@@ -11,8 +11,7 @@
<machines>
<machine id="1">
<machineconfig>
- <info hostname="{$hostname1}" libvirt_domain="{$virtdomain1}"
- rootpass="redhat"/>
+ <info hostname="{$hostname1}" libvirt_domain="{$virtdomain1}"/>
<netdevices>
<libvirt_create>
<netdevice network="tnet" phys_id="1" type="eth"/>
@@ -35,8 +34,7 @@
</machine>
<machine id="2">
<machineconfig>
- <info hostname="{$hostname2}" libvirt_domain="{$virtdomain2}"
- rootpass="redhat"/>
+ <info hostname="{$hostname2}" libvirt_domain="{$virtdomain2}"/>
<netdevices>
<libvirt_create>
<netdevice network="tnet" phys_id="1" type="eth"/>
diff --git a/recipes/team/machineconfig-test1.xml b/recipes/team/machineconfig-test1.xml
index 1591a01..ec3062a 100644
--- a/recipes/team/machineconfig-test1.xml
+++ b/recipes/team/machineconfig-test1.xml
@@ -1,5 +1,5 @@
<machineconfig>
- <info hostname="192.168.122.182" rootpass="aaa"/>
+ <info hostname="192.168.122.182"/>
<netdevices>
<netdevice type="eth" phys_id="1" hwaddr="52:54:00:3d:c7:6d" network="testing"/>
<netdevice type="eth" phys_id="2" hwaddr="52:54:00:73:15:c2" network="testing"/>
diff --git a/recipes/team/machineconfig-test2.xml b/recipes/team/machineconfig-test2.xml
index 10a2cf7..4c57d2e 100644
--- a/recipes/team/machineconfig-test2.xml
+++ b/recipes/team/machineconfig-test2.xml
@@ -1,5 +1,5 @@
<machineconfig>
- <info hostname="192.168.122.223" rootpass="aaa"/>
+ <info hostname="192.168.122.223"/>
<netdevices>
<netdevice type="eth" phys_id="1" hwaddr="52:54:00:99:bb:27" network="testing"/>
<netdevice type="eth" phys_id="2" hwaddr="52:54:00:b7:cc:fb" network="testing"/>
11 years, 4 months
[lnst] SshUtils: Removing unused module
by Jiří Pírko
commit eacd43b321071439b7f29d8d375fa0013cc9ff1b
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Nov 23 16:04:48 2012 +0100
SshUtils: Removing unused module
This patch removes SshUtils module. It is no longer used nor necessary.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Common/SshUtils.py | 421 -----------------------------------------------
1 files changed, 0 insertions(+), 421 deletions(-)
11 years, 4 months
[lnst] XML-RPC: File transfers through RPC
by Jiří Pírko
commit 501c987c24c65deec0787f8561e930b3b9acf71d
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Nov 23 16:04:18 2012 +0100
XML-RPC: File transfers through RPC
This patch adds a XML API for backwards file transfers from
slaves to the controller.
Some changes to the previous ctl -> slave transfering API was made
so both the interfaces are similar to each other.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Controller/NetTestController.py | 33 +++++++++---
lnst/Slave/NetTestSlave.py | 90 +++++++++++++++++++++++-----------
2 files changed, 86 insertions(+), 37 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 340cdea..469db04 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -20,7 +20,6 @@ import tempfile
from xmlrpclib import Binary
from pprint import pprint, pformat
from lnst.Common.Logs import Logs, log_exc_traceback
-from lnst.Common.SshUtils import scp_from_remote
from lnst.Common.XmlRpc import ServerProxy, ServerException
from lnst.Common.NetUtils import MacPool
from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
@@ -490,7 +489,7 @@ class NetTestController:
self._rpc_call(machine_id, 'stop_packet_capture')
def _gather_capture_files(self):
- logging_root = Logs.get_logging_root_path()
+ logging_root = self._log_root_path
logging_root = os.path.abspath(logging_root)
logging.info("Retrieving capture files from slaves")
for machine_id in self._recipe["machines"]:
@@ -510,8 +509,7 @@ class NetTestController:
for remote_path in capture_files:
filename = os.path.basename(remote_path)
local_path = os.path.join(slave_logging_dir, filename)
- scp_from_remote(hostname, "22", "root", rootpass,
- remote_path, local_path)
+ self._copy_from_slave(machine_id, remote_path, local_path)
def _update_system_config(self, machine_id, res_data, persistent=False):
info = self._get_machineinfo(machine_id)
@@ -568,7 +566,7 @@ class NetTestController:
logger.handle(record)
def _copy_to_slave(self, local_path, machine_id, remote_path=None):
- self._rpc_call(machine_id, "start_copy", remote_path)
+ remote_path = self._rpc_call(machine_id, "start_copy_to", remote_path)
f = open(local_path, "r+b")
while True:
@@ -576,11 +574,28 @@ class NetTestController:
if len(data) == 0:
break
- self._rpc_call(machine_id, "copy_part", Binary(data))
+ self._rpc_call(machine_id, "copy_part_to",
+ remote_path, Binary(data))
- # return remote path
- rpath = self._rpc_call(machine_id, "finish_copy")
- return rpath
+ self._rpc_call(machine_id, "finish_copy_to", remote_path)
+ return remote_path
+
+ def _copy_from_slave(self, machine_id, remote_path, local_path):
+ status = self._rpc_call(machine_id, "start_copy_from", remote_path)
+ if not status:
+ raise NetTestError("The requested file cannot be transfered." \
+ "It file does not exist on machine %d" % machine_id)
+
+ local_file = open(local_path, "wb")
+
+ binary = "next"
+ while binary != "":
+ binary = self._rpc_call(machine_id, "copy_part_from",
+ remote_path, 1024*1024) # 1MB buffer
+ local_file.write(binary.data)
+
+ local_file.close()
+ self._rpc_call(machine_id, "finish_copy_from", remote_path)
def _load_test_modules(self, dirs):
modules = {}
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 28cca22..4106f2d 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -14,6 +14,7 @@ jpirko(a)redhat.com (Jiri Pirko)
import signal
import select, logging
import os
+from xmlrpclib import Binary
from tempfile import NamedTemporaryFile
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
from lnst.Common.Logs import Logs, log_exc_traceback
@@ -40,7 +41,8 @@ class NetTestSlaveXMLRPC:
self._netconfig = NetConfig()
self._command_context = command_context
- self._copy_target = None
+ self._copy_targets = {}
+ self._copy_sources = {}
self._cache = ResourceCache(config.get_option("cache", "dir"),
config.get_option("cache", "expiration_period"))
@@ -50,11 +52,13 @@ class NetTestSlaveXMLRPC:
def hello(self):
self.clear_resource_table()
self._cache.del_old_entries()
+ self.reset_file_transfers()
return "hello"
def bye(self):
self.clear_resource_table()
self._cache.del_old_entries()
+ self.reset_file_transfers()
return "bye"
def get_new_logs(self):
@@ -153,33 +157,6 @@ class NetTestSlaveXMLRPC:
self._cache.del_old_entries()
return True
- def start_copy(self, filename=None):
- if self._copy_target:
- return False
-
- if filename:
- self._copy_target = open(filename, "w+b")
- else:
- self._copy_target = NamedTemporaryFile("w+b", delete=False)
-
- return True
-
- def copy_part(self, binary_data):
- if self._copy_target:
- self._copy_target.write(binary_data.data)
- return True
-
- return False
-
- def finish_copy(self):
- if self._copy_target:
- name = self._copy_target.name
- del self._copy_target
- self._copy_target = None
- return name
-
- return ""
-
def clear_resource_table(self):
self._resource_table = {}
return True
@@ -206,6 +183,63 @@ class NetTestSlaveXMLRPC:
self._cache.add_cache_entry(file_hash, local_path, name, res_type)
return True
+ def start_copy_to(self, filepath=None):
+ if filepath in self._copy_targets:
+ return ""
+
+ if filepath:
+ self._copy_targets[filepath] = open(filepath, "w+b")
+ else:
+ tmpfile = NamedTemporaryFile("w+b", delete=False)
+ filepath = tmpfile.name
+ self._copy_targets[filepath] = tmpfile
+
+ return filepath
+
+ def copy_part_to(self, filepath, binary_data):
+ if self._copy_targets[filepath]:
+ self._copy_targets[filepath].write(binary_data.data)
+ return True
+
+ return False
+
+ def finish_copy_to(self, filepath):
+ if self._copy_targets[filepath]:
+ self._copy_targets[filepath].close()
+
+ del self._copy_targets[filepath]
+ return True
+
+ return False
+
+ def start_copy_from(self, filepath):
+ if filepath in self._copy_sources or not os.path.exists(filepath):
+ return False
+
+ self._copy_sources[filepath] = open(filepath, "rb")
+ return True
+
+ def copy_part_from(self, filepath, buffsize):
+ data = Binary(self._copy_sources[filepath].read(buffsize))
+ return data
+
+ def finish_copy_from(self, filepath):
+ if filepath in self._copy_sources:
+ self._copy_sources[filepath].close()
+ del self._copy_sources[filepath]
+ return True
+
+ return False
+
+ def reset_file_transfers(self):
+ for file_handle in self._copy_targets.itervalues():
+ file_handle.close()
+ self._copy_targets = {}
+
+ for file_handle in self._copy_sources.itervalues():
+ file_handle.close()
+ self._copy_sources = {}
+
class MySimpleXMLRPCServer(Server):
def __init__(self, command_context, *args, **kwargs):
self._finished = False
11 years, 4 months
[lnst] PacketCapture: Suppress tcpdump's error output
by Jiří Pírko
commit c5ede57453548b0ec39d233ebc76e671185ea3d0
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Fri Nov 23 16:03:35 2012 +0100
PacketCapture: Suppress tcpdump's error output
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Common/PacketCapture.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Common/PacketCapture.py b/lnst/Common/PacketCapture.py
index 8cfad17..69ad5cb 100644
--- a/lnst/Common/PacketCapture.py
+++ b/lnst/Common/PacketCapture.py
@@ -50,8 +50,8 @@ class PacketCapture:
output_file = self._file
pcap_filter = self._filter
- self._cmd = "tcpdump -p -i %s -w %s \"%s\"" % (interface, output_file,
- pcap_filter)
+ self._cmd = "tcpdump -p -i %s -w %s \"%s\" 2>/dev/null" % \
+ (interface, output_file, pcap_filter)
def _execute_tcpdump(self):
""" Start tcpdump in the background """
11 years, 4 months
[PATCH] add command ctl_wait for the controller
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Sometimes it is necessary for the controller to wait and do nothing
while the slaves do stuff in the background. Until now we were using the
exec type command. However recently we made a change that forbid the
controller to run commands.
This patch adds a new command type "ctl_wait" that accepts an integer
value indicating for how many seconds will the controller sleep. To
ensure the usage of this command only for the controller the only
accepted attributes are: type, value and desc. The attribute machine_id
is not supported since the command can only be used by the controller.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestController.py | 6 ++++++
lnst/Controller/NetTestParse.py | 27 +++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 340cdea..b31e842 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -17,6 +17,7 @@ import os
import re
import pickle
import tempfile
+from time import sleep
from xmlrpclib import Binary
from pprint import pprint, pformat
from lnst.Common.Logs import Logs, log_exc_traceback
@@ -379,6 +380,11 @@ class NetTestController:
except KeyError:
pass
+ if command["type"] == "ctl_wait":
+ sleep(command["value"])
+ cmd_res = {"passed" : True}
+ return cmd_res
+
if "timeout" in command:
timeout = command["timeout"]
logging.debug("Setting socket timeout to \"%d\"", timeout)
diff --git a/lnst/Controller/NetTestParse.py b/lnst/Controller/NetTestParse.py
index 40223f5..79df154 100644
--- a/lnst/Controller/NetTestParse.py
+++ b/lnst/Controller/NetTestParse.py
@@ -554,13 +554,21 @@ class CommandParse(RecipeParser):
recipe["sequences"][self._seq_num]["commands"].append(command)
self._cmd_num = len(recipe["sequences"][self._seq_num]["commands"]) - 1
- machine_id = self._get_attribute(node, "machine_id")
- if machine_id and not machine_id in recipe["machines"]:
+ if self._has_attribute(node, "machine_id"):
+ machine_id = self._get_attribute(node, "machine_id")
+ else:
+ machine_id = None
+
+ if machine_id and machine_id not in recipe["machines"]:
raise XmlProcessingError("Invalid machine_id", node)
command["machine_id"] = machine_id
command["type"] = self._get_attribute(node, "type")
+ if (command["type"] != "ctl_wait" and not machine_id) or\
+ (machine_id and machine_id not in recipe["machines"]):
+ raise XmlProcessingError("Invalid machine_id", node)
+
command["value"] = None
if self._has_attribute(node, "value"):
command["value"] = self._get_attribute(node, "value")
@@ -586,6 +594,21 @@ class CommandParse(RecipeParser):
elif command["type"] == "exec":
if self._has_attribute(node, "from"):
command["from"] = self._get_attribute(node, "from")
+ elif command["type"] == "ctl_wait":
+ if command["machine_id"] != None:
+ msg = "Invalid attribute machine_id for command ctl_wait"
+ raise XmlProcessingError(msg, node)
+
+ try:
+ command["value"] = int(command["value"])
+ except ValueError:
+ msg = "Invalid value for command ctl_wait"
+ raise XmlProcessingError(msg, node)
+ for key in command.keys():
+ if key != "type" and key != "value" and\
+ key != "desc" and key != "machine_id":
+ msg = "Invalid attribute %s for command ctl_wait" % key
+ raise XmlProcessingError(msg, node)
scheme = {"options": self._options}
self._process_child_nodes(node, scheme)
--
1.7.11.7
11 years, 4 months
[PATCH] NetTestController: prepare_slave() cleanup fix
by Radek Pazdera
Make sure that cleanup phase happens before any slave configuration,
so the configuration doesn't get wiped out by accident.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
lnst/Controller/NetTestController.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index b0ffd90..14c706f 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -246,6 +246,9 @@ class NetTestController:
self._rpc_call(machine_id, "clear_resource_table")
required = self._resource_table
+ if self._docleanup:
+ self._rpc_call(machine_id, 'machine_cleanup')
+
for res_type, resources in self._resource_table.iteritems():
for res_name, res in resources.iteritems():
has_resource = self._rpc_call(machine_id, "has_resource",
@@ -285,9 +288,6 @@ class NetTestController:
for device in provisioner["netdevices"].itervalues():
self._rpc_call(machine_id, 'set_device_down', device["hwaddr"])
- if self._docleanup:
- self._rpc_call(machine_id, 'machine_cleanup')
-
def _init_slave_rpc(self, machine_id):
info = self._get_machineinfo(machine_id)
hostname = info["hostname"]
--
1.7.7.6
11 years, 4 months