Merge ~smoser/cloud-init:bug/1649652-curtin-routes-rendered into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: 9411d800b703a0c7d4e10138039ecaa765c91661
Proposed branch: ~smoser/cloud-init:bug/1649652-curtin-routes-rendered
Merge into: cloud-init:master
Diff against target: 57 lines (+46/-0)
1 file modified
tests/unittests/test_net.py (+46/-0)
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+313475@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) :
Revision history for this message
Scott Moser (smoser) wrote :

Mike,
Yeah, thats true.
The fix here does verify that the content is better than it was in that bug report though.

We need full round trip rendering and reading to do the whole thing the right way.

That said, the network config that was provided in the bug, and I think correctly simplified here, has static routes that are not attached to an interface. There is no specific link between the
'route' type and the subnet that it should be off of.

we could arguably work backwards and find the right subnet to hang the static route off of, but at the moment we dont do that. Additionally, there could well be two devices with an 'address' that would contain the route's 'gateway'.

Again, I agree that this test is minimalistic.
You have thoughts on what the route info should look like?

(we should probably move this discussion at least to the bug).

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
2index 789c78b..81b43a8 100755
3--- a/tests/unittests/test_net.py
4+++ b/tests/unittests/test_net.py
5@@ -769,6 +769,52 @@ class TestEniRoundTrip(TestCase):
6 entry['expected_eni'].splitlines(),
7 files['/etc/network/interfaces'].splitlines())
8
9+ def test_routes_rendered(self):
10+ # as reported in bug 1649652
11+ conf = [
12+ {'name': 'eth0', 'type': 'physical',
13+ 'subnets': [{
14+ 'address': '172.23.31.42/26',
15+ 'dns_nameservers': [], 'gateway': '172.23.31.2',
16+ 'type': 'static'}]},
17+ {'type': 'route', 'id': 4,
18+ 'metric': 0, 'destination': '10.0.0.0/12',
19+ 'gateway': '172.23.31.1'},
20+ {'type': 'route', 'id': 5,
21+ 'metric': 0, 'destination': '192.168.2.0/16',
22+ 'gateway': '172.23.31.1'},
23+ {'type': 'route', 'id': 6,
24+ 'metric': 1, 'destination': '10.0.200.0/16',
25+ 'gateway': '172.23.31.1'},
26+ ]
27+
28+ files = self._render_and_read(
29+ network_config={'config': conf, 'version': 1})
30+ expected = [
31+ 'auto lo',
32+ 'iface lo inet loopback',
33+ 'auto eth0',
34+ 'iface eth0 inet static',
35+ ' address 172.23.31.42/26',
36+ ' gateway 172.23.31.2',
37+ ('post-up route add -net 10.0.0.0 netmask 255.240.0.0 gw '
38+ '172.23.31.1 metric 0 || true'),
39+ ('pre-down route del -net 10.0.0.0 netmask 255.240.0.0 gw '
40+ '172.23.31.1 metric 0 || true'),
41+ ('post-up route add -net 192.168.2.0 netmask 255.255.0.0 gw '
42+ '172.23.31.1 metric 0 || true'),
43+ ('pre-down route del -net 192.168.2.0 netmask 255.255.0.0 gw '
44+ '172.23.31.1 metric 0 || true'),
45+ ('post-up route add -net 10.0.200.0 netmask 255.255.0.0 gw '
46+ '172.23.31.1 metric 1 || true'),
47+ ('pre-down route del -net 10.0.200.0 netmask 255.255.0.0 gw '
48+ '172.23.31.1 metric 1 || true'),
49+ ]
50+ found = files['/etc/network/interfaces'].splitlines()
51+
52+ self.assertEqual(
53+ expected, [line for line in found if line])
54+
55
56 def _gzip_data(data):
57 with io.BytesIO() as iobuf:

Subscribers

People subscribed via source and target branches