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

Proposed by Scott Moser on 2017-07-20
Status: Merged
Merged at revision: 8317bcab7cd08f1dcd96095c0cb746b57cb27234
Proposed branch: ~smoser/cloud-init:feature/curtin-centos6
Merge into: cloud-init:master
Diff against target: 85 lines (+49/-0)
2 files modified
cloudinit/net/sysconfig.py (+3/-0)
tests/unittests/test_net.py (+46/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2017-07-20
Ryan Harper 2017-07-20 Approve on 2017-07-20
Review via email: mp+327832@code.launchpad.net

Commit Message

sysconfig: handle manual type subnets

Implement manual control for sysconfig by using ONBOOT=N. This
allows an interface to be configured but not brought up.

Note that ONBOOT is per-interface not per address.

LP: #1687725

To post a comment you must log in.

PASSED: Continuous integration, rev:0b3d738c6230209a1cd2e1b84aaa18f657e0e7aa
https://jenkins.ubuntu.com/server/job/cloud-init-ci/67/
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/67/rebuild

review: Approve (continuous-integration)
Ryan Harper (raharper) :
review: Approve

PASSED: Continuous integration, rev:8317bcab7cd08f1dcd96095c0cb746b57cb27234
https://jenkins.ubuntu.com/server/job/cloud-init-ci/68/
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/68/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 abdd4de..b0f2ccf 100644
3--- a/cloudinit/net/sysconfig.py
4+++ b/cloudinit/net/sysconfig.py
5@@ -298,6 +298,9 @@ class Renderer(renderer.Renderer):
6 " for interface '%s'" % (subnet_type,
7 iface_cfg.name))
8
9+ if subnet.get('control') == 'manual':
10+ iface_cfg['ONBOOT'] = False
11+
12 # set IPv4 and IPv6 static addresses
13 ipv4_index = -1
14 ipv6_index = -1
15diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
16index c012600..e625934 100644
17--- a/tests/unittests/test_net.py
18+++ b/tests/unittests/test_net.py
19@@ -1031,6 +1031,39 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
20 """),
21 },
22 },
23+ 'manual': {
24+ 'yaml': textwrap.dedent("""
25+ version: 1
26+ config:
27+ - type: physical
28+ name: eth0
29+ mac_address: "52:54:00:12:34:00"
30+ subnets:
31+ - type: static
32+ address: 192.168.1.2/24
33+ control: manual"""),
34+ 'expected_eni': textwrap.dedent("""\
35+ auto lo
36+ iface lo inet loopback
37+
38+ # control-manual eth0
39+ iface eth0 inet static
40+ address 192.168.1.2/24
41+ """),
42+ 'expected_sysconfig': {
43+ 'ifcfg-eth0': textwrap.dedent("""\
44+ BOOTPROTO=none
45+ DEVICE=eth0
46+ HWADDR=52:54:00:12:34:00
47+ IPADDR=192.168.1.2
48+ NETMASK=255.255.255.0
49+ NM_CONTROLLED=no
50+ ONBOOT=no
51+ TYPE=Ethernet
52+ USERCTL=no
53+ """),
54+ },
55+ },
56 }
57
58
59@@ -1460,6 +1493,12 @@ USERCTL=no
60 self._compare_files_to_expected(entry['expected_sysconfig'], found)
61 self._assert_headers(found)
62
63+ def test_manual_config(self):
64+ entry = NETWORK_CONFIGS['manual']
65+ found = self._render_and_read(network_config=yaml.load(entry['yaml']))
66+ self._compare_files_to_expected(entry['expected_sysconfig'], found)
67+ self._assert_headers(found)
68+
69
70 class TestEniNetRendering(CiTestCase):
71
72@@ -1911,6 +1950,13 @@ class TestEniRoundTrip(CiTestCase):
73 entry['expected_eni'].splitlines(),
74 files['/etc/network/interfaces'].splitlines())
75
76+ def testsimple_render_manual(self):
77+ entry = NETWORK_CONFIGS['manual']
78+ files = self._render_and_read(network_config=yaml.load(entry['yaml']))
79+ self.assertEqual(
80+ entry['expected_eni'].splitlines(),
81+ files['/etc/network/interfaces'].splitlines())
82+
83 def test_routes_rendered(self):
84 # as reported in bug 1649652
85 conf = [

Subscribers

People subscribed via source and target branches

to all changes: