summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_lxd.py
diff options
context:
space:
mode:
authorStéphane Graber <stgraber@ubuntu.com>2016-09-29 01:40:32 -0400
committerScott Moser <smoser@brickies.net>2016-09-29 12:23:02 -0400
commit02f6c4bb8cef17b3fe04ef4dc1ef199e20aeb4d9 (patch)
tree6b53ce90cd1d969af46aafb7ed840cee47a50a37 /tests/unittests/test_handler/test_handler_lxd.py
parent9f83bb8e80806d3dd79ba426474dc3c696e19a41 (diff)
downloadvyos-cloud-init-02f6c4bb8cef17b3fe04ef4dc1ef199e20aeb4d9.tar.gz
vyos-cloud-init-02f6c4bb8cef17b3fe04ef4dc1ef199e20aeb4d9.zip
lxd: Update network config for LXD 2.3
Prior to LXD 2.3, the bridge configuration was done through distro packaging. Thus, lxd module interacted with debconf. With 2.3 and higher, this is now done inside LXD itself, so we need to use "lxc network" there. For now, this perfectly matches what we had before with debconf and doesn't cover any of the new options. We can always add those later. A set of tests similar to what we had for debconf has been added to make sure things look good. This is tested in Yakkety container running LXD 2.3 and all options seem to be passed through as expected, giving me the bridge I defined. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Diffstat (limited to 'tests/unittests/test_handler/test_handler_lxd.py')
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index 6f90defb..14366a10 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -132,3 +132,54 @@ class TestLxd(t_help.TestCase):
cc_lxd.bridge_to_debconf(data),
{"lxd/setup-bridge": "false",
"lxd/bridge-name": ""})
+
+ def test_lxd_cmd_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.assertEqual(
+ cc_lxd.bridge_to_cmd(data),
+ (["lxc", "network", "create", "testbr0",
+ "ipv4.address=10.0.8.1/24", "ipv4.nat=true",
+ "ipv4.dhcp.ranges=10.0.8.2-10.0.8.254",
+ "ipv6.address=fd98:9e0:3744::1/64",
+ "ipv6.nat=true", "dns.domain=lxd",
+ "--force-local"],
+ ["lxc", "network", "attach-profile",
+ "testbr0", "default", "eth0", "--force-local"]))
+
+ def test_lxd_cmd_new_partial(self):
+ data = {"mode": "new",
+ "ipv6_address": "fd98:9e0:3744::1",
+ "ipv6_netmask": "64",
+ "ipv6_nat": "true"}
+ self.assertEqual(
+ cc_lxd.bridge_to_cmd(data),
+ (["lxc", "network", "create", "lxdbr0", "ipv4.address=none",
+ "ipv6.address=fd98:9e0:3744::1/64", "ipv6.nat=true",
+ "--force-local"],
+ ["lxc", "network", "attach-profile",
+ "lxdbr0", "default", "eth0", "--force-local"]))
+
+ def test_lxd_cmd_existing(self):
+ data = {"mode": "existing",
+ "name": "testbr0"}
+ self.assertEqual(
+ cc_lxd.bridge_to_cmd(data),
+ (None, ["lxc", "network", "attach-profile",
+ "testbr0", "default", "eth0", "--force-local"]))
+
+ def test_lxd_cmd_none(self):
+ data = {"mode": "none"}
+ self.assertEqual(
+ cc_lxd.bridge_to_cmd(data),
+ (None, None))