aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/InterfaceUtil.py
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2017-05-31 13:25:24 +0000
committerPeter Mikus <pmikus@cisco.com>2017-06-06 09:04:40 +0000
commitd058458cb57eaa68c9aafe03fa823e7489664bf0 (patch)
tree509451686977e8e0d8226f898133d50a80294aee /resources/libraries/python/InterfaceUtil.py
parente2f9bdd098fb0008cc4fc2f8c8298ebe0d6ef062 (diff)
VIRL lspci fix
Change-Id: I884b56c5cc2e0d5f40c0e9d0b5fb7356dc3b4028 Signed-off-by: pmikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/python/InterfaceUtil.py')
-rw-r--r--resources/libraries/python/InterfaceUtil.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index e5597b9065..750029e197 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -348,27 +348,35 @@ class InterfaceUtil(object):
ssh = SSH()
ssh.connect(node)
- # First rescan PCI devices in the system
- cmd = 'sh -c "echo 1 > /sys/bus/pci/rescan"'
- (ret_code, _, _) = ssh.exec_command_sudo(cmd)
- if int(ret_code) != 0:
- raise RuntimeError("'{0}' failed on '{1}'"
- .format(cmd, node['host']))
-
- cmd = 'lspci -vmmks {0}'.format(pci_addr)
- (ret_code, stdout, _) = ssh.exec_command(cmd)
- if int(ret_code) != 0:
- raise RuntimeError("'{0}' failed on '{1}'"
- .format(cmd, node['host']))
+ for i in range(3):
+ logger.trace('Try {}: Get interface driver'.format(i))
+ cmd = 'sh -c "echo 1 > /sys/bus/pci/rescan"'
+ (ret_code, _, _) = ssh.exec_command_sudo(cmd)
+ if int(ret_code) != 0:
+ raise RuntimeError("'{0}' failed on '{1}'"
+ .format(cmd, node['host']))
- for line in stdout.splitlines():
- if len(line) == 0:
- continue
- (name, value) = line.split("\t", 1)
- if name == 'Driver:':
- return value
+ cmd = 'lspci -vmmks {0}'.format(pci_addr)
+ (ret_code, stdout, _) = ssh.exec_command(cmd)
+ if int(ret_code) != 0:
+ raise RuntimeError("'{0}' failed on '{1}'"
+ .format(cmd, node['host']))
- return None
+ for line in stdout.splitlines():
+ if len(line) == 0:
+ continue
+ try:
+ (name, value) = line.split("\t", 1)
+ except ValueError:
+ if name != "Driver:":
+ pass
+ else:
+ return None
+ if name == 'Driver:':
+ return value if value else None
+ else:
+ raise RuntimeError('Get interface driver for: {0}'\
+ .format(pci_addr))
@staticmethod
def tg_set_interfaces_udev_rules(node):