From 126fe985f68aeaf65037c104326ce6b859c01f00 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Fri, 17 Mar 2017 10:41:44 -0700 Subject: [PATCH] Remove set_nic_state from old remote_client set_nic_state was just one-line command wrapper method and it was not worth to keep it as a common method. That made stacktrace deep unnecessarily. This patch removes set_nic_state for the cleanup. NOTE: This method is not used at outside of Tempest. Change-Id: Ida09a3b4098980c1644cc096453c34ef6e1c2a37 --- tempest/common/utils/linux/remote_client.py | 8 ++------ tempest/scenario/test_network_basic_ops.py | 2 +- tempest/scenario/test_network_v6.py | 3 ++- tempest/tests/common/utils/linux/test_remote_client.py | 9 --------- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py index 6dfc5795d5..52d47a59da 100644 --- a/tempest/common/utils/linux/remote_client.py +++ b/tempest/common/utils/linux/remote_client.py @@ -80,10 +80,10 @@ class RemoteClient(remote_client.RemoteClient): return self.exec_command(cmd) def set_mac_address(self, nic, address): - self.set_nic_state(nic=nic, state="down") + self.exec_command("sudo ip link set %s down" % nic) cmd = "sudo ip link set dev {0} address {1}".format(nic, address) self.exec_command(cmd) - self.set_nic_state(nic=nic, state="up") + self.exec_command("sudo ip link set %s up" % nic) def get_mac_address(self, nic=""): show_nic = "show {nic} ".format(nic=nic) if nic else "" @@ -105,10 +105,6 @@ class RemoteClient(remote_client.RemoteClient): ip=addr, mask=network_mask_bits, nic=nic) return self.exec_command(cmd) - def set_nic_state(self, nic, state="up"): - cmd = "sudo ip link set {nic} {state}".format(nic=nic, state=state) - return self.exec_command(cmd) - def get_dns_servers(self): cmd = 'cat /etc/resolv.conf' resolve_file = self.exec_command(cmd).strip().split('\n') diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py index 15a0a70aea..e3b27d08d7 100644 --- a/tempest/scenario/test_network_basic_ops.py +++ b/tempest/scenario/test_network_basic_ops.py @@ -289,7 +289,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest): ssh_client.assign_static_ip( nic=new_nic, addr=new_port['fixed_ips'][0]['ip_address'], network_mask_bits=CONF.network.project_network_mask_bits) - ssh_client.set_nic_state(nic=new_nic) + ssh_client.exec_command("sudo ip link set %s up" % new_nic) def _get_server_nics(self, ssh_client): reg = re.compile(r'(?P\d+): (?P\w+):') diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py index cfd83d0bb3..4e8b004cab 100644 --- a/tempest/scenario/test_network_v6.py +++ b/tempest/scenario/test_network_v6.py @@ -153,7 +153,8 @@ class TestGettingAddress(manager.NetworkScenarioTest): "ports: %s") % (network_id, ports)) mac6 = ports[0] - ssh.set_nic_state(ssh.get_nic_name_by_mac(mac6)) + nic = ssh.get_nic_name_by_mac(mac6) + ssh.exec_command("sudo ip link set %s up" % nic) def _prepare_and_test(self, address6_mode, n_subnets6=1, dualnet=False): net_list = self.prepare_network(address6_mode=address6_mode, diff --git a/tempest/tests/common/utils/linux/test_remote_client.py b/tempest/tests/common/utils/linux/test_remote_client.py index 48cb86b45f..7af719c1f5 100644 --- a/tempest/tests/common/utils/linux/test_remote_client.py +++ b/tempest/tests/common/utils/linux/test_remote_client.py @@ -147,15 +147,6 @@ a0:b0:c0:d0:e0:f0""" self._assert_exec_called_with( "sudo ip addr add %s/%s dev %s" % (ip, '28', nic)) - def test_set_nic_state(self): - nic = 'eth0' - self.conn.set_nic_state(nic) - self._assert_exec_called_with( - 'sudo ip link set %s up' % nic) - self.conn.set_nic_state(nic, "down") - self._assert_exec_called_with( - 'sudo ip link set %s down' % nic) - class TestRemoteClientWithServer(base.TestCase):