summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-08-11 15:03:09 -0600
committerScott Moser <smoser@ubuntu.com>2016-08-11 16:52:26 -0600
commit8028c9234ec4260eda9431bffc6728ac3703e243 (patch)
treeb85e563491057f81581d3f6191cb77e411730c4b
parentcdcac86848a570eb657af428fe4d2bd4ce3bceb1 (diff)
downloadvyos-cloud-init-8028c9234ec4260eda9431bffc6728ac3703e243.tar.gz
vyos-cloud-init-8028c9234ec4260eda9431bffc6728ac3703e243.zip
ConfigDrive: recognize 'tap' as a link type.
This just adds 'tap' to the list of types that are understood to be physical or virtual network devices. Openstack basically exposes the type of the host device through. LP: #1610784
-rw-r--r--cloudinit/sources/helpers/openstack.py2
-rw-r--r--tests/unittests/test_datasource/test_configdrive.py44
2 files changed, 45 insertions, 1 deletions
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
index 2e7a1d47..461fbd0d 100644
--- a/cloudinit/sources/helpers/openstack.py
+++ b/cloudinit/sources/helpers/openstack.py
@@ -571,7 +571,7 @@ def convert_net_json(network_json=None, known_macs=None):
subnet['ipv6'] = True
subnets.append(subnet)
cfg.update({'subnets': subnets})
- if link['type'] in ['ethernet', 'vif', 'ovs', 'phy', 'bridge']:
+ if link['type'] in ['ethernet', 'vif', 'ovs', 'phy', 'bridge', 'tap']:
cfg.update({
'type': 'physical',
'mac_address': link['ethernet_mac_address']})
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index 18551b92..d0269943 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -101,6 +101,41 @@ NETWORK_DATA_2 = {
"type": "vif", "id": "eth1", "vif_id": "vif-foo2"}]
}
+# This network data ha 'tap' type for a link.
+NETWORK_DATA_3 = {
+ "services": [{"type": "dns", "address": "172.16.36.11"},
+ {"type": "dns", "address": "172.16.36.12"}],
+ "networks": [
+ {"network_id": "7c41450c-ba44-401a-9ab1-1604bb2da51e",
+ "type": "ipv4", "netmask": "255.255.255.128",
+ "link": "tap77a0dc5b-72", "ip_address": "172.17.48.18",
+ "id": "network0",
+ "routes": [{"netmask": "0.0.0.0", "network": "0.0.0.0",
+ "gateway": "172.17.48.1"}]},
+ {"network_id": "7c41450c-ba44-401a-9ab1-1604bb2da51e",
+ "type": "ipv6", "netmask": "ffff:ffff:ffff:ffff::",
+ "link": "tap77a0dc5b-72",
+ "ip_address": "fdb8:52d0:9d14:0:f816:3eff:fe9f:70d",
+ "id": "network1",
+ "routes": [{"netmask": "::", "network": "::",
+ "gateway": "fdb8:52d0:9d14::1"}]},
+ {"network_id": "1f53cb0e-72d3-47c7-94b9-ff4397c5fe54",
+ "type": "ipv4", "netmask": "255.255.255.128",
+ "link": "tap7d6b7bec-93", "ip_address": "172.16.48.13",
+ "id": "network2",
+ "routes": [{"netmask": "0.0.0.0", "network": "0.0.0.0",
+ "gateway": "172.16.48.1"},
+ {"netmask": "255.255.0.0", "network": "172.16.0.0",
+ "gateway": "172.16.48.1"}]}],
+ "links": [
+ {"ethernet_mac_address": "fa:16:3e:dd:50:9a", "mtu": None,
+ "type": "tap", "id": "tap77a0dc5b-72",
+ "vif_id": "77a0dc5b-720e-41b7-bfa7-1b2ff62e0d48"},
+ {"ethernet_mac_address": "fa:16:3e:a8:14:69", "mtu": None,
+ "type": "tap", "id": "tap7d6b7bec-93",
+ "vif_id": "7d6b7bec-93e6-4c03-869a-ddc5014892d5"}
+ ]
+}
KNOWN_MACS = {
'fa:16:3e:69:b0:58': 'enp0s1',
@@ -555,6 +590,15 @@ class TestConvertNetworkData(TestCase):
eni_rendering = f.read()
self.assertIn("route add default gw 2.2.2.9", eni_rendering)
+ def test_conversion_with_tap(self):
+ ncfg = openstack.convert_net_json(NETWORK_DATA_3,
+ known_macs=KNOWN_MACS)
+ physicals = set()
+ for i in ncfg['config']:
+ if i.get('type') == "physical":
+ physicals.add(i['name'])
+ self.assertEqual(physicals, set(('foo1', 'foo2')))
+
def cfg_ds_from_dir(seed_d):
cfg_ds = ds.DataSourceConfigDrive(settings.CFG_BUILTIN, None,