X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FInterfaceUtil.py;h=750029e19759a90c3a43a84e73898f01cc0482bc;hb=7436d8bdf60bca9b80fb76781e1f709bbcd435da;hp=793f908a7a40c32b441cb8d0f11acb89aa1d9cc1;hpb=8c1bb6ac0c8253ee203d120c1a8f035c47293d9e;p=csit.git diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 793f908a7a..750029e197 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -261,8 +261,14 @@ class InterfaceUtil(object): :rtype: list """ - sw_if_index = Topology.convert_interface_reference( - node, interface, "sw_if_index") + try: + sw_if_index = Topology.convert_interface_reference( + node, interface, "sw_if_index") + except RuntimeError: + if isinstance(interface, basestring): + sw_if_index = InterfaceUtil.get_sw_if_index(node, interface) + else: + raise with VatTerminal(node) as vat: response = vat.vat_terminal_exec_cmd_from_template( @@ -342,21 +348,35 @@ class InterfaceUtil(object): ssh = SSH() ssh.connect(node) - 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):