Merge lp:~mpontillo/curtin/fix-improper-inet6-bug-1588547 into lp:~curtin-dev/curtin/trunk

Proposed by Mike Pontillo
Status: Merged
Merged at revision: 390
Proposed branch: lp:~mpontillo/curtin/fix-improper-inet6-bug-1588547
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 70 lines (+47/-2)
2 files modified
curtin/net/__init__.py (+6/-2)
tests/unittests/test_net.py (+41/-0)
To merge this branch: bzr merge lp:~mpontillo/curtin/fix-improper-inet6-bug-1588547
Reviewer Review Type Date Requested Status
Ryan Harper (community) Approve
Review via email: mp+296380@code.launchpad.net

Commit message

Don't append the '6' to IPv4 aliases if an IPv6 alias preceded it.

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Comment inline.

review: Needs Fixing
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Thanks; I'll update this.

I guess there isn't an existing test case for this to change, like for the bond test case?

392. By Mike Pontillo

Address review comment.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

I've made your suggested change. I think this is ready for another look.

Revision history for this message
Ryan Harper (raharper) wrote :

> Thanks; I'll update this.
>
> I guess there isn't an existing test case for this to change, like for the
> bond test case?

No, mainly because I need to fix up the vmtest ifconfig_a output parser to handle what ipv6 looks like. I have a separate ivp6 related branch and I'll bring an aliased interface with ipv4 into it.

Revision history for this message
Ryan Harper (raharper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/net/__init__.py'
2--- curtin/net/__init__.py 2016-04-20 20:03:00 +0000
3+++ curtin/net/__init__.py 2016-06-03 20:00:33 +0000
4@@ -423,10 +423,14 @@
5 iface['index'] = index
6 iface['mode'] = subnet['type']
7 iface['control'] = subnet.get('control', 'auto')
8+ subnet_inet = 'inet'
9 if iface['mode'].endswith('6'):
10- iface['inet'] += '6'
11+ # This is a request for DHCPv6.
12+ subnet_inet += '6'
13 elif iface['mode'] == 'static' and ":" in subnet['address']:
14- iface['inet'] += '6'
15+ # This is a static IPv6 address.
16+ subnet_inet += '6'
17+ iface['inet'] = subnet_inet
18 if iface['mode'].startswith('dhcp'):
19 iface['mode'] = 'dhcp'
20
21
22=== modified file 'tests/unittests/test_net.py'
23--- tests/unittests/test_net.py 2016-05-17 20:04:00 +0000
24+++ tests/unittests/test_net.py 2016-06-03 20:00:33 +0000
25@@ -566,4 +566,45 @@
26 self.assertEqual(sorted(ifaces.split('\n')),
27 sorted(net_ifaces.split('\n')))
28
29+ def test_render_interfaces_ipv6_aliases(self):
30+ ipv6_aliases_config = '''
31+# YAML example of a simple network config
32+network:
33+ version: 1
34+ config:
35+ # Physical interfaces.
36+ - type: physical
37+ name: eth0
38+ mac_address: "c0:d6:9f:2c:e8:80"
39+ subnets:
40+ - type: static
41+ address: fde9:8f83:4a81:1:0:1:0:6/64
42+ - type: static
43+ address: 192.168.0.1/24
44+'''
45+
46+ ns = self.get_net_state(ipv6_aliases_config)
47+ ifaces = dedent("""\
48+ auto lo
49+ iface lo inet loopback
50+
51+ auto eth0
52+ iface eth0 inet6 static
53+ address fde9:8f83:4a81:1:0:1:0:6/64
54+
55+ auto eth0:1
56+ iface eth0:1 inet static
57+ address 192.168.0.1/24
58+
59+ source /etc/network/interfaces.d/*.cfg
60+ """)
61+ net_ifaces = net.render_interfaces(ns.network_state)
62+ print("\n".join(sorted(ifaces.split('\n'))))
63+ print("\n^^ LOCAL -- RENDER vv")
64+ print("\n".join(sorted(net_ifaces.split('\n'))))
65+ print(ns.network_state.get('interfaces'))
66+ self.assertEqual(sorted(ifaces.split('\n')),
67+ sorted(net_ifaces.split('\n')))
68+
69+
70 # vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches