[lxc-devel] [lxd/master] network: Improve errors and tests
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Jul 20 13:13:25 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180720/bd6bf93c/attachment.bin>
-------------- next part --------------
From 0eed711bb5dd446719480c7d25d541a09ed615ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 20 Jul 2018 09:04:40 -0400
Subject: [PATCH 1/2] lxd/networks: Improve error on missing openvswitch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lxd/networks.go b/lxd/networks.go
index 115e4eea8..7b863f0dd 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -964,7 +964,12 @@ func (n *network) Start() error {
// Create the bridge interface
if !n.IsRunning() {
if n.config["bridge.driver"] == "openvswitch" {
- _, err := shared.RunCommand("ovs-vsctl", "add-br", n.name)
+ _, err := exec.LookPath("ovs-vsctl")
+ if err != nil {
+ return fmt.Errorf("Open vSwitch isn't installed on this system")
+ }
+
+ _, err = shared.RunCommand("ovs-vsctl", "add-br", n.name)
if err != nil {
return err
}
From cce5155f5fd69bf6a1ae9221d75a87776d9f8403 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 20 Jul 2018 09:11:55 -0400
Subject: [PATCH 2/2] tests: Add test for network put/patch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
test/suites/network.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/test/suites/network.sh b/test/suites/network.sh
index 0213dc176..76a293248 100644
--- a/test/suites/network.sh
+++ b/test/suites/network.sh
@@ -11,6 +11,15 @@ test_network() {
lxc network set lxdt$$ ipv4.routing false
lxc network set lxdt$$ ipv6.routing false
lxc network set lxdt$$ ipv6.dhcp.stateful true
+
+ # validate unset and patch
+ [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "true" ]
+ lxc network unset lxdt$$ ipv6.dhcp.stateful
+ [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "" ]
+ lxc query -X PATCH -d "{\\\"config\\\": {\\\"ipv6.dhcp.stateful\\\": \\\"true\\\"}}" lxd/1.0/networks/lxdt$$
+ [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "true" ]
+
+ # delete the network
lxc network delete lxdt$$
# edit network description
More information about the lxc-devel
mailing list