summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2016-05-26 21:17:29 -0500
committerRyan Harper <ryan.harper@canonical.com>2016-05-26 21:17:29 -0500
commitc1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1 (patch)
tree8725465ffa453e36918db345bc391258a00b68a5 /tests
parent22bd075cd77ccc1021e049333f498afd56de2c6a (diff)
downloadvyos-cloud-init-c1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1.tar.gz
vyos-cloud-init-c1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1.zip
Move sdc:nics to a JSON map. Add unittest for sdc:nics
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_smartos.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index 5c49966a..1ee64d60 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -24,6 +24,7 @@
from __future__ import print_function
+import json
import os
import os.path
import re
@@ -47,6 +48,48 @@ try:
except ImportError:
import mock
+SDC_NICS = json.loads("""
+[
+ {
+ "nic_tag": "external",
+ "primary": true,
+ "mtu": 1500,
+ "model": "virtio",
+ "gateway": "8.12.42.1",
+ "netmask": "255.255.255.0",
+ "ip": "8.12.42.102",
+ "network_uuid": "992fc7ce-6aac-4b74-aed6-7b9d2c6c0bfe",
+ "gateways": [
+ "8.12.42.1"
+ ],
+ "vlan_id": 324,
+ "mac": "90:b8:d0:f5:e4:f5",
+ "interface": "net0",
+ "ips": [
+ "8.12.42.102/24"
+ ]
+ },
+ {
+ "nic_tag": "sdc_overlay/16187209",
+ "gateway": "192.168.128.1",
+ "model": "virtio",
+ "mac": "90:b8:d0:a5:ff:cd",
+ "netmask": "255.255.252.0",
+ "ip": "192.168.128.93",
+ "network_uuid": "4cad71da-09bc-452b-986d-03562a03a0a9",
+ "gateways": [
+ "192.168.128.1"
+ ],
+ "vlan_id": 2,
+ "mtu": 8500,
+ "interface": "net1",
+ "ips": [
+ "192.168.128.93/22"
+ ]
+ }
+]
+""")
+
MOCK_RETURNS = {
'hostname': 'test-host',
'root_authorized_keys': 'ssh-rsa AAAAB3Nz...aC1yc2E= keyname',
@@ -60,6 +103,7 @@ MOCK_RETURNS = {
'sdc:vendor-data': '\n'.join(['VENDOR_DATA', '']),
'user-data': '\n'.join(['something', '']),
'user-script': '\n'.join(['/bin/true', '']),
+ 'sdc:nics': SDC_NICS,
}
DMI_DATA_RETURN = 'smartdc'
@@ -275,6 +319,13 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
self.assertEquals(MOCK_RETURNS['cloud-init:user-data'],
dsrc.userdata_raw)
+ def test_sdc_nics(self):
+ dsrc = self._get_ds(mockdata=MOCK_RETURNS)
+ ret = dsrc.get_data()
+ self.assertTrue(ret)
+ self.assertEquals(MOCK_RETURNS['sdc:nics'],
+ dsrc.metadata['network-data'])
+
def test_sdc_scripts(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()