NetworkManager hijacks LNST controlled interfaces
by Radek Pazdera
Hi,
there's a problem I've been dealing with network manager running on the
slaves.
Each time a new interface is hot-plugged to the machine, NM creates a
default
connection profile for it and executes it. It means, that it tries to
run dhclient
on that interface once in a while.
That's a problem, because we configure interfaces on slaves "manually"
with ip
command. This configuration is flushed when by NM when it tries to
enforce the
"Auto eth5" default profile on the interface. There's not even a DHCP server
running in the environment I tested this in.
The thing is, that we need to have the network-manager running, because
it starts
dhclient when the controller interface is plugged in. I don't know
whether the
standard networking scripts can do this too. And if they can, we need a
way to
turn NM off somehow anyway (which is hard, because we don't have shell
at that
time yet).
NM has a D-Bus interface and a cli-wrapper around it called 'nmcli'.
This utility
is shipped along with the NM package. It can be used to exclude some
interfaces
from NM control by issuing
nmcli dev disconnect iface eth2
command without necessity to restart the whole service (which is
something we cannot
do, since we're connected through ssh).
Has this ever happened to you? It usually results a failure in the
cleanup phase on
ip addr del ...
command saying that it cannot clear the address (because NM already
flushed it). Or
do you have NM off on slaves?
Radek :)
11 years, 4 months
[lnst] XmlTemplates: error messages for template functions
by Jiří Pírko
commit 3e54448e4f6633ba126950829cfa1f21259365a6
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Aug 3 12:38:06 2012 +0200
XmlTemplates: error messages for template functions
Passing illegal parameters to template functions would result in raising
of KeyError or IndexError exceptions.
This commit fixes that by raising XmlTemplateError exception with a
meaningful error message.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/XmlTemplates.py | 49 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index a88ccca..d79efe5 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -223,8 +223,23 @@ class XmlTemplates:
if_id = int(params[1])
ip_id = int(params[2]) if len(params) == 3 else 0
- machines = recipe["machines"]
- ip_addr = machines[m_id]['netconfig'][if_id]['addresses'][ip_id]
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function ip() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machine = recipe["machines"][m_id]
+
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function ip() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ if ip_id >= len(machine['netconfig'][if_id]['addresses']):
+ msg = "Third parameter of function ip() is invalid: "\
+ "Address %s does not exist." % ip_id
+ raise XmlTemplateError(msg)
+ ip_addr = machine['netconfig'][if_id]['addresses'][ip_id]
+
return ip_addr.split('/')[0]
@@ -234,8 +249,19 @@ class XmlTemplates:
m_id = int(params[0])
if_id = int(params[1])
- machines = recipe["machines"]
- return machines[m_id]['netconfig'][if_id]['hwaddr']
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function hwaddr() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machine = recipe["machines"][m_id]
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function hwaddr() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ mac_addr = machine['netconfig'][if_id]['hwaddr']
+
+ return mac_addr
def _devname_func(self, params):
@@ -244,8 +270,19 @@ class XmlTemplates:
m_id = int(params[0])
if_id = int(params[1])
- machines = recipe["machines"]
- return machines[m_id]['netconfig'][if_id]['name']
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function devname() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machines = recipe["machines"][m_id]
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function devname() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ dev_name = machines['netconfig'][if_id]['name']
+
+ return dev_name
@staticmethod
def _validate_func_params(name, params, mandatory, optional):
11 years, 4 months
[PATCH] XmlTemplates: error messages for template functions
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Passing illegal parameters to template functions would result in raising
of KeyError or IndexError exceptions.
This commit fixes that by raising XmlTemplateError exception with a
meaningful error message.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
Common/XmlTemplates.py | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index a88ccca..d79efe5 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -223,8 +223,23 @@ class XmlTemplates:
if_id = int(params[1])
ip_id = int(params[2]) if len(params) == 3 else 0
- machines = recipe["machines"]
- ip_addr = machines[m_id]['netconfig'][if_id]['addresses'][ip_id]
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function ip() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machine = recipe["machines"][m_id]
+
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function ip() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ if ip_id >= len(machine['netconfig'][if_id]['addresses']):
+ msg = "Third parameter of function ip() is invalid: "\
+ "Address %s does not exist." % ip_id
+ raise XmlTemplateError(msg)
+ ip_addr = machine['netconfig'][if_id]['addresses'][ip_id]
+
return ip_addr.split('/')[0]
@@ -234,8 +249,19 @@ class XmlTemplates:
m_id = int(params[0])
if_id = int(params[1])
- machines = recipe["machines"]
- return machines[m_id]['netconfig'][if_id]['hwaddr']
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function hwaddr() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machine = recipe["machines"][m_id]
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function hwaddr() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ mac_addr = machine['netconfig'][if_id]['hwaddr']
+
+ return mac_addr
def _devname_func(self, params):
@@ -244,8 +270,19 @@ class XmlTemplates:
m_id = int(params[0])
if_id = int(params[1])
- machines = recipe["machines"]
- return machines[m_id]['netconfig'][if_id]['name']
+ if 'machines' not in recipe or m_id not in recipe['machines']:
+ msg = "First parameter of function devname() is invalid: "\
+ "Machine %s does not exist." % m_id
+ raise XmlTemplateError(msg)
+ machines = recipe["machines"][m_id]
+
+ if if_id not in machine['netconfig']:
+ msg = "Second parameter of function devname() is invalid: "\
+ "Interface %s does not exist." % if_id
+ raise XmlTemplateError(msg)
+ dev_name = machines['netconfig'][if_id]['name']
+
+ return dev_name
@staticmethod
def _validate_func_params(name, params, mandatory, optional):
--
1.7.11.2
11 years, 4 months
[lnst] multicast: Disable logging output of exec_cmd
by Jiří Pírko
commit d7189d9efe8d602de66143d57f9357da408866d6
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Wed Aug 1 13:28:00 2012 +0200
multicast: Disable logging output of exec_cmd
This commit disables logging of exec_cmd in TestMulticast.py.
The first one does compilation of the test tools which only polutes
the messages and the second exec's output is processed further and
written to log after the processing.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Tests/TestMulticast.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/Tests/TestMulticast.py b/Tests/TestMulticast.py
index 5e2df5b..860608a 100644
--- a/Tests/TestMulticast.py
+++ b/Tests/TestMulticast.py
@@ -108,10 +108,11 @@ class TestMulticast(TestGeneric):
setup_name = self.get_mopt("setup")
logging.info("Started Multicast test setup {0}".format(setup_name))
- exec_cmd("cd " + self._tools_location + " && make")
+ exec_cmd("cd " + self._tools_location + " && make",
+ log_outputs=False)
cmd = self._compose_cmd()
- data_stdout = exec_cmd(cmd, die_on_err=False)[0]
+ data_stdout = exec_cmd(cmd, die_on_err=False, log_outputs=False)[0]
res = {}
11 years, 4 months
[PATCH] multicast: Disable logging output of exec_cmd
by Radek Pazdera
From: Radek Pazdera <rpazdera(a)redhat.com>
This commit disables logging of exec_cmd in TestMulticast.py.
The first one does compilation of the test tools which only polutes
the messages and the second exec's output is processed further and
written to log after the processing.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
Tests/TestMulticast.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Tests/TestMulticast.py b/Tests/TestMulticast.py
index 5e2df5b..860608a 100644
--- a/Tests/TestMulticast.py
+++ b/Tests/TestMulticast.py
@@ -108,10 +108,11 @@ class TestMulticast(TestGeneric):
setup_name = self.get_mopt("setup")
logging.info("Started Multicast test setup {0}".format(setup_name))
- exec_cmd("cd " + self._tools_location + " && make")
+ exec_cmd("cd " + self._tools_location + " && make",
+ log_outputs=False)
cmd = self._compose_cmd()
- data_stdout = exec_cmd(cmd, die_on_err=False)[0]
+ data_stdout = exec_cmd(cmd, die_on_err=False, log_outputs=False)[0]
res = {}
--
1.7.7.6
11 years, 4 months
[lnst] ExecCmd: Adding some info to ExecCmdFail exception
by Jiří Pírko
commit 252bb2624ab2bb0c97be1a28a0777cb8b8c76db1
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Wed Aug 1 13:00:06 2012 +0200
ExecCmd: Adding some info to ExecCmdFail exception
This commit extends ExecCmdFail exception with some information of
what went wrong, so the parent code that can catch this error can
react appropriatelly.
ExecCmdFail now contains return value of the command, the command
itself (for reporting purposes - which command failed) and conents
of standard error output, that usualy contains a clue or some error
message.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Common/ExecCmd.py | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/Common/ExecCmd.py b/Common/ExecCmd.py
index e2e7f61..702ad73 100644
--- a/Common/ExecCmd.py
+++ b/Common/ExecCmd.py
@@ -14,7 +14,25 @@ import logging
import subprocess
class ExecCmdFail(Exception):
- pass
+ _cmd = None
+ _retval = None
+ _stderr = None
+
+ def __init__(self, cmd=None, retval=None, err=""):
+ self._stderr = err
+ self._retval = retval
+
+ def get_cmd(self):
+ return self._cmd
+
+ def get_stderr(self):
+ return self._stderr
+
+ def __str__(self):
+ retval = ""
+ if self._retval:
+ retval = " (exited with %d)" % self._retval
+ return "Command execution failed%s" % retval
def log_output(log_func, out_type, out):
log_func("%s:\n"
@@ -40,7 +58,8 @@ def exec_cmd(cmd, die_on_err=True, log_outputs=True):
if data_stderr:
log_output(logging.error, "Stderr", data_stderr)
if subp.returncode and die_on_err:
- logging.error("Command failed with error \"%d\"" % subp.returncode)
- raise ExecCmdFail
+ err = ExecCmdFail(cmd, subp.returncode, data_stderr)
+ logging.error(err)
+ raise err
return data_stdout, data_stderr
11 years, 4 months
[lnst] NetConfig: More cleanup
by Jiří Pírko
commit 45001c236725e566db6c0438a69825bd70e9c7a5
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Wed Aug 1 12:56:13 2012 +0200
NetConfig: More cleanup
I forgot to remove one more line in NetConfig in the previous cleanup
commit (2587cd9176895a27e13dc10558f1e00847edab05).
This commit fixes that.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
NetConfig/NetConfig.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
---
diff --git a/NetConfig/NetConfig.py b/NetConfig/NetConfig.py
index 6e97478..41a99d8 100644
--- a/NetConfig/NetConfig.py
+++ b/NetConfig/NetConfig.py
@@ -70,7 +70,6 @@ class NetConfig:
def remove_interface_config(self, if_id):
config = self._config[if_id]
del self._config[if_id]
- print self._config
dev_type = config["type"]
if not dev_type in self._get_used_types():
11 years, 4 months
[PATCH] ExecCmd: Adding some info to ExecCmdFail exception
by Radek Pazdera
From: Radek Pazdera <rpazdera(a)redhat.com>
This commit extends ExecCmdFail exception with some information of
what went wrong, so the parent code that can catch this error can
react appropriatelly.
ExecCmdFail now contains return value of the command, the command
itself (for reporting purposes - which command failed) and conents
of standard error output, that usualy contains a clue or some error
message.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
Common/ExecCmd.py | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/Common/ExecCmd.py b/Common/ExecCmd.py
index e2e7f61..702ad73 100644
--- a/Common/ExecCmd.py
+++ b/Common/ExecCmd.py
@@ -14,7 +14,25 @@ import logging
import subprocess
class ExecCmdFail(Exception):
- pass
+ _cmd = None
+ _retval = None
+ _stderr = None
+
+ def __init__(self, cmd=None, retval=None, err=""):
+ self._stderr = err
+ self._retval = retval
+
+ def get_cmd(self):
+ return self._cmd
+
+ def get_stderr(self):
+ return self._stderr
+
+ def __str__(self):
+ retval = ""
+ if self._retval:
+ retval = " (exited with %d)" % self._retval
+ return "Command execution failed%s" % retval
def log_output(log_func, out_type, out):
log_func("%s:\n"
@@ -40,7 +58,8 @@ def exec_cmd(cmd, die_on_err=True, log_outputs=True):
if data_stderr:
log_output(logging.error, "Stderr", data_stderr)
if subp.returncode and die_on_err:
- logging.error("Command failed with error \"%d\"" % subp.returncode)
- raise ExecCmdFail
+ err = ExecCmdFail(cmd, subp.returncode, data_stderr)
+ logging.error(err)
+ raise err
return data_stdout, data_stderr
--
1.7.7.6
11 years, 4 months
[PATCH] NetConfig: Small code cleanup
by Radek Pazdera
From: Radek Pazdera <rpazdera(a)redhat.com>
This commit merges type_init() function with add_interface_config() and
type_cleanup() with remove_interface_config().
These functions had too dangerous preconditions, which was not very
obvious. The preconditions disappear after the merge.
Also an info entry will be written to the log when a device class is
initialized or cleaned up.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
NetConfig/NetConfig.py | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/NetConfig/NetConfig.py b/NetConfig/NetConfig.py
index 57903cd..6e97478 100644
--- a/NetConfig/NetConfig.py
+++ b/NetConfig/NetConfig.py
@@ -58,23 +58,24 @@ class NetConfig:
types.add(netdev["type"])
return types
- def _type_init(self, dev_type):
+ def add_interface_config(self, if_id, config):
+ dev_type = config["type"]
if not dev_type in self._get_used_types():
+ logging.info("Initializing '%s' device class", dev_type)
NetConfigDeviceType(dev_type).type_init()
- def _type_cleanup(self, dev_type):
- if not dev_type in self._get_used_types():
- NetConfigDeviceType(dev_type).type_cleanup()
-
- def add_interface_config(self, if_id, config):
- self._type_init(config["type"])
self._config[if_id] = config
self._devnames.assign_name(if_id, self._config)
def remove_interface_config(self, if_id):
config = self._config[if_id]
del self._config[if_id]
- self._type_cleanup(config["type"])
+ print self._config
+
+ dev_type = config["type"]
+ if not dev_type in self._get_used_types():
+ logging.info("Cleaning up '%s' device class.", dev_type)
+ NetConfigDeviceType(dev_type).type_cleanup()
def get_interface_config(self, if_id):
return self._config[if_id]
--
1.7.7.6
11 years, 4 months