[PATCH] NmConfigDevice: add port config to team slaves
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
When I implemented the team configuration through NM I forgot about port
configuration of team slaves. This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index affb0a9..4901729 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -748,6 +748,11 @@ class NmConfigDeviceTeam(NmConfigDeviceGeneric):
hw_addr = self._convert_hwaddr(netdev)
+ teamd_port_config = get_slave_option(self._netdev,
+ slave, "teamd_port_config")
+ if teamd_port_config == None:
+ teamd_port_config = ""
+
s_eth = dbus.Dictionary({
'duplex': dbus.Array('full', 's'),
'mac-address': hw_addr})
@@ -760,9 +765,13 @@ class NmConfigDeviceTeam(NmConfigDeviceGeneric):
'master': self._netdev["master_uuid"],
'slave-type': 'team'})
+ s_port_cfg = dbus.Dictionary({
+ 'config': teamd_port_config})
+
slave_con = dbus.Dictionary({
'802-3-ethernet': s_eth,
- 'connection': s_slave_con})
+ 'connection': s_slave_con,
+ 'team-port': s_port_cfg})
netdev["con_obj_path"] = self._nm_add_connection(slave_con)
--
1.8.3.1
10 years, 5 months
[PATCH] SlavePool: virtual machine creation ignored custom rpcport
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Setting the rpc_port parameter in a slave pool had no effect for virtual
machines, which resulted in the machine being recognized as available
but the controller could'nt connect to it.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/SlavePool.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index e7d4557..7266eaf 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -289,7 +289,11 @@ class SlavePool:
hostname = pm["params"]["hostname"]
libvirt_domain = pm["params"]["libvirt_domain"]
- machine = Machine(tm_id, hostname, libvirt_domain)
+ rpcport = None
+ if "rpc_port" in pm["params"]:
+ rpcport = pm["params"]["rpc_port"]
+
+ machine = Machine(tm_id, hostname, libvirt_domain, rpcport)
# make all the existing unused
for if_id, if_data in pm["interfaces"].iteritems():
--
1.8.3.1
10 years, 5 months
[PATCH v2] lnst-ctl: enhance readability of info about processed recipes
by Jan Tluka
Resending version 2 of the patch. I moved the code for generating log
entry into a function to avoid code duplication.
This is a patch that would slightly enhance readability of controller
log.
First change is addition of a missing log entry when recipes are passed
as
individual files.
Second change is modification of the log entry so it's obvious that
another recipe's being processed.
Before,
# ./lnst-ctl run recipes/team/
Loading config file '/root/lnst/lnst-ctl.conf'
Loading config file '/root/.lnst/lnst-ctl.conf'
2013-11-20 09:12:17 (localhost) INFO: Processing recipe file "recipes/team/recipex_ab_001.xml"
2013-11-20 09:12:17 (localhost) INFO: Checking machine pool availability.
...
After,
# ./lnst-ctl run recipes/team/
Loading config file '/root/lnst/lnst-ctl.conf'
Loading config file '/root/.lnst/lnst-ctl.conf'
2013-11-20 09:14:43 (localhost) INFO:
--------------------------------------------------------
Processing recipe file "recipes/team/recipex_ab_001.xml"
--------------------------------------------------------
2013-11-20 09:14:43 (localhost) INFO: Checking machine pool availability.
...
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst-ctl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index d597c23..fadeeb8 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -106,6 +106,12 @@ def get_recipe_result(args, file_path, res_serializer, packet_capture,
return (file_path, res, retval)
+def recipe_head_log_entry(filename)
+ head_str = "\nProcessing recipe file \"%s\"\n" % filename
+ logging.info("-" * len(head_str.strip())
+ + head_str
+ + "-" * len(head_str.strip()))
+
def main():
"""
Main function
@@ -213,7 +219,7 @@ def main():
for f in all_files:
recipe_file = os.path.join(recipe_path, f)
if re.match(r'^.*\.xml$', recipe_file):
- logging.info("Processing recipe file \"%s\"" % recipe_file)
+ recipe_head_log_entry(recipe_file)
fp, res, rv = get_recipe_result(action, recipe_file,
res_serializer,
packet_capture,
@@ -221,6 +227,7 @@ def main():
defined_aliases,
overriden_aliases)
else:
+ recipe_head_log_entry(recipe_path)
fp, res, rv = get_recipe_result(action, recipe_path,
res_serializer,
packet_capture,
--
1.8.1.4
10 years, 5 months
[PATCH] lnst-ctl: enhance readability of info about processed recipes
by Jan Tluka
This is a patch that would slightly enhance readability of controller log.
First change is addition of a missing log entry when recipes are passed as
individual files.
Second change is modification of the log entry so it's obvious that
another recipe's being processed.
Before,
# ./lnst-ctl run recipes/team/
Loading config file '/root/lnst/lnst-ctl.conf'
Loading config file '/root/.lnst/lnst-ctl.conf'
2013-11-20 09:12:17 (localhost) INFO: Processing recipe file "recipes/team/recipex_ab_001.xml"
2013-11-20 09:12:17 (localhost) INFO: Checking machine pool availability.
...
After,
# ./lnst-ctl run recipes/team/
Loading config file '/root/lnst/lnst-ctl.conf'
Loading config file '/root/.lnst/lnst-ctl.conf'
2013-11-20 09:14:43 (localhost) INFO:
--------------------------------------------------------
Processing recipe file "recipes/team/recipex_ab_001.xml"
--------------------------------------------------------
2013-11-20 09:14:43 (localhost) INFO: Checking machine pool availability.
...
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst-ctl | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index d597c23..ad27cc0 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -213,7 +213,11 @@ def main():
for f in all_files:
recipe_file = os.path.join(recipe_path, f)
if re.match(r'^.*\.xml$', recipe_file):
- logging.info("Processing recipe file \"%s\"" % recipe_file)
+ head_str = "\nProcessing recipe file \"%s\"\n" % \
+ recipe_file
+ logging.info("-" * len(head_str.strip())
+ + head_str\
+ + "-" * len(head_str.strip()))
fp, res, rv = get_recipe_result(action, recipe_file,
res_serializer,
packet_capture,
@@ -221,6 +225,10 @@ def main():
defined_aliases,
overriden_aliases)
else:
+ head_str = "\nProcessing recipe file \"%s\"\n" % recipe_path
+ logging.info("-" * len(head_str.strip())
+ + head_str\
+ + "-" * len(head_str.strip()))
fp, res, rv = get_recipe_result(action, recipe_path,
res_serializer,
packet_capture,
--
1.8.1.4
10 years, 5 months
[lnst] PacketAssert: bugfix and code cleanup
by Jiří Pírko
commit 8af4751ddbd887fc55f72fa62f81413697749940
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Fri Nov 15 19:44:48 2013 +0100
PacketAssert: bugfix and code cleanup
I found a bug in PacketAssert test module. It was caused by processing the
last line twice - inside the interrupt handler and in the run() function
as well. I've cleaned up the code a bit, too.
The changes include
- removal of the tcpdump's output processing from the interrupt handler
- tcpdump termination polling is done in separate loop
- tcpdump's output is stored into temporary file instead of using pipes
- tcpdump's output is processed after the tcpdump command terminates
I have tested this heavily and it looks much more reliable now.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_modules/PacketAssert.py | 72 +++++++++++++++++-------------------------
1 files changed, 29 insertions(+), 43 deletions(-)
---
diff --git a/test_modules/PacketAssert.py b/test_modules/PacketAssert.py
index c716c66..0611179 100644
--- a/test_modules/PacketAssert.py
+++ b/test_modules/PacketAssert.py
@@ -15,6 +15,9 @@ import logging
import subprocess
import re
import signal
+import time
+import os
+import tempfile
from lnst.Common.TestsCommon import TestGeneric
class PacketAssert(TestGeneric):
@@ -25,6 +28,7 @@ class PacketAssert(TestGeneric):
_cmd = ""
_tcpdump = None
+ _tcpdump_capture_file = None
_grep_filters = []
_min_cond = 1
@@ -38,29 +42,10 @@ class PacketAssert(TestGeneric):
def _interrupt_handler(self, signum, frame):
""" Kill tcpdump when interrupted """
- self._tcpdump.terminate()
-
- tcpdump_output = self._tcpdump.stdout
- while True:
- try:
- next_line = tcpdump_output.readline()
- except IOError: # Interrupted system call
- break
-
- if next_line == "":
- break
-
- next_line = next_line.strip("\n")
-
- if re.match("[0-9]+\:[0-9]+\:[0-9\.]+", next_line) and\
- self.line != "":
- self._process_captured_line(self.line)
- self.line = next_line
- else:
- self.line += next_line
- if self.line != "":
- self._process_captured_line(self.line)
-
+ try:
+ self._tcpdump.terminate()
+ except OSError:
+ raise Exception("Caught exception in interrupt handler")
def _prepare_grep_filters(self):
""" Parse `grep_for' test options """
@@ -96,8 +81,11 @@ class PacketAssert(TestGeneric):
def _execute_tcpdump(self):
""" Start tcpdump in the background """
cmd = self._cmd
- proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ tcpdump_file = tempfile.NamedTemporaryFile(delete=False)
+ self._tcpdump_capture_file = tcpdump_file.name
+
+ proc = subprocess.Popen(cmd, shell=True, stdout=tcpdump_file,
+ stderr=None)
self._tcpdump = proc
def _process_captured_line(self, line):
@@ -128,34 +116,32 @@ class PacketAssert(TestGeneric):
logging.info("Capturing started")
- self.line = ""
- tcpdump_output = self._tcpdump.stdout
while True:
if self._tcpdump.poll() != None:
if self._tcpdump.returncode > 0:
raise Exception("tcpdump terminated with error")
else:
break
-
- try:
- next_line = tcpdump_output.readline()
- except IOError: # Interrupted system call
- continue
-
- if next_line == "":
+ else:
+ time.sleep(1)
continue
- next_line = next_line.strip("\n")
+ # get and evalute the tcpdump's output
+ # empty string returned by readline() means the EOF has been reached
+ tcpdump_file = open(self._tcpdump_capture_file, 'r')
+ line = "\n"
+ while line != "":
+ try:
+ line = tcpdump_file.readline()
+ except (OSError, IOError):
+ logging.debug("Caught exception while reading tcpdump output")
+ break
- if re.match("[0-9]+\:[0-9]+\:[0-9\.]+", next_line) and\
- self.line != "":
- self._process_captured_line(self.line)
- self.line = next_line
- else:
- self.line += next_line
+ line = line.strip("\n")
+ self._process_captured_line(line)
- if self.line != "":
- self._process_captured_line(self.line)
+ tcpdump_file.close()
+ os.remove(tcpdump_file.name)
logging.info("Capturing finished. Received %d packets", self._num_recv)
res = {"received": self._num_recv,
10 years, 5 months
[PATCH] PacketAssert: bugfix and code cleanup
by Jan Tluka
I found a bug in PacketAssert test module. It was caused by processing the
last line twice - inside the interrupt handler and in the run() function
as well. I've cleaned up the code a bit, too.
The changes include
- removal of the tcpdump's output processing from the interrupt handler
- tcpdump termination polling is done in separate loop
- tcpdump's output is stored into temporary file instead of using pipes
- tcpdump's output is processed after the tcpdump command terminates
I have tested this heavily and it looks much more reliable now.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
test_modules/PacketAssert.py | 72 ++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 43 deletions(-)
diff --git a/test_modules/PacketAssert.py b/test_modules/PacketAssert.py
index c716c66..0611179 100644
--- a/test_modules/PacketAssert.py
+++ b/test_modules/PacketAssert.py
@@ -15,6 +15,9 @@ import logging
import subprocess
import re
import signal
+import time
+import os
+import tempfile
from lnst.Common.TestsCommon import TestGeneric
class PacketAssert(TestGeneric):
@@ -25,6 +28,7 @@ class PacketAssert(TestGeneric):
_cmd = ""
_tcpdump = None
+ _tcpdump_capture_file = None
_grep_filters = []
_min_cond = 1
@@ -38,29 +42,10 @@ class PacketAssert(TestGeneric):
def _interrupt_handler(self, signum, frame):
""" Kill tcpdump when interrupted """
- self._tcpdump.terminate()
-
- tcpdump_output = self._tcpdump.stdout
- while True:
- try:
- next_line = tcpdump_output.readline()
- except IOError: # Interrupted system call
- break
-
- if next_line == "":
- break
-
- next_line = next_line.strip("\n")
-
- if re.match("[0-9]+\:[0-9]+\:[0-9\.]+", next_line) and\
- self.line != "":
- self._process_captured_line(self.line)
- self.line = next_line
- else:
- self.line += next_line
- if self.line != "":
- self._process_captured_line(self.line)
-
+ try:
+ self._tcpdump.terminate()
+ except OSError:
+ raise Exception("Caught exception in interrupt handler")
def _prepare_grep_filters(self):
""" Parse `grep_for' test options """
@@ -96,8 +81,11 @@ class PacketAssert(TestGeneric):
def _execute_tcpdump(self):
""" Start tcpdump in the background """
cmd = self._cmd
- proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ tcpdump_file = tempfile.NamedTemporaryFile(delete=False)
+ self._tcpdump_capture_file = tcpdump_file.name
+
+ proc = subprocess.Popen(cmd, shell=True, stdout=tcpdump_file,
+ stderr=None)
self._tcpdump = proc
def _process_captured_line(self, line):
@@ -128,34 +116,32 @@ class PacketAssert(TestGeneric):
logging.info("Capturing started")
- self.line = ""
- tcpdump_output = self._tcpdump.stdout
while True:
if self._tcpdump.poll() != None:
if self._tcpdump.returncode > 0:
raise Exception("tcpdump terminated with error")
else:
break
-
- try:
- next_line = tcpdump_output.readline()
- except IOError: # Interrupted system call
- continue
-
- if next_line == "":
+ else:
+ time.sleep(1)
continue
- next_line = next_line.strip("\n")
+ # get and evalute the tcpdump's output
+ # empty string returned by readline() means the EOF has been reached
+ tcpdump_file = open(self._tcpdump_capture_file, 'r')
+ line = "\n"
+ while line != "":
+ try:
+ line = tcpdump_file.readline()
+ except (OSError, IOError):
+ logging.debug("Caught exception while reading tcpdump output")
+ break
- if re.match("[0-9]+\:[0-9]+\:[0-9\.]+", next_line) and\
- self.line != "":
- self._process_captured_line(self.line)
- self.line = next_line
- else:
- self.line += next_line
+ line = line.strip("\n")
+ self._process_captured_line(line)
- if self.line != "":
- self._process_captured_line(self.line)
+ tcpdump_file.close()
+ os.remove(tcpdump_file.name)
logging.info("Capturing finished. Received %d packets", self._num_recv)
res = {"received": self._num_recv,
--
1.8.1.4
10 years, 5 months