Remove get_ip_list()
get_ip_list() just calls exec_command("ip address"), there is not so much merit to keep this in common place. NOTE: This change affects congress and vmware-nsx. Change-Id: Iadddf283dc7bed502285cb2fc9e87110787d87a0
This commit is contained in:
parent
645b0b1f66
commit
84aeba6dae
|
@ -166,10 +166,6 @@ class RemoteClient(object):
|
||||||
nic = self.exec_command(cmd)
|
nic = self.exec_command(cmd)
|
||||||
return nic.strip().strip(":").lower()
|
return nic.strip().strip(":").lower()
|
||||||
|
|
||||||
def get_ip_list(self):
|
|
||||||
cmd = "ip address"
|
|
||||||
return self.exec_command(cmd)
|
|
||||||
|
|
||||||
def assign_static_ip(self, nic, addr, network_mask_bits=28):
|
def assign_static_ip(self, nic, addr, network_mask_bits=28):
|
||||||
cmd = "sudo ip addr add {ip}/{mask} dev {nic}".format(
|
cmd = "sudo ip addr add {ip}/{mask} dev {nic}".format(
|
||||||
ip=addr, mask=network_mask_bits, nic=nic)
|
ip=addr, mask=network_mask_bits, nic=nic)
|
||||||
|
|
|
@ -292,7 +292,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
||||||
|
|
||||||
def _get_server_nics(self, ssh_client):
|
def _get_server_nics(self, ssh_client):
|
||||||
reg = re.compile(r'(?P<num>\d+): (?P<nic_name>\w+):')
|
reg = re.compile(r'(?P<num>\d+): (?P<nic_name>\w+):')
|
||||||
ipatxt = ssh_client.get_ip_list()
|
ipatxt = ssh_client.exec_command("ip address")
|
||||||
return reg.findall(ipatxt)
|
return reg.findall(ipatxt)
|
||||||
|
|
||||||
def _check_network_internal_connectivity(self, network,
|
def _check_network_internal_connectivity(self, network,
|
||||||
|
|
|
@ -164,7 +164,7 @@ class TestGettingAddress(manager.NetworkScenarioTest):
|
||||||
sshv4_2, ips_from_api_2, sid2 = self.prepare_server(networks=net_list)
|
sshv4_2, ips_from_api_2, sid2 = self.prepare_server(networks=net_list)
|
||||||
|
|
||||||
def guest_has_address(ssh, addr):
|
def guest_has_address(ssh, addr):
|
||||||
return addr in ssh.get_ip_list()
|
return addr in ssh.exec_command("ip address")
|
||||||
|
|
||||||
# Turn on 2nd NIC for Cirros when dualnet
|
# Turn on 2nd NIC for Cirros when dualnet
|
||||||
if dualnet:
|
if dualnet:
|
||||||
|
@ -172,8 +172,8 @@ class TestGettingAddress(manager.NetworkScenarioTest):
|
||||||
self.turn_nic6_on(sshv4_2, sid2)
|
self.turn_nic6_on(sshv4_2, sid2)
|
||||||
|
|
||||||
# get addresses assigned to vNIC as reported by 'ip address' utility
|
# get addresses assigned to vNIC as reported by 'ip address' utility
|
||||||
ips_from_ip_1 = sshv4_1.get_ip_list()
|
ips_from_ip_1 = sshv4_1.exec_command("ip address")
|
||||||
ips_from_ip_2 = sshv4_2.get_ip_list()
|
ips_from_ip_2 = sshv4_2.exec_command("ip address")
|
||||||
self.assertIn(ips_from_api_1['4'], ips_from_ip_1)
|
self.assertIn(ips_from_api_1['4'], ips_from_ip_1)
|
||||||
self.assertIn(ips_from_api_2['4'], ips_from_ip_2)
|
self.assertIn(ips_from_api_2['4'], ips_from_ip_2)
|
||||||
for i in range(n_subnets6):
|
for i in range(n_subnets6):
|
||||||
|
|
|
@ -139,23 +139,6 @@ a0:b0:c0:d0:e0:f0"""
|
||||||
self._assert_exec_called_with(
|
self._assert_exec_called_with(
|
||||||
"ip addr | awk '/ether/ {print $2}'")
|
"ip addr | awk '/ether/ {print $2}'")
|
||||||
|
|
||||||
def test_get_ip_list(self):
|
|
||||||
ips = """1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
|
|
||||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
|
||||||
inet 127.0.0.1/8 scope host lo
|
|
||||||
inet6 ::1/128 scope host
|
|
||||||
valid_lft forever preferred_lft forever
|
|
||||||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
|
|
||||||
link/ether fa:16:3e:6e:26:3b brd ff:ff:ff:ff:ff:ff
|
|
||||||
inet 10.0.0.4/24 brd 10.0.0.255 scope global eth0
|
|
||||||
inet6 fd55:faaf:e1ab:3d9:f816:3eff:fe6e:263b/64 scope global dynamic
|
|
||||||
valid_lft 2591936sec preferred_lft 604736sec
|
|
||||||
inet6 fe80::f816:3eff:fe6e:263b/64 scope link
|
|
||||||
valid_lft forever preferred_lft forever"""
|
|
||||||
self.ssh_mock.mock.exec_command.return_value = ips
|
|
||||||
self.assertEqual(self.conn.get_ip_list(), ips)
|
|
||||||
self._assert_exec_called_with('ip address')
|
|
||||||
|
|
||||||
def test_assign_static_ip(self):
|
def test_assign_static_ip(self):
|
||||||
self.ssh_mock.mock.exec_command.return_value = ''
|
self.ssh_mock.mock.exec_command.return_value = ''
|
||||||
ip = '10.0.0.2'
|
ip = '10.0.0.2'
|
||||||
|
|
Loading…
Reference in New Issue