[PATCH] NetConfigDevice: don't set loopback device down
by Jan Tluka
We do not want to bring loopback device down in root namespace as
this might have an unpredictable impact on further testing.
In case of non-root namespace leaving loopback device up is not
a problem since the namespace will get destroyed after recipe is
finished anyway.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Slave/NetConfigDevice.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index 0fbc3f0..1422850 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -97,6 +97,14 @@ class NetConfigDeviceLoopback(NetConfigDeviceGeneric):
def configure(self):
config = self._dev_config
+ def down(self):
+ # We do not want to bring loopback device down in root namespace as
+ # this might have an unpredictable impact on further testing.
+ # In case of non-root namespace leaving loopback device up is not
+ # a problem since the namespace will get destroyed after recipe is
+ # finished
+ pass
+
class NetConfigDeviceBond(NetConfigDeviceGeneric):
_modulename = "bonding"
_moduleparams = "max_bonds=0"
--
2.1.0
7 years, 8 months
issue #136 - RFC
by Jiri Prochazka
Hello,
I'd like to ask you about your opinion of the issue #136 [1].
The first idea me and Jan had was this:
- Compute MD5 hash of files lnst-ctl, lnst-slave and all .py files in LNST
modules directory
- Compare it via hello message between Slave and Controller
- If hashes mismatch, end with an error
However, there is a problem with path of the binary and module files.
When we are running LNST from git, lnst-ctl, lnst-slave and modules are all
in the same directory.
When we are running LNST from RPM or installation from git, binaries are in
/usr/bin/ or /bin/ and modules are in /usr/share/lnst/.
I've came up with following approach to this, described in [2]. This way,
mixing of git and RPM is allowed, as long as all the important files are
the same.
When the hashes are calculated, they are compared within the hello() method
on Controller.
If you have any better solution or comments to this, both are very welcome
[1] https://github.com/jpirko/lnst/issues/136
[2] https://ctrlv.cz/7RgT
Best regards,
Jiri Prochazka
LNST Developer
| www.lnst-project.org
+420 532 294 633 | jprochaz(a)redhat.com
Red Hat Czech | Purkyňova 71/99, 612 00 Brno
7 years, 9 months
[PATCH v2 1/8] pool-wizard: Add new line in error message of _create_dir method
by Jiri Prochazka
New line was missing in print of an error message of _create_dir method
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Wizard.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/Controller/Wizard.py b/lnst/Controller/Wizard.py
index f2c645c..51856e8 100644
--- a/lnst/Controller/Wizard.py
+++ b/lnst/Controller/Wizard.py
@@ -186,7 +186,7 @@ class Wizard:
print("Dir '%s' has been created" % pool_dir)
return pool_dir
except:
- sys.stderr.write("Failed creating dir")
+ sys.stderr.write("Failed creating dir\n")
return None
def _create_xml(self, machine_interfaces, hostname,
--
2.4.3
7 years, 9 months
[PATCH] regression-tests: Fix LNST regression test #13
by Jiri Prochazka
Since 90ab16c, non defined aliases return None when accessed,
instead of raising XmlTemplateError exception, making this
test invalid. This patch fixes it, so it expects failure instead
of an error
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
regression-tests/tests/13/run.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/regression-tests/tests/13/run.sh b/regression-tests/tests/13/run.sh
index f988ae6..b72d1e2 100755
--- a/regression-tests/tests/13/run.sh
+++ b/regression-tests/tests/13/run.sh
@@ -17,6 +17,6 @@ assert_status "fail" "$rv"
lnst-ctl -d run taskapi-alias-namespace-check.xml
rv=$?
-assert_status "error" "$rv"
+assert_status "fail" "$rv"
end_test
--
2.4.3
7 years, 9 months
[PATCH] Controller: Replace InterfaceAPI.get_ip_prefix() with InterfaceAPI.get_prefix()
by Jiri Prochazka
This patch renames InterfaceAPI.get_ip_prefix() to InterfaceAPI.get)prefix(),
leaves InterfaceAPI.get_ip_prefix() as an alias to InterfaceAPI.get_prefix()
and marks InterfaceAPI.get_ip_prefix() as deprecated
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Task.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 7306203..f3047ef 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -373,9 +373,13 @@ class InterfaceAPI(object):
def get_ip_addrs(self):
return self.get_ips()
- def get_ip_prefix(self, ip_index):
+ def get_prefix(self, ip_index):
return VolatileValue(self._if.get_prefix, ip_index)
+ @deprecated
+ def get_ip_prefix(self, ip_index):
+ return self.get_prefix(ip_index)
+
def get_mtu(self):
return VolatileValue(self._if.get_mtu)
--
2.4.3
7 years, 9 months
[PATCH 1/3] Utils: Add get_version_hash function
by Jiri Prochazka
This function computes hash from all .py files in "lnst/" directory and
from files "lnst-ctl" and "lnst-slave".
This function will be used for computing version of LNST
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Common/Utils.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 22d2925..ce67c92 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -290,3 +290,33 @@ def is_installed(program):
return True
except subprocess.CalledProcessError:
return False
+
+def get_version_hash():
+ """
+ Returns MD5 hash computed from all .py files in lnst/ directory
+ and files lnst-ctl and lnst-slave
+ """
+ file_list = []
+ file_sum = ""
+
+ for root, _, files in os.walk("./lnst/"):
+ for f in files:
+ if f.endswith(".py"):
+ file_list.append(os.path.join(root, f))
+
+ file_list.sort()
+
+ for f in file_list:
+ with open(f, 'r') as fin:
+ file_sum += fin.read()
+ fin.close()
+
+ for f in ["./lnst-ctl", "./lnst-slave"]:
+ with open(f, 'r') as fin:
+ file_sum += fin.read()
+ fin.close()
+
+ md5 = hashlib.md5()
+ md5.update(file_sum)
+
+ return md5.hexdigest()
--
2.4.3
7 years, 9 months
[PATCH 1/8] pool-wizard: Add new line in error message of _create_dir method
by Jiri Prochazka
New line was missing in print of an error message of _create_dir method
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Wizard.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/Controller/Wizard.py b/lnst/Controller/Wizard.py
index f2c645c..51856e8 100644
--- a/lnst/Controller/Wizard.py
+++ b/lnst/Controller/Wizard.py
@@ -186,7 +186,7 @@ class Wizard:
print("Dir '%s' has been created" % pool_dir)
return pool_dir
except:
- sys.stderr.write("Failed creating dir")
+ sys.stderr.write("Failed creating dir\n")
return None
def _create_xml(self, machine_interfaces, hostname,
--
2.4.3
7 years, 9 months
[PATCH] Controller: Mark HostAPI methods get_hwaddr, get_devname and get_prefix as deprecated
by Jiri Prochazka
Users shouldn't use these methods, instead they should use methods from InterfaceAPI,
this patch adds decorator to the methods, so each time method is called, warning message
is shown in log warning user that the message is deprecated and he should check documentation
for up-to-date method
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Task.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 5aa0ea1..4cdd3c8 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -260,6 +260,7 @@ class HostAPI(object):
def get_interface(self, interface_id):
return self._interfaces[interface_id]
+ @deprecated
def get_devname(self, interface_id):
"""
Returns devname of the interface.
@@ -273,6 +274,7 @@ class HostAPI(object):
iface = self._interfaces[interface_id]
return iface.get_devname()
+ @deprecated
def get_hwaddr(self, interface_id):
"""
Returns hwaddr of the interface.
@@ -303,6 +305,7 @@ class HostAPI(object):
iface = self._interfaces[interface_id]
return iface.get_ip_addr(addr_number)
+ @deprecated
def get_prefix(self, interface_id, addr_number=0):
"""
Returns an IP address prefix (netmask)
--
2.4.3
7 years, 9 months
[PATCH v3 1/5] Add is_installed method
by Jiri Prochazka
This method is used for detecting if program is present in $PATH
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Common/Utils.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index b42fc86..22d2925 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -278,3 +278,15 @@ def deprecated(func):
% (func.__name__, self.__class__.__name__))
return func(self, *args, **kwargs)
return log
+
+def is_installed(program):
+ """
+ Returns True if program is detected by which, False otherwise
+ """
+ cmd = "which %s" % program
+ try:
+ subprocess.check_call(cmd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ return True
+ except subprocess.CalledProcessError:
+ return False
--
2.4.3
7 years, 9 months
[PATCH V2 1/2] InterfaceManager: Add link state methods
by Ido Schimmel
In order to test link negotiation it is useful to have methods that can
change the link state of an interface from a task.
Add the 'set_link_up' and 'set_link_down' methods for interfaces.
Unlike existing methods, these methods only change the link state and
nothing else (e.g. setting an address).
Changes in V2:
* Rename 'carrier_on' to 'link_up'
* Rename 'carrier_off' to 'link_down'
Signed-off-by: Ido Schimmel <idosch(a)mellanox.com>
Signed-off-by: Jiri Pirko <jiri(a)mellanox.com>
---
lnst/Controller/Machine.py | 14 ++++++++++++++
lnst/Controller/Task.py | 6 ++++++
lnst/Slave/InterfaceManager.py | 6 ++++++
lnst/Slave/NetTestSlave.py | 18 ++++++++++++++++++
4 files changed, 44 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index e60e1ea..895397b 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -717,6 +717,20 @@ class Interface(object):
else:
self._machine._rpc_call("set_device_down", self._id)
+ def set_link_up(self):
+ netns = self._netns
+ if netns != None:
+ self._machine._rpc_call_to_netns(netns, "set_link_up", self._id)
+ else:
+ self._machine._rpc_call("set_link_up", self._id)
+
+ def set_link_down(self):
+ netns = self._netns
+ if netns != None:
+ self._machine._rpc_call_to_netns(netns, "set_link_down", self._id)
+ else:
+ self._machine._rpc_call("set_link_down", self._id)
+
def initialize(self):
phys_devs = self._machine._rpc_call("map_if_by_hwaddr",
self._id, self._hwaddr)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 0d437f3..44c328d 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -370,6 +370,12 @@ class InterfaceAPI(object):
def set_mtu(self, mtu):
return self._if.set_mtu(mtu)
+ def set_link_up(self):
+ return self._if.set_link_up()
+
+ def set_link_down(self):
+ return self._if.set_link_down()
+
class ModuleAPI(object):
""" An API class representing a module. """
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index 09f3be9..de3adba 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -486,6 +486,12 @@ class Device(object):
else:
exec_cmd("ip link set %s down" % self._name)
+ def link_up(self):
+ exec_cmd("ip link set %s up" % self._name)
+
+ def link_down(self):
+ exec_cmd("ip link set %s down" % self._name)
+
def set_netns(self, netns):
self._netns = netns
return
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 775d4a5..b5d76b9 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -174,6 +174,24 @@ class SlaveMethods:
return False
return True
+ def set_link_up(self, if_id):
+ dev = self._if_manager.get_mapped_device(if_id)
+ if dev is not None:
+ dev.link_up()
+ else:
+ logging.error("Device with id '%s' not found." % if_id)
+ return False
+ return True
+
+ def set_link_down(self, if_id):
+ dev = self._if_manager.get_mapped_device(if_id)
+ if dev is not None:
+ dev.link_down()
+ else:
+ logging.error("Device with id '%s' not found." % if_id)
+ return False
+ return True
+
def set_unmapped_device_down(self, hwaddr):
dev = self._if_manager.get_device_by_hwaddr(hwaddr)
if dev is not None:
--
2.4.6
7 years, 9 months