Bläddra i källkod

Make LXC aware of custom bridge

Guillaume J. Charmes 12 år sedan
förälder
incheckning
d9a9bfc9c7
2 ändrade filer med 3 tillägg och 1 borttagningar
  1. 2 0
      container.go
  2. 1 1
      lxc_template.go

+ 2 - 0
container.go

@@ -135,6 +135,7 @@ type NetworkSettings struct {
 	IpAddress   string
 	IpAddress   string
 	IpPrefixLen int
 	IpPrefixLen int
 	Gateway     string
 	Gateway     string
+	Bridge      string
 	PortMapping map[string]string
 	PortMapping map[string]string
 }
 }
 
 
@@ -491,6 +492,7 @@ func (container *Container) allocateNetwork() error {
 		}
 		}
 	}
 	}
 	container.network = iface
 	container.network = iface
+	container.NetworkSettings.Bridge = container.runtime.networkManager.bridgeIface
 	container.NetworkSettings.IpAddress = iface.IPNet.IP.String()
 	container.NetworkSettings.IpAddress = iface.IPNet.IP.String()
 	container.NetworkSettings.IpPrefixLen, _ = iface.IPNet.Mask.Size()
 	container.NetworkSettings.IpPrefixLen, _ = iface.IPNet.Mask.Size()
 	container.NetworkSettings.Gateway = iface.Gateway.String()
 	container.NetworkSettings.Gateway = iface.Gateway.String()

+ 1 - 1
lxc_template.go

@@ -16,7 +16,7 @@ lxc.utsname = {{.Id}}
 # network configuration
 # network configuration
 lxc.network.type = veth
 lxc.network.type = veth
 lxc.network.flags = up
 lxc.network.flags = up
-lxc.network.link = lxcbr0
+lxc.network.link = {{.NetworkSettings.Bridge}}
 lxc.network.name = eth0
 lxc.network.name = eth0
 lxc.network.mtu = 1500
 lxc.network.mtu = 1500
 lxc.network.ipv4 = {{.NetworkSettings.IpAddress}}/{{.NetworkSettings.IpPrefixLen}}
 lxc.network.ipv4 = {{.NetworkSettings.IpAddress}}/{{.NetworkSettings.IpPrefixLen}}