diff --git a/io/net/infiniband/ib_pingpong.py b/io/net/infiniband/ib_pingpong.py index 174305229..758a82b19 100755 --- a/io/net/infiniband/ib_pingpong.py +++ b/io/net/infiniband/ib_pingpong.py @@ -44,16 +44,24 @@ def setUp(self): ''' To check and install dependencies for the test ''' + local = LocalHost() interfaces = netifaces.interfaces() + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.flag = self.params.get("ext_flag", default="0") - self.iface = self.params.get("interface", default="") self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -86,7 +94,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) smm = SoftwareManager() @@ -194,8 +203,9 @@ def test_ib_pingpong(self): self.log.info("Extended test option skipped") def tearDown(self): - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") - self.remotehost.remote_session.quit() + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer") + self.remotehost.remote_session.quit() diff --git a/io/net/infiniband/mckey.py b/io/net/infiniband/mckey.py index 38ea80c03..90ba3abed 100755 --- a/io/net/infiniband/mckey.py +++ b/io/net/infiniband/mckey.py @@ -63,15 +63,24 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Not able to install %s" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() - self.iface = self.params.get("interface", default="") + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -100,7 +109,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) self.option = self.option.replace("PEERIP", self.peer_ip) @@ -169,8 +179,9 @@ def tearDown(self): """ unset ip """ - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") - self.remotehost.remote_session.quit() + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer") + self.remotehost.remote_session.quit() diff --git a/io/net/infiniband/ping6.py b/io/net/infiniband/ping6.py index 8930c2bdd..851b34c6e 100755 --- a/io/net/infiniband/ping6.py +++ b/io/net/infiniband/ping6.py @@ -63,8 +63,18 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Not able to install %s" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() - self.iface = self.params.get("interface", default="") + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.peer_iface = self.params.get("peer_interface", default="") self.ipv6_peer = self.params.get("peer_ipv6", default="") self.peer_ip = self.params.get("peer_ip", default="") @@ -73,7 +83,6 @@ def setUp(self): default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -113,7 +122,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) diff --git a/io/net/infiniband/rdma_tests.py b/io/net/infiniband/rdma_tests.py index 4af5bf29e..e2be8ee1b 100755 --- a/io/net/infiniband/rdma_tests.py +++ b/io/net/infiniband/rdma_tests.py @@ -52,15 +52,24 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("%s package is need to test" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() - self.iface = self.params.get("interface", default="") + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -96,7 +105,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) @@ -164,8 +174,9 @@ def tearDown(self): """ unset ip """ - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") - self.remotehost.remote_session.quit() + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer") + self.remotehost.remote_session.quit() diff --git a/io/net/infiniband/rping.py b/io/net/infiniband/rping.py index 3675f2486..838a89029 100755 --- a/io/net/infiniband/rping.py +++ b/io/net/infiniband/rping.py @@ -63,8 +63,18 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Not able to install %s" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() - self.iface = self.params.get("interface", default="") + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.peer_ip = self.params.get("peer_ip", default="") self.ipv6_peer = self.params.get("peer_ipv6", default="") if self.iface not in interfaces: @@ -73,7 +83,6 @@ def setUp(self): self.cancel("%s peer machine is not available" % self.peer_ip) self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -105,7 +114,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) @@ -166,8 +176,9 @@ def tearDown(self): """ unset ip """ - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") - self.remotehost.remote_session.quit() + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer") + self.remotehost.remote_session.quit() diff --git a/io/net/infiniband/ucmatose.py b/io/net/infiniband/ucmatose.py index cb4f6c782..b9842f11e 100755 --- a/io/net/infiniband/ucmatose.py +++ b/io/net/infiniband/ucmatose.py @@ -63,16 +63,25 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Not able to install %s" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.flag = self.params.get("ext_flag", default="0") - self.iface = self.params.get("interface", default="") self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -100,7 +109,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) @@ -160,8 +170,9 @@ def tearDown(self): """ unset ip """ - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") - self.remotehost.remote_session.quit() + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer") + self.remotehost.remote_session.quit() diff --git a/io/net/infiniband/udaddy.py b/io/net/infiniband/udaddy.py index 7f776a768..701b935b1 100755 --- a/io/net/infiniband/udaddy.py +++ b/io/net/infiniband/udaddy.py @@ -63,15 +63,24 @@ def setUp(self): for pkg in pkgs: if not smm.check_installed(pkg) and not smm.install(pkg): self.cancel("Not able to install %s" % pkg) + + local = LocalHost() interfaces = netifaces.interfaces() - self.iface = self.params.get("interface", default="") + device = self.params.get("interface", default=None) + if device in interfaces: + self.iface = device + elif local.validate_mac_addr(device) and device in local.get_all_hwaddr(): + self.iface = local.get_interface_by_hwaddr(device).name + else: + self.iface = None + self.cancel("%s interface is not available" % device) + self.peer_ip = self.params.get("peer_ip", default="") self.peer_user = self.params.get("peer_user", default="root") self.peer_password = self.params.get("peer_password", '*', default="None") self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") - local = LocalHost() if self.iface[0:2] == 'ib': self.networkinterface = NetworkInterface(self.iface, local, if_type='Infiniband') @@ -99,7 +108,8 @@ def setUp(self): self.mtu = self.params.get("mtu", default=1500) self.remotehost = RemoteHost(self.peer_ip, self.peer_user, password=self.peer_password) - self.peer_interface = self.remotehost.get_interface_by_ipaddr(self.peer_ip).name + self.peer_interface = self.remotehost.get_interface_by_ipaddr( + self.peer_ip).name self.peer_networkinterface = NetworkInterface(self.peer_interface, self.remotehost) @@ -159,7 +169,8 @@ def tearDown(self): """ unset ip """ - if self.networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in host") - if self.peer_networkinterface.set_mtu('1500') is not None: - self.fail("Failed to set mtu in peer") + if self.iface: + if self.networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in host") + if self.peer_networkinterface.set_mtu('1500') is not None: + self.fail("Failed to set mtu in peer")