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

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 <[email protected]>
From 0f95ec8a2247ad7a78acac855f6a1532279106c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Fri, 27 Apr 2018 21:20:02 -0400
Subject: [PATCH] lxd/init: Offer to setup a Fan bridge when clustered
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <[email protected]>
---
 lxd/main_init_interactive.go | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lxd/main_init_interactive.go b/lxd/main_init_interactive.go
index 311b1968d..33efafb16 100644
--- a/lxd/main_init_interactive.go
+++ b/lxd/main_init_interactive.go
@@ -3,6 +3,7 @@ package main
 import (
        "encoding/pem"
        "fmt"
+       "io/ioutil"
        "net"
        "os"
        "os/exec"
@@ -274,7 +275,16 @@ func (c *cmdInit) askMAAS(config *initData, d 
lxd.ContainerServer) error {
 }
 
 func (c *cmdInit) askNetworking(config *initData, d lxd.ContainerServer) error 
{
-       if !cli.AskBool("Would you like to create a new network bridge? 
(yes/no) [default=yes]: ", "yes") {
+       if config.Cluster != nil || !cli.AskBool("Would you like to create a 
new local network bridge? (yes/no) [default=yes]: ", "yes") {
+               // At this time, only the Ubuntu kernel supports the Fan, 
detect it
+               fanKernel := false
+               if shared.PathExists("/proc/sys/kernel/version") {
+                       content, _ := 
ioutil.ReadFile("/proc/sys/kernel/version")
+                       if content != nil && strings.Contains(string(content), 
"Ubuntu") {
+                               fanKernel = true
+                       }
+               }
+
                if cli.AskBool("Would you like to configure LXD to use an 
existing bridge or host interface? (yes/no) [default=no]: ", "no") {
                        for {
                                name := cli.AskString("Name of the existing 
bridge or host interface: ", "", nil)
@@ -314,6 +324,24 @@ func (c *cmdInit) askNetworking(config *initData, d 
lxd.ContainerServer) error {
 
                                break
                        }
+               } else if config.Cluster != nil && fanKernel && 
cli.AskBool("Would you like to create a new Fan overlay network? (yes/no) 
[default=yes]", "yes") {
+                       // Define the network
+                       network := api.NetworksPost{}
+                       network.Name = "lxdfan0"
+                       network.Config = map[string]string{
+                               "bridge.mode": "fan",
+                       }
+
+                       // Add the new network
+                       config.Networks = append(config.Networks, network)
+
+                       // Add to the default profile
+                       config.Profiles[0].Devices["eth0"] = map[string]string{
+                               "type":    "nic",
+                               "nictype": "bridged",
+                               "name":    "eth0",
+                               "parent":  "lxdfan0",
+                       }
                }
 
                return nil
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to