summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJon Grimm <jon.grimm@canonical.com>2016-09-09 16:32:36 -0500
committerScott Moser <smoser@brickies.net>2016-09-12 14:50:38 -0400
commit65ace7b35494dba1747eece815754ab8573d83d8 (patch)
tree6aecf4a54f77927c6124c1144a073317c0b7a380 /tests
parent2aa9b1ddf80ffe7d35e8437c59670856d612e64e (diff)
downloadvyos-cloud-init-65ace7b35494dba1747eece815754ab8573d83d8.tar.gz
vyos-cloud-init-65ace7b35494dba1747eece815754ab8573d83d8.zip
Allow link type of null in network_data.json
Treat null type as yet another physical type, seen in real-world openstack cloud. Also, support the case where network_data.json provides mac addresses in upper case. Rackspace public cloud currently does that. LP: #1621968
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_configdrive.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index 98ff97a7..6e00abf4 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -1,4 +1,4 @@
-from copy import copy
+from copy import copy, deepcopy
import json
import os
import shutil
@@ -101,7 +101,7 @@ NETWORK_DATA_2 = {
"type": "vif", "id": "eth1", "vif_id": "vif-foo2"}]
}
-# This network data ha 'tap' type for a link.
+# This network data ha 'tap' or null type for a link.
NETWORK_DATA_3 = {
"services": [{"type": "dns", "address": "172.16.36.11"},
{"type": "dns", "address": "172.16.36.12"}],
@@ -132,7 +132,7 @@ NETWORK_DATA_3 = {
"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",
+ "type": None, "id": "tap7d6b7bec-93",
"vif_id": "7d6b7bec-93e6-4c03-869a-ddc5014892d5"}
]
}
@@ -704,6 +704,22 @@ class TestConvertNetworkData(TestCase):
self.assertIn("address 10.0.1.5", eni_rendering)
self.assertIn("auto enp0s1.602", eni_rendering)
+ def test_mac_addrs_can_be_upper_case(self):
+ # input mac addresses on rackspace may be upper case
+ my_netdata = deepcopy(NETWORK_DATA)
+ for link in my_netdata['links']:
+ link['ethernet_mac_address'] = link['ethernet_mac_address'].upper()
+
+ ncfg = openstack.convert_net_json(my_netdata, known_macs=KNOWN_MACS)
+ config_name2mac = {}
+ for n in ncfg['config']:
+ if n['type'] == 'physical':
+ config_name2mac[n['name']] = n['mac_address']
+
+ expected = {'nic0': 'fa:16:3e:05:30:fe', 'enp0s1': 'fa:16:3e:69:b0:58',
+ 'enp0s2': 'fa:16:3e:d4:57:ad'}
+ self.assertEqual(expected, config_name2mac)
+
def cfg_ds_from_dir(seed_d):
cfg_ds = ds.DataSourceConfigDrive(settings.CFG_BUILTIN, None,