summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-11 15:20:46 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-11 15:20:46 -0400
commit763be4ecccca0c0ccb62466699cc9cd22f79adc7 (patch)
tree816b5703292f5820c4b1f3921c91ee66e532c4c1 /tests
parent822ac18bc98dee35c805bf238f6bf0a1543a39dc (diff)
parent860d98bce4b607a513dc94d96335e8f105a36294 (diff)
downloadvyos-cloud-init-763be4ecccca0c0ccb62466699cc9cd22f79adc7.tar.gz
vyos-cloud-init-763be4ecccca0c0ccb62466699cc9cd22f79adc7.zip
lxd: adds basic support for dpkg based lxd-bridge configuration.
It exposes the most useful debconf keys as cloud-init configuration keys.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index 7ffa2a53..5f61ba6a 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -73,3 +73,62 @@ class TestLxd(t_help.TestCase):
cc_lxd.handle('cc_lxd', {'package_update': True}, cc, LOG, [])
self.assertFalse(cc.distro.install_packages.called)
self.assertFalse(mock_util.subp.called)
+
+ def test_lxd_debconf_new_full(self):
+ data = {"mode": "new",
+ "name": "testbr0",
+ "ipv4_address": "10.0.8.1",
+ "ipv4_netmask": "24",
+ "ipv4_dhcp_first": "10.0.8.2",
+ "ipv4_dhcp_last": "10.0.8.254",
+ "ipv4_dhcp_leases": "250",
+ "ipv4_nat": "true",
+ "ipv6_address": "fd98:9e0:3744::1",
+ "ipv6_netmask": "64",
+ "ipv6_nat": "true",
+ "domain": "lxd"}
+ self.assertEquals(
+ cc_lxd.bridge_to_debconf(data),
+ {"lxd/setup-bridge": "true",
+ "lxd/bridge-name": "testbr0",
+ "lxd/bridge-ipv4": "true",
+ "lxd/bridge-ipv4-address": "10.0.8.1",
+ "lxd/bridge-ipv4-netmask": "24",
+ "lxd/bridge-ipv4-dhcp-first": "10.0.8.2",
+ "lxd/bridge-ipv4-dhcp-last": "10.0.8.254",
+ "lxd/bridge-ipv4-dhcp-leases": "250",
+ "lxd/bridge-ipv4-nat": "true",
+ "lxd/bridge-ipv6": "true",
+ "lxd/bridge-ipv6-address": "fd98:9e0:3744::1",
+ "lxd/bridge-ipv6-netmask": "64",
+ "lxd/bridge-ipv6-nat": "true",
+ "lxd/bridge-domain": "lxd"})
+
+ def test_lxd_debconf_new_partial(self):
+ data = {"mode": "new",
+ "ipv6_address": "fd98:9e0:3744::1",
+ "ipv6_netmask": "64",
+ "ipv6_nat": "true"}
+ self.assertEquals(
+ cc_lxd.bridge_to_debconf(data),
+ {"lxd/setup-bridge": "true",
+ "lxd/bridge-ipv6": "true",
+ "lxd/bridge-ipv6-address": "fd98:9e0:3744::1",
+ "lxd/bridge-ipv6-netmask": "64",
+ "lxd/bridge-ipv6-nat": "true"})
+
+ def test_lxd_debconf_existing(self):
+ data = {"mode": "existing",
+ "name": "testbr0"}
+ self.assertEquals(
+ cc_lxd.bridge_to_debconf(data),
+ {"lxd/setup-bridge": "false",
+ "lxd/use-existing-bridge": "true",
+ "lxd/bridge-name": "testbr0"})
+
+ def test_lxd_debconf_none(self):
+ data = {"mode": "none"}
+ self.assertEquals(
+ cc_lxd.bridge_to_debconf(data),
+ {"lxd/setup-bridge": "false",
+ "lxd/bridge-name": ""})