From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit fixes several Exception messages that were formatted with
variables, but there were no formatting escape sequences in them which
caused crashes.
Also the initialize method of class Interface uses the result of the
get_devices_by_hwaddr slave method to properly set the interface
devname.
Finally I had to add a sleep call after the interface deconfiguration
call because sometimes dynamically added devices (through libvirt) would
change their MAC address based on their master bond device, and wouldn't
have enough time to change back before deleting them.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 14e78ed..e509736 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -351,7 +351,7 @@ class Interface(object):
def get_hwaddr(self):
if not self._hwaddr:
- msg = "Hardware address is not available for interface ''"
\
+ msg = "Hardware address is not available for interface
'%s'" \
% self.get_id()
raise MachineError(msg)
return self._hwaddr
@@ -361,7 +361,7 @@ class Interface(object):
def get_devname(self):
if not self._devname:
- msg = "Device name is not available for interface ''" \
+ msg = "Device name is not available for interface '%s'" \
% self.get_id()
raise MachineError(msg)
return self._devname
@@ -371,7 +371,7 @@ class Interface(object):
def get_network(self):
if not self._network:
- msg = "Network segment is not available for interface ''"
\
+ msg = "Network segment is not available for interface '%s'"
\
% self.get_id()
raise MachineError(msg)
return self._network
@@ -407,7 +407,7 @@ class Interface(object):
phys_devs = self._machine._rpc_call("get_devices_by_hwaddr",
self._hwaddr)
if len(phys_devs) == 1:
- pass
+ self.set_devname(phys_devs[0]["name"])
elif len(phys_devs) < 1:
msg = "Device %s not found on machine %s" \
% (self.get_id(), self._machine.get_id())
@@ -449,6 +449,7 @@ class Interface(object):
self._machine._rpc_call("deconfigure_interface", self.get_id())
self._configured = False
+ sleep(1)
class StaticInterface(Interface):
""" Static interface
--
1.8.3.1