The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2390

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
From 64e369f817bd9e170761a75466c7cbf33e9ac57e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 6 Sep 2016 23:16:50 -0400
Subject: [PATCH] network: Move and rename isOnBridge
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: St├ęphane Graber <stgra...@ubuntu.com>
---
 lxd/networks.go | 54 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/lxd/networks.go b/lxd/networks.go
index f705f6e..cfd1e72 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -12,6 +12,33 @@ import (
        "github.com/lxc/lxd/shared"
 )
 
+// Helper functions
+func networkIsInUse(c container, name string) bool {
+       devices := c.ExpandedDevices()
+       for _, name := range devices.DeviceNames() {
+               device := devices[name]
+
+               if device["type"] != "nic" {
+                       continue
+               }
+
+               if !shared.StringInSlice(device["nictype"], []string{"bridged", 
"macvlan"}) {
+                       continue
+               }
+
+               if device["parent"] == "" {
+                       continue
+               }
+
+               if device["parent"] == name {
+                       return true
+               }
+       }
+
+       return false
+}
+
+// API endpoints
 func networksGet(d *Daemon, r *http.Request) Response {
        recursionStr := r.FormValue("recursion")
        recursion, err := strconv.Atoi(recursionStr)
@@ -54,31 +81,6 @@ type network struct {
        UsedBy []string `json:"used_by"`
 }
 
-func isOnBridge(c container, bridge string) bool {
-       devices := c.ExpandedDevices()
-       for _, name := range devices.DeviceNames() {
-               device := devices[name]
-
-               if device["type"] != "nic" {
-                       continue
-               }
-
-               if !shared.StringInSlice(device["nictype"], []string{"bridged", 
"macvlan"}) {
-                       continue
-               }
-
-               if device["parent"] == "" {
-                       continue
-               }
-
-               if device["parent"] == bridge {
-                       return true
-               }
-       }
-
-       return false
-}
-
 func networkGet(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
@@ -113,7 +115,7 @@ func doNetworkGet(d *Daemon, name string) (network, error) {
                        return network{}, err
                }
 
-               if isOnBridge(c, n.Name) {
+               if networkIsInUse(c, n.Name) {
                        n.UsedBy = append(n.UsedBy, 
fmt.Sprintf("/%s/containers/%s", shared.APIVersion, ct))
                }
        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to