Merge ~smoser/cloud-init:feature/curtin-centos2 into cloud-init:master

Proposed by Scott Moser on 2017-07-19
Status: Merged
Merged at revision: 97abd83513bee191b58f095f4d683b18acce0b49
Proposed branch: ~smoser/cloud-init:feature/curtin-centos2
Merge into: cloud-init:master
Diff against target: 101 lines (+15/-14)
3 files modified
cloudinit/net/sysconfig.py (+9/-11)
tests/unittests/test_distros/test_netconfig.py (+4/-2)
tests/unittests/test_net.py (+2/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2017-07-19
Ryan Harper 2017-07-19 Approve on 2017-07-19
Review via email: mp+327739@code.launchpad.net

Commit Message

sysconfig: ipv6 and default gateway fixes.

With this change, entries in IPV6ADDR and IPV6ADDR_SECONDARIES will now
always be in format addr/prefix. When a subnet has a gateway will be
written. If the gateway is ipv6, use the key IPV6_DEFAULTGW rather than
GATEWAY.

LP: #1704872

To post a comment you must log in.
Scott Moser (smoser) wrote :

this is from Ryan's commit
  Use prefix for ipv6 and set v4 and v6 gateway keys, use DEFROUTE

https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/327648

Ryan Harper (raharper) :
review: Approve

PASSED: Continuous integration, rev:bed2414f4ac7226e8135d92de946ad57a8c99ab2
https://jenkins.ubuntu.com/server/job/cloud-init-ci/57/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/57/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
2index ad8c268..de6601a 100644
3--- a/cloudinit/net/sysconfig.py
4+++ b/cloudinit/net/sysconfig.py
5@@ -10,7 +10,8 @@ from cloudinit.distros.parsers import resolv_conf
6 from cloudinit import util
7
8 from . import renderer
9-from .network_state import subnet_is_ipv6, net_prefix_to_ipv4_mask
10+from .network_state import (
11+ is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6)
12
13
14 def _make_header(sep='#'):
15@@ -308,20 +309,13 @@ class Renderer(renderer.Renderer):
16 elif subnet_type == 'static':
17 if subnet_is_ipv6(subnet):
18 ipv6_index = ipv6_index + 1
19- if 'netmask' in subnet and str(subnet['netmask']) != "":
20- ipv6_cidr = (subnet['address'] +
21- '/' +
22- str(subnet['netmask']))
23- else:
24- ipv6_cidr = subnet['address']
25+ ipv6_cidr = "%s/%s" % (subnet['address'], subnet['prefix'])
26 if ipv6_index == 0:
27 iface_cfg['IPV6ADDR'] = ipv6_cidr
28 elif ipv6_index == 1:
29 iface_cfg['IPV6ADDR_SECONDARIES'] = ipv6_cidr
30 else:
31- iface_cfg['IPV6ADDR_SECONDARIES'] = (
32- iface_cfg['IPV6ADDR_SECONDARIES'] +
33- " " + ipv6_cidr)
34+ iface_cfg['IPV6ADDR_SECONDARIES'] += " " + ipv6_cidr
35 else:
36 ipv4_index = ipv4_index + 1
37 suff = "" if ipv4_index == 0 else str(ipv4_index)
38@@ -330,7 +324,11 @@ class Renderer(renderer.Renderer):
39 net_prefix_to_ipv4_mask(subnet['prefix'])
40
41 if 'gateway' in subnet:
42- iface_cfg['GATEWAY'] = subnet['gateway']
43+ iface_cfg['DEFROUTE'] = True
44+ if is_ipv6_addr(subnet['gateway']):
45+ iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
46+ else:
47+ iface_cfg['GATEWAY'] = subnet['gateway']
48
49 @classmethod
50 def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
51diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
52index dffe178..2f505d9 100644
53--- a/tests/unittests/test_distros/test_netconfig.py
54+++ b/tests/unittests/test_distros/test_netconfig.py
55@@ -476,10 +476,11 @@ NETWORKING=yes
56 # Created by cloud-init on instance boot automatically, do not edit.
57 #
58 BOOTPROTO=none
59+DEFROUTE=yes
60 DEVICE=eth0
61+GATEWAY=192.168.1.254
62 IPADDR=192.168.1.5
63 NETMASK=255.255.255.0
64-GATEWAY=192.168.1.254
65 NM_CONTROLLED=no
66 ONBOOT=yes
67 TYPE=Ethernet
68@@ -626,10 +627,11 @@ IPV6_AUTOCONF=no
69 # Created by cloud-init on instance boot automatically, do not edit.
70 #
71 BOOTPROTO=none
72+DEFROUTE=yes
73 DEVICE=eth0
74 IPV6ADDR=2607:f0d0:1002:0011::2/64
75-GATEWAY=2607:f0d0:1002:0011::1
76 IPV6INIT=yes
77+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
78 NM_CONTROLLED=no
79 ONBOOT=yes
80 TYPE=Ethernet
81diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
82index 76721ba..2224271 100644
83--- a/tests/unittests/test_net.py
84+++ b/tests/unittests/test_net.py
85@@ -298,7 +298,7 @@ DEVICE=eth0
86 GATEWAY=172.19.3.254
87 HWADDR=fa:16:3e:ed:9a:59
88 IPADDR=172.19.1.34
89-IPV6ADDR=2001:DB8::10
90+IPV6ADDR=2001:DB8::10/64
91 IPV6ADDR_SECONDARIES="2001:DB9::10/64 2001:DB10::10/64"
92 IPV6INIT=yes
93 IPV6_DEFAULTGW=2001:DB8::1
94@@ -1161,6 +1161,7 @@ USERCTL=no
95 # Created by cloud-init on instance boot automatically, do not edit.
96 #
97 BOOTPROTO=none
98+DEFROUTE=yes
99 DEVICE=interface0
100 GATEWAY=10.0.2.2
101 HWADDR=52:54:00:12:34:00

Subscribers

People subscribed via source and target branches

to all changes: