Makes sure to recreate gateway for moved ip
If nova moves an ip when setting up dhcp, make sure to reset the default gateway. Fixes bug 859587 Change-Id: I9f2b7bc5ede142717df6cb1653043b4f5c09959a
This commit is contained in:
parent
0da27977d7
commit
b1f4eb8ab2
|
@ -346,7 +346,7 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||||
actual = self.driver._host_dhcp(fixed_ips[0])
|
actual = self.driver._host_dhcp(fixed_ips[0])
|
||||||
self.assertEquals(actual, expected)
|
self.assertEquals(actual, expected)
|
||||||
|
|
||||||
def _test_initialize_gateway(self, existing, expected):
|
def _test_initialize_gateway(self, existing, expected, routes=''):
|
||||||
self.flags(fake_network=False)
|
self.flags(fake_network=False)
|
||||||
executes = []
|
executes = []
|
||||||
|
|
||||||
|
@ -354,6 +354,8 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||||
executes.append(args)
|
executes.append(args)
|
||||||
if args[0] == 'ip' and args[1] == 'addr' and args[2] == 'show':
|
if args[0] == 'ip' and args[1] == 'addr' and args[2] == 'show':
|
||||||
return existing, ""
|
return existing, ""
|
||||||
|
if args[0] == 'route' and args[1] == '-n':
|
||||||
|
return routes, ""
|
||||||
self.stubs.Set(utils, 'execute', fake_execute)
|
self.stubs.Set(utils, 'execute', fake_execute)
|
||||||
network = {'dhcp_server': '192.168.1.1',
|
network = {'dhcp_server': '192.168.1.1',
|
||||||
'cidr': '192.168.1.0/24',
|
'cidr': '192.168.1.0/24',
|
||||||
|
@ -371,6 +373,7 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||||
" valid_lft forever preferred_lft forever\n")
|
" valid_lft forever preferred_lft forever\n")
|
||||||
expected = [
|
expected = [
|
||||||
('ip', 'addr', 'show', 'dev', 'eth0', 'scope', 'global'),
|
('ip', 'addr', 'show', 'dev', 'eth0', 'scope', 'global'),
|
||||||
|
('route', '-n'),
|
||||||
('ip', 'addr', 'del', '192.168.0.1/24',
|
('ip', 'addr', 'del', '192.168.0.1/24',
|
||||||
'brd', '192.168.0.255', 'scope', 'global', 'dev', 'eth0'),
|
'brd', '192.168.0.255', 'scope', 'global', 'dev', 'eth0'),
|
||||||
('ip', 'addr', 'add', '192.168.1.1/24',
|
('ip', 'addr', 'add', '192.168.1.1/24',
|
||||||
|
@ -383,6 +386,32 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||||
]
|
]
|
||||||
self._test_initialize_gateway(existing, expected)
|
self._test_initialize_gateway(existing, expected)
|
||||||
|
|
||||||
|
def test_initialize_gateway_resets_route(self):
|
||||||
|
routes = "0.0.0.0 192.68.0.1 0.0.0.0 " \
|
||||||
|
"UG 100 0 0 eth0"
|
||||||
|
existing = ("2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> "
|
||||||
|
" mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000\n"
|
||||||
|
" link/ether de:ad:be:ef:be:ef brd ff:ff:ff:ff:ff:ff\n"
|
||||||
|
" inet 192.168.0.1/24 brd 192.168.0.255 scope global eth0\n"
|
||||||
|
" inet6 dead::beef:dead:beef:dead/64 scope link\n"
|
||||||
|
" valid_lft forever preferred_lft forever\n")
|
||||||
|
expected = [
|
||||||
|
('ip', 'addr', 'show', 'dev', 'eth0', 'scope', 'global'),
|
||||||
|
('route', '-n'),
|
||||||
|
('route', 'del', 'default', 'gw', '192.68.0.1', 'dev', 'eth0'),
|
||||||
|
('ip', 'addr', 'del', '192.168.0.1/24',
|
||||||
|
'brd', '192.168.0.255', 'scope', 'global', 'dev', 'eth0'),
|
||||||
|
('ip', 'addr', 'add', '192.168.1.1/24',
|
||||||
|
'brd', '192.168.1.255', 'dev', 'eth0'),
|
||||||
|
('ip', 'addr', 'add', '192.168.0.1/24',
|
||||||
|
'brd', '192.168.0.255', 'scope', 'global', 'dev', 'eth0'),
|
||||||
|
('route', 'add', 'default', 'gw', '192.68.0.1'),
|
||||||
|
('ip', '-f', 'inet6', 'addr', 'change',
|
||||||
|
'2001:db8::/64', 'dev', 'eth0'),
|
||||||
|
('ip', 'link', 'set', 'dev', 'eth0', 'promisc', 'on'),
|
||||||
|
]
|
||||||
|
self._test_initialize_gateway(existing, expected, routes)
|
||||||
|
|
||||||
def test_initialize_gateway_no_move_right_ip(self):
|
def test_initialize_gateway_no_move_right_ip(self):
|
||||||
existing = ("2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> "
|
existing = ("2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> "
|
||||||
" mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000\n"
|
" mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000\n"
|
||||||
|
@ -407,6 +436,7 @@ class LinuxNetworkTestCase(test.TestCase):
|
||||||
" valid_lft forever preferred_lft forever\n")
|
" valid_lft forever preferred_lft forever\n")
|
||||||
expected = [
|
expected = [
|
||||||
('ip', 'addr', 'show', 'dev', 'eth0', 'scope', 'global'),
|
('ip', 'addr', 'show', 'dev', 'eth0', 'scope', 'global'),
|
||||||
|
('route', '-n'),
|
||||||
('ip', 'addr', 'add', '192.168.1.1/24',
|
('ip', 'addr', 'add', '192.168.1.1/24',
|
||||||
'brd', '192.168.1.255', 'dev', 'eth0'),
|
'brd', '192.168.1.255', 'dev', 'eth0'),
|
||||||
('ip', '-f', 'inet6', 'addr', 'change',
|
('ip', '-f', 'inet6', 'addr', 'change',
|
||||||
|
|
Loading…
Reference in New Issue