[lxc-devel] [lxd/master] network: Fix networkIsInUse
stgraber on Github
lxc-bot at linuxcontainers.org
Sat Sep 17 06:19:29 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 395 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160917/54f04b61/attachment.bin>
-------------- next part --------------
From d4efd0f6c770abc9456147bc9e7cfb56e4c99421 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 17 Sep 2016 02:18:46 -0400
Subject: [PATCH] network: Fix networkIsInUse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Variable name re-use was breaking it.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks.go | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lxd/networks.go b/lxd/networks.go
index cfd1e72..a5b29e3 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -14,23 +14,20 @@ import (
// Helper functions
func networkIsInUse(c container, name string) bool {
- devices := c.ExpandedDevices()
- for _, name := range devices.DeviceNames() {
- device := devices[name]
-
- if device["type"] != "nic" {
+ for _, d := range c.ExpandedDevices() {
+ if d["type"] != "nic" {
continue
}
- if !shared.StringInSlice(device["nictype"], []string{"bridged", "macvlan"}) {
+ if !shared.StringInSlice(d["nictype"], []string{"bridged", "macvlan"}) {
continue
}
- if device["parent"] == "" {
+ if d["parent"] == "" {
continue
}
- if device["parent"] == name {
+ if d["parent"] == name {
return true
}
}
More information about the lxc-devel
mailing list