Ubuntu Pastebin

Paste from smoser at Fri, 3 Jun 2016 18:44:02 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
=== modified file 'cloudinit/net/__init__.py'
--- cloudinit/net/__init__.py	2016-06-03 18:23:34 +0000
+++ cloudinit/net/__init__.py	2016-06-03 18:43:43 +0000
@@ -574,6 +574,8 @@
                 content += iface_start_entry(iface, index)
                 content += iface_add_subnet(iface, subnet)
                 content += iface_add_attrs(iface)
+                for route in subnet.get('routes', []):
+                    content += render_route(route)
         else:
             # ifenslave docs say to auto the slave devices
             if 'bond-master' in iface:

=== modified file 'tests/unittests/test_datasource/test_configdrive.py'
--- tests/unittests/test_datasource/test_configdrive.py	2016-06-03 03:03:38 +0000
+++ tests/unittests/test_datasource/test_configdrive.py	2016-06-03 18:40:36 +0000
@@ -88,9 +88,33 @@
     ]
 }
 
+NETWORK_DATA_2 = {
+    "services": [
+        {"type": "dns", "address": "1.1.1.191"},
+        {"type": "dns", "address": "1.1.1.4"}],
+    "networks": [
+        {"network_id": "d94bbe94-7abc-48d4-9c82-4628ea26164a", "type": "ipv4",
+         "netmask": "255.255.255.248", "link": "eth0",
+         "routes": [{"netmask": "0.0.0.0", "network": "0.0.0.0",
+                     "gateway": "2.2.2.9"}],
+         "ip_address": "2.2.2.10", "id": "network0-ipv4"},
+        {"network_id": "ca447c83-6409-499b-aaef-6ad1ae995348", "type": "ipv4",
+         "netmask": "255.255.255.224", "link": "eth1",
+         "routes": [], "ip_address": "3.3.3.24", "id": "network1-ipv4"}],
+    "links": [
+        {"ethernet_mac_address": "fa:16:3e:dd:50:9a", "mtu": 1500,
+         "type": "vif", "id": "eth0", "vif_id": "vif-foo1"},
+        {"ethernet_mac_address": "fa:16:3e:a8:14:69", "mtu": 1500,
+         "type": "vif", "id": "eth1", "vif_id": "vif-foo2"}]
+}
+
+
 KNOWN_MACS = {
     'fa:16:3e:69:b0:58': 'enp0s1',
-    'fa:16:3e:d4:57:ad': 'enp0s2'}
+    'fa:16:3e:d4:57:ad': 'enp0s2',
+    'fa:16:3e:dd:50:9a': 'foo1',
+    'fa:16:3e:a8:14:69': 'foo2',
+}
 
 CFG_DRIVE_FILES_V2 = {
     'ec2/2009-04-04/meta-data.json': json.dumps(EC2_META),
@@ -402,6 +426,15 @@
         self.assertRaises(ValueError, ds.convert_network_data,
                           NETWORK_DATA, known_macs=macs)
 
+    def test_conversion_with_route(self):
+        from cloudinit import net
+        ncfg = ds.convert_network_data(NETWORK_DATA_2, known_macs=KNOWN_MACS)
+        import pprint; pprint.pprint(ncfg)
+        ns = net.parse_net_config_data(ncfg)
+        eni = net.render_interfaces(ns)
+        print("eni=%s" % eni)
+        raise Exception(ncfg)
+
 
 def cfg_ds_from_dir(seed_d):
     found = ds.read_config_drive(seed_d)
Download as text