[lxc-devel] [lxd/master] lxd/init: Allow using an existing bridge
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Mar 29 19:36:46 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/20180329/f443c7e1/attachment.bin>
-------------- next part --------------
From 19f2f6da83eed78c6fac180b6049168487901d26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 29 Mar 2018 15:33:42 -0400
Subject: [PATCH] lxd/init: Allow using an existing bridge
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 | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/lxd/main_init_interactive.go b/lxd/main_init_interactive.go
index a616e31ef..8094fad65 100644
--- a/lxd/main_init_interactive.go
+++ b/lxd/main_init_interactive.go
@@ -241,6 +241,32 @@ func (c *cmdInit) askClustering(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 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)
+
+ if !shared.PathExists(fmt.Sprintf("/sys/class/net/%s", name)) {
+ fmt.Println("The requested interface doesn't exist. Please choose another one.")
+ continue
+ }
+
+ nicType := "macvlan"
+ if shared.PathExists(fmt.Sprintf("/sys/class/net/%s/bridge", name)) {
+ nicType = "bridged"
+ }
+
+ // Add to the default profile
+ config.Profiles[0].Devices["eth0"] = map[string]string{
+ "type": "nic",
+ "nictype": nicType,
+ "name": "eth0",
+ "parent": name,
+ }
+
+ break
+ }
+ }
+
return nil
}
More information about the lxc-devel
mailing list