summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorsshedi <53473811+sshedi@users.noreply.github.com>2021-06-29 00:12:34 +0530
committerGitHub <noreply@github.com>2021-06-28 13:42:34 -0500
commitb5aecbe9512fa546255cc93b178b4081342fc247 (patch)
treee7300b313984dfdde9799294d8f2a02f276e19c0 /tests/unittests
parent35aa9db6f8e2ba05d366776c0e8d97f52217e930 (diff)
downloadvyos-cloud-init-b5aecbe9512fa546255cc93b178b4081342fc247.tar.gz
vyos-cloud-init-b5aecbe9512fa546255cc93b178b4081342fc247.zip
Removed distro specific network code from Photon (#929)
Minor fixes in networkd renderer & fixed corresponding tests Removed datasource_list for Photon from cloud.cfg.tmpl & added a comment in cloud.cfg.tmpl about not to use multiline array for datasource_list. Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_distros/test_netconfig.py41
-rw-r--r--tests/unittests/test_net.py4
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index 562ee04a..d09e46af 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -15,6 +15,7 @@ from cloudinit.tests.helpers import (
FilesystemMockingTestCase, dir2dict)
from cloudinit import subp
from cloudinit import util
+from cloudinit import safeyaml
BASE_NET_CFG = '''
auto lo
@@ -88,6 +89,24 @@ V1_NET_CFG = {'config': [{'name': 'eth0',
'type': 'physical'}],
'version': 1}
+V1_NET_CFG_WITH_DUPS = """\
+# same value in interface specific dns and global dns
+# should produce single entry in network file
+version: 1
+config:
+ - type: physical
+ name: eth0
+ subnets:
+ - type: static
+ address: 192.168.0.102/24
+ dns_nameservers: [1.2.3.4]
+ dns_search: [test.com]
+ interface: eth0
+ - type: nameserver
+ address: [1.2.3.4]
+ search: [test.com]
+"""
+
V1_NET_CFG_OUTPUT = """\
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
@@ -867,6 +886,28 @@ class TestNetCfgDistroPhoton(TestNetCfgDistroBase):
V2_NET_CFG,
expected_cfgs.copy())
+ def test_photon_network_config_v1_with_duplicates(self):
+ expected = """\
+ [Match]
+ Name=eth0
+ [Network]
+ DHCP=no
+ DNS=1.2.3.4
+ Domains=test.com
+ [Address]
+ Address=192.168.0.102/24"""
+
+ net_cfg = safeyaml.load(V1_NET_CFG_WITH_DUPS)
+
+ expected = self.create_conf_dict(expected.splitlines())
+ expected_cfgs = {
+ self.nwk_file_path('eth0'): expected,
+ }
+
+ self._apply_and_verify(self.distro.apply_network_config,
+ net_cfg,
+ expected_cfgs.copy())
+
def get_mode(path, target=None):
return os.stat(subp.target_path(target, path)).st_mode & 0o777
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index b2ddbf99..1aab51ee 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -825,10 +825,14 @@ NETWORK_CONFIGS = {
[Match]
Name=eth99
MACAddress=c0:d6:9f:2c:e8:80
+ [Address]
+ Address=192.168.21.3/24
[Network]
DHCP=ipv4
+ Domains=barley.maas sach.maas
Domains=wark.maas
DNS=1.2.3.4 5.6.7.8
+ DNS=8.8.8.8 8.8.4.4
[Route]
Gateway=65.61.151.37
Destination=0.0.0.0/0