[lxc-devel] [lxd/master] lxd/init: Offer to setup a Fan bridge when clustered
stgraber on Github
lxc-bot at linuxcontainers.org
Sat Apr 28 01:52:04 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180428/9b6a36ac/attachment.bin>
-------------- next part --------------
From 0f95ec8a2247ad7a78acac855f6a1532279106c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
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 <stgraber at ubuntu.com>
---
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
More information about the lxc-devel
mailing list