diff options
author | 2015-08-17 19:36:16 +0000 | |
---|---|---|
committer | 2015-08-17 17:47:09 -0400 | |
commit | 0b130b6b3b4a9e0768e99b1496d2852f2ca47bb7 (patch) | |
tree | 73ec771493d5a229457e7747607aa9b777cda1cc /os_net_config/tests/test_impl_ifcfg.py | |
parent | 103b87aa82cfd298b664fe1314e987bd953ec20d (diff) |
Support multiple addresses assignment with ifcfg
Currently only the first IPv4/v6 address is assigned to a NIC
even if multiple addresses are specified in config file.
With this change, ifcfg implementation can configure multiple
IPv4/v6 addresses for a NIC.
Also this enables os-net-config to configure IPv6 netmasks.
Change-Id: I31b39abae36e0620dbbcb1001fa51f5ca2bd9ea2
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index e32aff2..73271e8 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -41,11 +41,20 @@ NETMASK=255.255.255.0 _V4_IFCFG_MAPPED = _V4_IFCFG.replace('em1', 'nic1') + "HWADDR=a1:b2:c3:d4:e5\n" +_V4_IFCFG_MULTIPLE = _V4_IFCFG + """IPADDR1=192.168.1.3 +NETMASK1=255.255.255.255 +IPADDR2=10.0.0.2 +NETMASK2=255.0.0.0 +""" + _V6_IFCFG = _BASE_IFCFG + """IPV6INIT=yes IPV6_AUTOCONF=no -IPV6ADDR=2001:abc:a:: +IPV6ADDR=2001:abc:a::/64 """ +_V6_IFCFG_MULTIPLE = (_V6_IFCFG + "IPV6ADDR_SECONDARIES=\"2001:abc:b::1/64 " + + "2001:abc:c::2/96\"\n") + _OVS_IFCFG = _BASE_IFCFG + "DEVICETYPE=ovs\nBOOTPROTO=none\n" @@ -171,6 +180,15 @@ class TestIfcfgNetConfig(base.TestCase): self.assertEqual(_V4_IFCFG, self.get_interface_config()) self.assertEqual('', self.get_route_config()) + def test_add_interface_with_v4_multiple(self): + addresses = [objects.Address('192.168.1.2/24'), + objects.Address('192.168.1.3/32'), + objects.Address('10.0.0.2/8')] + interface = objects.Interface('em1', addresses=addresses) + self.provider.add_interface(interface) + self.assertEqual(_V4_IFCFG_MULTIPLE, self.get_interface_config()) + self.assertEqual('', self.get_route_config()) + def test_add_interface_map_persisted(self): def test_interface_mac(name): macs = {'em1': 'a1:b2:c3:d4:e5'} @@ -194,6 +212,14 @@ class TestIfcfgNetConfig(base.TestCase): self.provider.add_interface(interface) self.assertEqual(_V6_IFCFG, self.get_interface_config()) + def test_add_interface_with_v6_multiple(self): + addresses = [objects.Address('2001:abc:a::/64'), + objects.Address('2001:abc:b::1/64'), + objects.Address('2001:abc:c::2/96')] + interface = objects.Interface('em1', addresses=addresses) + self.provider.add_interface(interface) + self.assertEqual(_V6_IFCFG_MULTIPLE, self.get_interface_config()) + def test_network_with_routes(self): route1 = objects.Route('192.168.1.1', default=True) route2 = objects.Route('192.168.1.1', '172.19.0.0/24') |