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.

Update scan failed

At least one of the branches involved have failed to scan. You can manually schedule a rescan if required.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 789c78b..81b43a8 100755
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -769,6 +769,52 @@ class TestEniRoundTrip(TestCase):
769 entry['expected_eni'].splitlines(),769 entry['expected_eni'].splitlines(),
770 files['/etc/network/interfaces'].splitlines())770 files['/etc/network/interfaces'].splitlines())
771771
772 def test_routes_rendered(self):
773 # as reported in bug 1649652
774 conf = [
775 {'name': 'eth0', 'type': 'physical',
776 'subnets': [{
777 'address': '172.23.31.42/26',
778 'dns_nameservers': [], 'gateway': '172.23.31.2',
779 'type': 'static'}]},
780 {'type': 'route', 'id': 4,
781 'metric': 0, 'destination': '10.0.0.0/12',
782 'gateway': '172.23.31.1'},
783 {'type': 'route', 'id': 5,
784 'metric': 0, 'destination': '192.168.2.0/16',
785 'gateway': '172.23.31.1'},
786 {'type': 'route', 'id': 6,
787 'metric': 1, 'destination': '10.0.200.0/16',
788 'gateway': '172.23.31.1'},
789 ]
790
791 files = self._render_and_read(
792 network_config={'config': conf, 'version': 1})
793 expected = [
794 'auto lo',
795 'iface lo inet loopback',
796 'auto eth0',
797 'iface eth0 inet static',
798 ' address 172.23.31.42/26',
799 ' gateway 172.23.31.2',
800 ('post-up route add -net 10.0.0.0 netmask 255.240.0.0 gw '
801 '172.23.31.1 metric 0 || true'),
802 ('pre-down route del -net 10.0.0.0 netmask 255.240.0.0 gw '
803 '172.23.31.1 metric 0 || true'),
804 ('post-up route add -net 192.168.2.0 netmask 255.255.0.0 gw '
805 '172.23.31.1 metric 0 || true'),
806 ('pre-down route del -net 192.168.2.0 netmask 255.255.0.0 gw '
807 '172.23.31.1 metric 0 || true'),
808 ('post-up route add -net 10.0.200.0 netmask 255.255.0.0 gw '
809 '172.23.31.1 metric 1 || true'),
810 ('pre-down route del -net 10.0.200.0 netmask 255.255.0.0 gw '
811 '172.23.31.1 metric 1 || true'),
812 ]
813 found = files['/etc/network/interfaces'].splitlines()
814
815 self.assertEqual(
816 expected, [line for line in found if line])
817
772818
773def _gzip_data(data):819def _gzip_data(data):
774 with io.BytesIO() as iobuf:820 with io.BytesIO() as iobuf:

Subscribers

People subscribed via source and target branches