[lxc-devel] [lxd/master] Network: Pick default network type based on project

tomponline on Github lxc-bot at linuxcontainers.org
Wed Sep 23 08:22:47 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 438 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200923/4b521f07/attachment.bin>
-------------- next part --------------
From 8ca190120f9461048bb38537a7ba1f1883e11a41 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 23 Sep 2020 09:20:04 +0100
Subject: [PATCH 1/2] lxd/network: Removes client side default network type
 when creating network

Let server decide the appropriate network type to use when not specified by user.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxc/network.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxc/network.go b/lxc/network.go
index 17980f40c2..41c2f6e549 100644
--- a/lxc/network.go
+++ b/lxc/network.go
@@ -255,7 +255,7 @@ func (c *cmdNetworkCreate) Command() *cobra.Command {
 	cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(`Create new networks`))
 
 	cmd.Flags().StringVar(&c.network.flagTarget, "target", "", i18n.G("Cluster member name")+"``")
-	cmd.Flags().StringVarP(&c.network.flagType, "type", "t", "bridge", i18n.G("Network type"))
+	cmd.Flags().StringVarP(&c.network.flagType, "type", "t", "", i18n.G("Network type"))
 
 	cmd.RunE = c.Run
 

From c896c22ae8c97cfb93ebf4112b6e6ecaa291bd48 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 23 Sep 2020 09:20:43 +0100
Subject: [PATCH 2/2] lxd/networks: Default to ovn network type when creating
 non-default network project

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/networks.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lxd/networks.go b/lxd/networks.go
index 32a58f7043..3e399350c0 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -144,7 +144,11 @@ func networksPost(d *Daemon, r *http.Request) response.Response {
 	}
 
 	if req.Type == "" {
-		req.Type = "bridge"
+		if projectName != project.Default {
+			req.Type = "ovn" // Only OVN networks are allowed inside network enabled projects.
+		} else {
+			req.Type = "bridge" // Default to bridge for non-network enabled projects.
+		}
 	}
 
 	if req.Config == nil {


More information about the lxc-devel mailing list