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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 | === modified file 'cloudinit/sources/helpers/openstack.py'
--- cloudinit/sources/helpers/openstack.py 2016-07-13 22:04:07 +0000
+++ cloudinit/sources/helpers/openstack.py 2016-07-22 19:22:24 +0000
@@ -539,6 +539,8 @@
networks = network_json.get('networks', [])
services = network_json.get('services', [])
+ bond_name_fmt = "bond%d"
+ bond_number = 0
config = []
for link in links:
subnets = []
@@ -582,9 +584,17 @@
continue
elif k.startswith('bond'):
params.update({k: v})
+
+ # openstack does not provide a name for the bond.
+ # they do provide an 'id', but that is possibly non-sensical.
+ # so we just create our own name.
+ link_name = bond_name_fmt % bond_number
+ bond_number += 1
+
cfg.update({
'bond_interfaces': copy.deepcopy(link['bond_links']),
'params': params,
+ 'name': link_name,
})
elif link['type'] in ['vlan']:
cfg.update({
=== modified file 'tests/unittests/test_datasource/test_configdrive.py'
--- tests/unittests/test_datasource/test_configdrive.py 2016-06-10 21:16:51 +0000
+++ tests/unittests/test_datasource/test_configdrive.py 2016-07-22 19:23:29 +0000
@@ -101,6 +101,93 @@
"type": "vif", "id": "eth1", "vif_id": "vif-foo2"}]
}
+NETWORK_DATA_3 = {
+ "services": [
+ {
+ "type": "dns",
+ "address": "1.1.1.191"
+ },
+ {
+ "type": "dns",
+ "address": "1.1.1.4"
+ }
+ ],
+ "networks": [
+ {
+ "network_id": "4daf5ce8-38cf-4240-9f1a-04e86d7c6117",
+ "type": "ipv4",
+ "netmask": "255.255.255.248",
+ "link": "vlan2",
+ "routes": [
+ {
+ "netmask": "0.0.0.0",
+ "network": "0.0.0.0",
+ "gateway": "2.2.2.9"
+ }
+ ],
+ "ip_address": "2.2.2.13",
+ "id": "network2-ipv4"
+ },
+ {
+ "network_id": "a9e2f47c-3c43-4782-94d0-e1eeef1c8c9d",
+ "type": "ipv4",
+ "netmask": "255.255.255.248",
+ "link": "vlan3",
+ "routes": [
+ {
+ "netmask": "255.255.255.255",
+ "network": "192.168.1.0",
+ "gateway": "10.0.1.1"
+ }
+ ],
+ "ip_address": "10.0.1.5",
+ "id": "network3-ipv4"
+ }
+ ],
+ "links": [
+ {
+ "ethernet_mac_address": "0c:c4:7a:34:6e:3c",
+ "type": "phy",
+ "id": "eth0",
+ "mtu": 1500
+ },
+ {
+ "ethernet_mac_address": "0c:c4:7a:34:6e:3d",
+ "type": "phy",
+ "id": "eth1",
+ "mtu": 1500
+ },
+ {
+ "bond_mode": "4",
+ "bond_miimon": 100,
+ "type": "bond",
+ "bond_links": [
+ "eth0",
+ "eth1"
+ ],
+ "ethernet_mac_address": "0c:c4:7a:34:6e:3c",
+ "id": "bond0",
+ "bond_xmit_hash_policy": "layer3+4"
+ },
+ {
+ "ethernet_mac_address": "fa:16:3e:b3:72:30",
+ "vlan_link": "bond0",
+ "vlan_id": 602,
+ "type": "vlan",
+ "id": "vlan2",
+ "vlan_mac_address": "fa:16:3e:b3:72:30"
+ },
+ {
+ "ethernet_mac_address": "fa:16:3e:66:ab:a6",
+ "vlan_link": "bond0",
+ "vlan_id": 612,
+ "type": "vlan",
+ "id": "vlan3",
+ "vlan_mac_address": "fa:16:3e:66:ab:a6"
+ }
+ ]
+}
+
KNOWN_MACS = {
'fa:16:3e:69:b0:58': 'enp0s1',
@@ -108,6 +195,8 @@
'fa:16:3e:dd:50:9a': 'foo1',
'fa:16:3e:a8:14:69': 'foo2',
'fa:16:3e:ed:9a:59': 'foo3',
+ '0c:c4:7a:34:6e:3d': 'oeth1',
+ '0c:c4:7a:34:6e:3c': 'oeth0',
}
CFG_DRIVE_FILES_V2 = {
@@ -555,6 +644,17 @@
eni_rendering = f.read()
self.assertIn("route add default gw 2.2.2.9", eni_rendering)
+ def test_bond_conversion(self):
+ ncfg = openstack.convert_net_json(NETWORK_DATA_3,
+ known_macs=KNOWN_MACS)
+ eni_renderer = eni.Renderer()
+ eni_renderer.render_network_state(
+ self.tmp, network_state.parse_net_config_data(ncfg))
+ with open(os.path.join(self.tmp, "etc",
+ "network", "interfaces"), 'r') as f:
+ eni_rendering = f.read()
+ # TODO: do some check on sanity of the bond interfaces
+
def cfg_ds_from_dir(seed_d):
cfg_ds = ds.DataSourceConfigDrive(settings.CFG_BUILTIN, None,
|