diff options
-rw-r--r-- | cloudinit/net/eni.py | 11 | ||||
-rw-r--r-- | tests/unittests/test_net.py | 10 |
2 files changed, 18 insertions, 3 deletions
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py index bb48a6eb..2da13ffd 100644 --- a/cloudinit/net/eni.py +++ b/cloudinit/net/eni.py @@ -369,11 +369,20 @@ class Renderer(renderer.Renderer): if iface['mode'].startswith('dhcp'): iface['mode'] = 'dhcp' - sections.append( + lines = list( _iface_start_entry(iface, index) + _iface_add_subnet(iface, subnet) + _iface_add_attrs(iface) ) + for route in subnet.get('routes', []): + lines.extend(self._render_route(route, indent=" ")) + + if len(subnets) > 1 and index == 0: + tmpl = " post-up ifup %s:%s\n" + for i in range(1, len(subnets)): + lines.append(tmpl % (iface['name'], i)) + + sections.append(lines) else: # ifenslave docs say to auto the slave devices lines = [] diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index ecd21b2b..d50ac440 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -168,7 +168,7 @@ version: 1 config: # Physical interfaces. - type: physical - name: eth0 + name: eth99 mac_address: "c0:d6:9f:2c:e8:80" subnets: - type: dhcp4 @@ -178,6 +178,11 @@ config: - 8.8.8.8 - 8.8.4.4 dns_search: barley.maas sach.maas + routes: + - gateway: 65.61.151.37 + netmask: 0.0.0.0 + network: 0.0.0.0 + metric: 2 - type: physical name: eth1 mac_address: "cf:d6:af:48:e8:80" @@ -188,6 +193,7 @@ config: search: - wark.maas """ + NETWORK_YAML_ALL = """ version: 1 config: @@ -520,7 +526,7 @@ class TestEniRoundTrip(TestCase): network_config=yaml.load(NETWORK_YAML_ALL)) raise Exception("FOO2") - def skiptestsimple_render_small(self): + def testsimple_render_small(self): files = self._render_and_read( network_config=yaml.load(NETWORK_YAML_SMALL)) raise Exception("FOO3") |