[lnst] NmConfigDevice: add team configuration through NM
by Jiří Pírko
commit 41c4060d1f1d252b8498cd3addd66c1c8abf431c
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Nov 11 11:20:59 2013 +0100
NmConfigDevice: add team configuration through NM
This commit adds support for configuring team devices through NM. The
support is limited to NM versions >= 0.9.9.
The code is similar to how bond configuration is done -> we create
connection objects for the team device and all the slaves, remove them
in reverse order. (De)Activation is done in the same order.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 102 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 98 insertions(+), 4 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 6a258a6..affb0a9 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -673,20 +673,114 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
pass
class NmConfigDeviceTeam(NmConfigDeviceGeneric):
- #Not supported by NetworkManager yet
@classmethod
def is_nm_managed(cls, netdev, config):
- managed = False
+ if _dev_exists(netdev["hwaddr"]):
+ managed = super(NmConfigDeviceTeam, cls).is_nm_managed(netdev,
+ config)
+ else:
+ if get_nm_version() < "0.9.9":
+ managed = False
+ else:
+ slave_id = get_slaves(netdev)[0]
+ netdev = config[slave_id]
+ managed = is_nm_managed(netdev, config)
for slave in get_slaves(netdev):
- slave_netdev = config[slave]
- if is_nm_managed(slave_netdev, config) != managed:
+ netdev = config[slave]
+ if is_nm_managed(netdev, config) != managed:
msg = "Mixing NM managed and not managed devices in a "\
"master-slave relationship is not allowed!"
raise Exception(msg)
return managed
+ def up(self):
+ super(NmConfigDeviceTeam, self).up()
+
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ self._nm_activate_connection(netdev)
+
+ def down(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ self._nm_deactivate_connection(netdev)
+
+ super(NmConfigDeviceTeam, self).down()
+
+ def _add_team(self):
+ netdev = self._netdev
+ netdev["master_uuid"] = str(uuid.uuid4())
+
+ s_team_con = dbus.Dictionary({
+ 'type': 'team',
+ 'autoconnect': dbus.Boolean(False),
+ 'uuid': netdev["master_uuid"],
+ 'id': netdev["name"]+"_con"})
+
+ teamd_config = get_option(self._netdev, "teamd_config")
+
+ s_team = dbus.Dictionary({
+ 'interface-name': netdev["name"],
+ 'config': teamd_config})
+
+ s_ipv4, s_ipv6 = self._nm_make_ip_settings(netdev["addresses"])
+
+ connection = dbus.Dictionary({
+ 'team': s_team,
+ 'ipv4': s_ipv4,
+ 'ipv6': s_ipv6,
+ 'connection': s_team_con})
+
+ netdev["con_obj_path"] = self._nm_add_connection(connection)
+
+ def _rm_team(self):
+ netdev = self._netdev
+ if netdev["con_obj_path"] != "":
+ self._nm_rm_connection(netdev["con_obj_path"])
+ netdev["con_obj_path"] = ""
+
+ def _add_slaves(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ slave_name = netdev["name"]
+
+ hw_addr = self._convert_hwaddr(netdev)
+
+ s_eth = dbus.Dictionary({
+ 'duplex': dbus.Array('full', 's'),
+ 'mac-address': hw_addr})
+
+ s_slave_con = dbus.Dictionary({
+ 'type': '802-3-ethernet',
+ 'autoconnect': dbus.Boolean(False),
+ 'uuid': str(uuid.uuid4()),
+ 'id': 'slave_con',
+ 'master': self._netdev["master_uuid"],
+ 'slave-type': 'team'})
+
+ slave_con = dbus.Dictionary({
+ '802-3-ethernet': s_eth,
+ 'connection': s_slave_con})
+
+ netdev["con_obj_path"] = self._nm_add_connection(slave_con)
+
+ def _rm_slaves(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ if netdev["con_obj_path"] != "":
+ self._nm_rm_connection(netdev["con_obj_path"])
+ netdev["con_obj_path"] = ""
+
+ def configure(self):
+ self._add_team()
+ self._add_slaves()
+
+ def deconfigure(self):
+ self._rm_slaves()
+ self._rm_team()
+
type_class_mapping = {
"eth": NmConfigDeviceEth,
"bond": NmConfigDeviceBond,
10 years, 5 months
[lnst] NmConfigDevice: add detection of NM version
by Jiří Pírko
commit a627699263c44776f3c83c4b6f3335bea957a218
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Nov 11 11:20:37 2013 +0100
NmConfigDevice: add detection of NM version
This commit adds a new function that returns the version of the running
NM daemon. The version is determined through dbus. For now I've used it
to detect whether to manually remove soft network devices or to leave NM
do it (NM version >= 0.9.9 removes them automatically). Later this will
be used to determine if team devices are supported by NM.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 51 +++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 18 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index a2ad57f..6a258a6 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -60,6 +60,18 @@ def _dev_exists(hwaddr):
if dev["hwaddr"] == hwaddr:
return True
+def get_nm_version():
+ if not check_process_running("NetworkManager") or\
+ not lnst_config.get_option("environment", "use_nm"):
+ return ""
+
+ bus = dbus.SystemBus()
+ nm_obj = bus.get_object(NM_BUS, OBJ_PRE)
+ nm_if = dbus.Interface(nm_obj, IF_PRE)
+
+ props = dbus.Interface(nm_obj, "org.freedesktop.DBus.Properties")
+ return props.Get(IF_PRE, "Version")
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -392,11 +404,12 @@ class NmConfigDeviceBond(NmConfigDeviceGeneric):
netdev["con_obj_path"] = ""
#older versions of NM don't know how to remove soft devices...
- try:
- bond_masters = "/sys/class/net/bonding_masters"
- exec_cmd('echo "-%s" > %s' % (netdev["name"], bond_masters))
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ bond_masters = "/sys/class/net/bonding_masters"
+ exec_cmd('echo "-%s" > %s' % (netdev["name"], bond_masters))
+ except:
+ pass
def _add_slaves(self):
for slave in get_slaves(self._netdev):
@@ -505,11 +518,12 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
netdev["con_obj_path"] = ""
#older versions of NM don't know how to remove soft devices...
- try:
- exec_cmd("ip link set %s down" % netdev["name"])
- exec_cmd("brctl delbr %s " % netdev["name"])
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ exec_cmd("ip link set %s down" % netdev["name"])
+ exec_cmd("brctl delbr %s " % netdev["name"])
+ except:
+ pass
def _add_slave(self, slave):
netdev = self._config[slave]
@@ -648,14 +662,15 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
#older versions of NM don't know how to remove soft devices...
#and lnst will break when multiple devices with the same mac exist
- try:
- dev_name = self._get_vlan_info()[0]
- if self._check_ip_link_add():
- exec_cmd("ip link del %s" % dev_name)
- else:
- exec_cmd("vconfig rem %s" % dev_name)
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ dev_name = self._get_vlan_info()[0]
+ if self._check_ip_link_add():
+ exec_cmd("ip link del %s" % dev_name)
+ else:
+ exec_cmd("vconfig rem %s" % dev_name)
+ except:
+ pass
class NmConfigDeviceTeam(NmConfigDeviceGeneric):
#Not supported by NetworkManager yet
10 years, 5 months
[lnst] Logs: use machine names instead of IP addresses
by Jiří Pírko
commit 135bc0fe65bdc799a181d1a1fbc3f74980468a72
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Nov 8 16:22:47 2013 +0100
Logs: use machine names instead of IP addresses
This commit changes the format of log messages, instead of using
hostnames, which are usually IP addresses, we will use the host ids that
are specified in the supplied recipe.
This makes it more obvious what's happening on which machine. The
information about the used hosts is still available at the beginning of
recipe execution when the controller finds a suitable match.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/Logs.py | 19 +++++++++----------
lnst/Controller/NetTestController.py | 2 +-
2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/lnst/Common/Logs.py b/lnst/Common/Logs.py
index 33a43a7..b891439 100644
--- a/lnst/Common/Logs.py
+++ b/lnst/Common/Logs.py
@@ -44,7 +44,7 @@ class MultilineFormatter(Formatter): # addr:17 level:7
def _format_addr(self, record):
if not "address" in record.__dict__:
- addr = "(127.0.0.1)".rjust(17)
+ addr = "(localhost)".rjust(17)
else:
addr = record.address.rjust(17)
@@ -145,11 +145,11 @@ class LoggingCtl:
logger.removeHandler(self.recipe_handlers[1])
self.recipe_handlers = (None, None)
- def add_slave(self, slave_id, name):
- slave_log_path = os.path.join(self.recipe_log_path, name)
+ def add_slave(self, slave_id):
+ slave_log_path = os.path.join(self.recipe_log_path, slave_id)
self._clean_folder(slave_log_path)
- logger = logging.getLogger(name)
+ logger = logging.getLogger(slave_id)
logger.setLevel(logging.DEBUG)
logger.propagate = True
@@ -157,22 +157,21 @@ class LoggingCtl:
logger.addHandler(slave_info)
logger.addHandler(slave_debug)
- self.slaves[slave_id] = (name, slave_info, slave_debug)
+ self.slaves[slave_id] = (slave_info, slave_debug)
def remove_slave(self, slave_id):
- logger = logging.getLogger(self.slaves[slave_id][0])
+ logger = logging.getLogger(slave_id)
logger.propagate = False
+ logger.removeHandler(self.slaves[slave_id][0])
logger.removeHandler(self.slaves[slave_id][1])
- logger.removeHandler(self.slaves[slave_id][2])
del self.slaves[slave_id]
def add_client_log(self, slave_id, log_record):
- name = self.slaves[slave_id][0]
- logger = logging.getLogger(name)
+ logger = logging.getLogger(slave_id)
- log_record['address'] = '(' + name + ')'
+ log_record['address'] = '(' + slave_id + ')'
record = logging.makeLogRecord(log_record)
logger.handle(record)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 320182e..cce1678 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -198,7 +198,7 @@ class NetTestController:
machine = self._machines[m_id]
address = socket.gethostbyname(machine.get_hostname())
- self._log_ctl.add_slave(m_id, address)
+ self._log_ctl.add_slave(m_id)
machine.set_rpc(self._msg_dispatcher)
machine.set_mac_pool(self._mac_pool)
machine.set_network_bridges(self._network_bridges)
10 years, 5 months
[lnst] NetTestCommand: fix bg_id in result headers
by Jiří Pírko
commit e8ca563599886b6463c3085166e244df9465632f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Nov 8 16:22:36 2013 +0100
NetTestCommand: fix bg_id in result headers
bg_id in result summary was incorrectly formatted with a missing space.
This commit fixes that, and also swaps around the information about the
command and the bg_id. The reason for this is that the "bg_id: aaa"
could look like it was part of the command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 64bd432..5b12221 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = "bg_id: %s" % self._command["bg_id"]
+ bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
10 years, 5 months
[PATCH] NmConfigDevice: add team configuration through NM
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds support for configuring team devices through NM. The
support is limited to NM versions >= 0.9.9.
The code is similar to how bond configuration is done -> we create
connection objects for the team device and all the slaves, remove them
in reverse order. (De)Activation is done in the same order.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 102 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 6a258a6..affb0a9 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -673,20 +673,114 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
pass
class NmConfigDeviceTeam(NmConfigDeviceGeneric):
- #Not supported by NetworkManager yet
@classmethod
def is_nm_managed(cls, netdev, config):
- managed = False
+ if _dev_exists(netdev["hwaddr"]):
+ managed = super(NmConfigDeviceTeam, cls).is_nm_managed(netdev,
+ config)
+ else:
+ if get_nm_version() < "0.9.9":
+ managed = False
+ else:
+ slave_id = get_slaves(netdev)[0]
+ netdev = config[slave_id]
+ managed = is_nm_managed(netdev, config)
for slave in get_slaves(netdev):
- slave_netdev = config[slave]
- if is_nm_managed(slave_netdev, config) != managed:
+ netdev = config[slave]
+ if is_nm_managed(netdev, config) != managed:
msg = "Mixing NM managed and not managed devices in a "\
"master-slave relationship is not allowed!"
raise Exception(msg)
return managed
+ def up(self):
+ super(NmConfigDeviceTeam, self).up()
+
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ self._nm_activate_connection(netdev)
+
+ def down(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ self._nm_deactivate_connection(netdev)
+
+ super(NmConfigDeviceTeam, self).down()
+
+ def _add_team(self):
+ netdev = self._netdev
+ netdev["master_uuid"] = str(uuid.uuid4())
+
+ s_team_con = dbus.Dictionary({
+ 'type': 'team',
+ 'autoconnect': dbus.Boolean(False),
+ 'uuid': netdev["master_uuid"],
+ 'id': netdev["name"]+"_con"})
+
+ teamd_config = get_option(self._netdev, "teamd_config")
+
+ s_team = dbus.Dictionary({
+ 'interface-name': netdev["name"],
+ 'config': teamd_config})
+
+ s_ipv4, s_ipv6 = self._nm_make_ip_settings(netdev["addresses"])
+
+ connection = dbus.Dictionary({
+ 'team': s_team,
+ 'ipv4': s_ipv4,
+ 'ipv6': s_ipv6,
+ 'connection': s_team_con})
+
+ netdev["con_obj_path"] = self._nm_add_connection(connection)
+
+ def _rm_team(self):
+ netdev = self._netdev
+ if netdev["con_obj_path"] != "":
+ self._nm_rm_connection(netdev["con_obj_path"])
+ netdev["con_obj_path"] = ""
+
+ def _add_slaves(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ slave_name = netdev["name"]
+
+ hw_addr = self._convert_hwaddr(netdev)
+
+ s_eth = dbus.Dictionary({
+ 'duplex': dbus.Array('full', 's'),
+ 'mac-address': hw_addr})
+
+ s_slave_con = dbus.Dictionary({
+ 'type': '802-3-ethernet',
+ 'autoconnect': dbus.Boolean(False),
+ 'uuid': str(uuid.uuid4()),
+ 'id': 'slave_con',
+ 'master': self._netdev["master_uuid"],
+ 'slave-type': 'team'})
+
+ slave_con = dbus.Dictionary({
+ '802-3-ethernet': s_eth,
+ 'connection': s_slave_con})
+
+ netdev["con_obj_path"] = self._nm_add_connection(slave_con)
+
+ def _rm_slaves(self):
+ for slave in get_slaves(self._netdev):
+ netdev = self._config[slave]
+ if netdev["con_obj_path"] != "":
+ self._nm_rm_connection(netdev["con_obj_path"])
+ netdev["con_obj_path"] = ""
+
+ def configure(self):
+ self._add_team()
+ self._add_slaves()
+
+ def deconfigure(self):
+ self._rm_slaves()
+ self._rm_team()
+
type_class_mapping = {
"eth": NmConfigDeviceEth,
"bond": NmConfigDeviceBond,
--
1.8.3.1
10 years, 5 months
[PATCH] NmConfigDevice: add detection of NM version
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds a new function that returns the version of the running
NM daemon. The version is determined through dbus. For now I've used it
to detect whether to manually remove soft network devices or to leave NM
do it (NM version >= 0.9.9 removes them automatically). Later this will
be used to determine if team devices are supported by NM.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 51 ++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index a2ad57f..6a258a6 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -60,6 +60,18 @@ def _dev_exists(hwaddr):
if dev["hwaddr"] == hwaddr:
return True
+def get_nm_version():
+ if not check_process_running("NetworkManager") or\
+ not lnst_config.get_option("environment", "use_nm"):
+ return ""
+
+ bus = dbus.SystemBus()
+ nm_obj = bus.get_object(NM_BUS, OBJ_PRE)
+ nm_if = dbus.Interface(nm_obj, IF_PRE)
+
+ props = dbus.Interface(nm_obj, "org.freedesktop.DBus.Properties")
+ return props.Get(IF_PRE, "Version")
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -392,11 +404,12 @@ class NmConfigDeviceBond(NmConfigDeviceGeneric):
netdev["con_obj_path"] = ""
#older versions of NM don't know how to remove soft devices...
- try:
- bond_masters = "/sys/class/net/bonding_masters"
- exec_cmd('echo "-%s" > %s' % (netdev["name"], bond_masters))
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ bond_masters = "/sys/class/net/bonding_masters"
+ exec_cmd('echo "-%s" > %s' % (netdev["name"], bond_masters))
+ except:
+ pass
def _add_slaves(self):
for slave in get_slaves(self._netdev):
@@ -505,11 +518,12 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
netdev["con_obj_path"] = ""
#older versions of NM don't know how to remove soft devices...
- try:
- exec_cmd("ip link set %s down" % netdev["name"])
- exec_cmd("brctl delbr %s " % netdev["name"])
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ exec_cmd("ip link set %s down" % netdev["name"])
+ exec_cmd("brctl delbr %s " % netdev["name"])
+ except:
+ pass
def _add_slave(self, slave):
netdev = self._config[slave]
@@ -648,14 +662,15 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
#older versions of NM don't know how to remove soft devices...
#and lnst will break when multiple devices with the same mac exist
- try:
- dev_name = self._get_vlan_info()[0]
- if self._check_ip_link_add():
- exec_cmd("ip link del %s" % dev_name)
- else:
- exec_cmd("vconfig rem %s" % dev_name)
- except:
- pass
+ if get_nm_version() < "0.9.9":
+ try:
+ dev_name = self._get_vlan_info()[0]
+ if self._check_ip_link_add():
+ exec_cmd("ip link del %s" % dev_name)
+ else:
+ exec_cmd("vconfig rem %s" % dev_name)
+ except:
+ pass
class NmConfigDeviceTeam(NmConfigDeviceGeneric):
#Not supported by NetworkManager yet
--
1.8.3.1
10 years, 5 months
how to deal with bridge device kernel module removal
by Jan Tluka
Hi everyone,
I've come to a topic that we discussed some time ago but we did not
choose any path to follow since then.
Here's the case. I'm testing in a network with one virtual host that's running
on dom0 that acts both as the controller and a slave machine, too.
There's a bridge device on this multi-role machine involved in testing. The
bridge device gets configured but at the end of the test this device gets
cleaned up and bridge kernel module gets removed, too. This results in breaking
the libvirt's networking infrastructure for the guest and the libvirt's network
has to be reinitialized.
I know, not a typical use case but here's another more realistic.
A network with a bare-metal host hosting two guests (deployed in the <task>
part of the recipe) that are sending some data through dom0 to another
bare-metal host.
The solution to this is removing the _modulename from the bridge device code.
What's your opinion on this?
-Jan
10 years, 5 months
[PATCH] Logs: use machine names instead of IP addresses
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit changes the format of log messages, instead of using
hostnames, which are usually IP addresses, we will use the host ids that
are specified in the supplied recipe.
This makes it more obvious what's happening on which machine. The
information about the used hosts is still available at the beginning of
recipe execution when the controller finds a suitable match.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Logs.py | 19 +++++++++----------
lnst/Controller/NetTestController.py | 2 +-
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/lnst/Common/Logs.py b/lnst/Common/Logs.py
index 33a43a7..b891439 100644
--- a/lnst/Common/Logs.py
+++ b/lnst/Common/Logs.py
@@ -44,7 +44,7 @@ class MultilineFormatter(Formatter): # addr:17 level:7
def _format_addr(self, record):
if not "address" in record.__dict__:
- addr = "(127.0.0.1)".rjust(17)
+ addr = "(localhost)".rjust(17)
else:
addr = record.address.rjust(17)
@@ -145,11 +145,11 @@ class LoggingCtl:
logger.removeHandler(self.recipe_handlers[1])
self.recipe_handlers = (None, None)
- def add_slave(self, slave_id, name):
- slave_log_path = os.path.join(self.recipe_log_path, name)
+ def add_slave(self, slave_id):
+ slave_log_path = os.path.join(self.recipe_log_path, slave_id)
self._clean_folder(slave_log_path)
- logger = logging.getLogger(name)
+ logger = logging.getLogger(slave_id)
logger.setLevel(logging.DEBUG)
logger.propagate = True
@@ -157,22 +157,21 @@ class LoggingCtl:
logger.addHandler(slave_info)
logger.addHandler(slave_debug)
- self.slaves[slave_id] = (name, slave_info, slave_debug)
+ self.slaves[slave_id] = (slave_info, slave_debug)
def remove_slave(self, slave_id):
- logger = logging.getLogger(self.slaves[slave_id][0])
+ logger = logging.getLogger(slave_id)
logger.propagate = False
+ logger.removeHandler(self.slaves[slave_id][0])
logger.removeHandler(self.slaves[slave_id][1])
- logger.removeHandler(self.slaves[slave_id][2])
del self.slaves[slave_id]
def add_client_log(self, slave_id, log_record):
- name = self.slaves[slave_id][0]
- logger = logging.getLogger(name)
+ logger = logging.getLogger(slave_id)
- log_record['address'] = '(' + name + ')'
+ log_record['address'] = '(' + slave_id + ')'
record = logging.makeLogRecord(log_record)
logger.handle(record)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 320182e..cce1678 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -198,7 +198,7 @@ class NetTestController:
machine = self._machines[m_id]
address = socket.gethostbyname(machine.get_hostname())
- self._log_ctl.add_slave(m_id, address)
+ self._log_ctl.add_slave(m_id)
machine.set_rpc(self._msg_dispatcher)
machine.set_mac_pool(self._mac_pool)
machine.set_network_bridges(self._network_bridges)
--
1.8.3.1
10 years, 5 months
[PATCH] NetTestCommand: fix bg_id in result headers
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
bg_id in result summary was incorrectly formatted with a missing space.
This commit fixes that, and also swaps around the information about the
command and the bg_id. The reason for this is that the "bg_id: aaa"
could look like it was part of the command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 64bd432..5b12221 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = "bg_id: %s" % self._command["bg_id"]
+ bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
--
1.8.3.1
10 years, 5 months