[lxc-devel] [lxd/master] networks/utils: Removes networkUpdateStaticContainer

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jul 15 13:34:48 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 426 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190715/a029b4c5/attachment.bin>
-------------- next part --------------
From 5196a2a13064aa39c22d55f4ee7bab5cca297378 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 15 Jul 2019 14:33:48 +0100
Subject: [PATCH] networks/utils: Removes networkUpdateStaticContainer

Updates references to use dnsmasq.UpdateStaticEntry() instead

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/container_lxc.go  |  2 +-
 lxd/networks_utils.go | 29 -----------------------------
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 5dbc44b9fd..8116de59eb 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -8936,7 +8936,7 @@ func (c *containerLXC) allocateNetworkFilterIPs(deviceName string, m types.Devic
 		dnsmasq.ConfigMutex.Lock()
 		defer dnsmasq.ConfigMutex.Unlock()
 
-		err = networkUpdateStaticContainer(m["parent"], c.Project(), c.Name(), netConfig, m["hwaddr"], IPv4Str, IPv6Str)
+		err = dnsmasq.UpdateStaticEntry(m["parent"], c.Project(), c.Name(), netConfig, m["hwaddr"], IPv4Str, IPv6Str)
 		if err != nil {
 			return IPv4, IPv6, err
 		}
diff --git a/lxd/networks_utils.go b/lxd/networks_utils.go
index d15b8726e1..a0b6bc0111 100644
--- a/lxd/networks_utils.go
+++ b/lxd/networks_utils.go
@@ -1010,35 +1010,6 @@ func networkDHCPFindFreeIPv4(usedIPs map[[4]byte]dnsmasq.DHCPAllocation, netConf
 	return nil, fmt.Errorf("No available IP could not be found")
 }
 
-// networkUpdateStaticContainer writes a single dhcp-host line for a container/network combination.
-func networkUpdateStaticContainer(network string, projectName string, cName string, netConfig map[string]string, hwaddr string, ipv4Address string, ipv6Address string) error {
-	line := hwaddr
-
-	// Generate the dhcp-host line
-	if ipv4Address != "" {
-		line += fmt.Sprintf(",%s", ipv4Address)
-	}
-
-	if ipv6Address != "" {
-		line += fmt.Sprintf(",[%s]", ipv6Address)
-	}
-
-	if netConfig["dns.mode"] == "" || netConfig["dns.mode"] == "managed" {
-		line += fmt.Sprintf(",%s", cName)
-	}
-
-	if line == hwaddr {
-		return nil
-	}
-
-	err := ioutil.WriteFile(shared.VarPath("networks", network, "dnsmasq.hosts", project.Prefix(projectName, cName)), []byte(line+"\n"), 0644)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
 func networkUpdateStatic(s *state.State, networkName string) error {
 	// We don't want to race with ourselves here
 	dnsmasq.ConfigMutex.Lock()


More information about the lxc-devel mailing list