Remove set_mac_address from old remote_client
set_mac_address() was called from test_network_basic_ops only and it is not necessary to keep it as common method in Tempest. Then this patch moves the implementation into test_network_basic_ops and removes set_mac_address() from old remote_client. In addition, this patch merges 3 exec_command() calls into a single call for avoiding ssh re-connections. Change-Id: I60b86a143e3987b911fa070754879bd002128120
This commit is contained in:
parent
679f8c30cc
commit
5129c62bc6
|
@ -79,12 +79,6 @@ class RemoteClient(remote_client.RemoteClient):
|
|||
cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % message
|
||||
return self.exec_command(cmd)
|
||||
|
||||
def set_mac_address(self, nic, address):
|
||||
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.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 ""
|
||||
cmd = "ip addr %s| awk '/ether/ {print $2}'" % show_nic
|
||||
|
|
|
@ -834,7 +834,13 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||
peer_address = peer['addresses'][self.new_net['name']][0]['addr']
|
||||
self.check_remote_connectivity(ssh_client, dest=peer_address,
|
||||
nic=spoof_nic, should_succeed=True)
|
||||
ssh_client.set_mac_address(spoof_nic, spoof_mac)
|
||||
# Set a mac address by making nic down temporary
|
||||
cmd = ("sudo ip link set {nic} down;"
|
||||
"sudo ip link set dev {nic} address {mac};"
|
||||
"sudo ip link set {nic} up").format(nic=spoof_nic,
|
||||
mac=spoof_mac)
|
||||
ssh_client.exec_command(cmd)
|
||||
|
||||
new_mac = ssh_client.get_mac_address(nic=spoof_nic)
|
||||
self.assertEqual(spoof_mac, new_mac)
|
||||
self.check_remote_connectivity(ssh_client, dest=peer_address,
|
||||
|
|
Loading…
Reference in New Issue