Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard authored on 2015/07/14 04:34:58... | ... |
@@ -2,6 +2,8 @@ package daemon |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"os" |
5 |
+ |
|
6 |
+ flag "github.com/docker/docker/pkg/mflag" |
|
5 | 7 |
) |
6 | 8 |
|
7 | 9 |
var ( |
... | ... |
@@ -10,6 +12,12 @@ var ( |
10 | 10 |
defaultExec = "windows" |
11 | 11 |
) |
12 | 12 |
|
13 |
+// bridgeConfig stores all the bridge driver specific |
|
14 |
+// configuration. |
|
15 |
+type bridgeConfig struct { |
|
16 |
+ VirtualSwitchName string |
|
17 |
+} |
|
18 |
+ |
|
13 | 19 |
// Config defines the configuration of a docker daemon. |
14 | 20 |
// These are the configuration settings that you pass |
15 | 21 |
// to the docker daemon when you launch it with say: `docker -d -e windows` |
... | ... |
@@ -28,6 +36,6 @@ func (config *Config) InstallFlags() { |
28 | 28 |
// First handle install flags which are consistent cross-platform |
29 | 29 |
config.InstallCommonFlags() |
30 | 30 |
|
31 |
- // Then platform-specific install flags. There are none presently on Windows |
|
32 |
- |
|
31 |
+ // Then platform-specific install flags. |
|
32 |
+ flag.StringVar(&config.Bridge.VirtualSwitchName, []string{"b", "-bridge"}, "", "Attach containers to a virtual switch") |
|
33 | 33 |
} |
... | ... |
@@ -80,6 +80,7 @@ func populateCommand(c *Container, env []string) error { |
80 | 80 |
network := c.NetworkSettings |
81 | 81 |
en.Interface = &execdriver.NetworkInterface{ |
82 | 82 |
MacAddress: network.MacAddress, |
83 |
+ Bridge: c.daemon.config.Bridge.VirtualSwitchName, |
|
83 | 84 |
} |
84 | 85 |
} |
85 | 86 |
default: |
... | ... |
@@ -156,12 +157,6 @@ func (container *Container) GetSize() (int64, int64) { |
156 | 156 |
} |
157 | 157 |
|
158 | 158 |
func (container *Container) AllocateNetwork() error { |
159 |
- |
|
160 |
- // TODO Windows. This needs reworking with libnetwork. In the |
|
161 |
- // proof-of-concept for //build conference, the Windows daemon |
|
162 |
- // invoked eng.Job("allocate_interface) passing through |
|
163 |
- // RequestedMac. |
|
164 |
- |
|
165 | 159 |
return nil |
166 | 160 |
} |
167 | 161 |
|
... | ... |
@@ -174,11 +169,9 @@ func (container *Container) ExportRw() (archive.Archive, error) { |
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
func (container *Container) ReleaseNetwork() { |
177 |
- // TODO Windows. Rework with libnetwork |
|
178 | 177 |
} |
179 | 178 |
|
180 | 179 |
func (container *Container) RestoreNetwork() error { |
181 |
- // TODO Windows. Rework with libnetwork |
|
182 | 180 |
return nil |
183 | 181 |
} |
184 | 182 |
|
... | ... |
@@ -15,6 +15,8 @@ import ( |
15 | 15 |
"github.com/microsoft/hcsshim" |
16 | 16 |
) |
17 | 17 |
|
18 |
+const DefaultVirtualSwitch = "Virtual Switch" |
|
19 |
+ |
|
18 | 20 |
func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) { |
19 | 21 |
return daemon.driver.Changes(container.ID, container.ImageID) |
20 | 22 |
} |
... | ... |
@@ -125,7 +127,10 @@ func isBridgeNetworkDisabled(config *Config) bool { |
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
func initNetworkController(config *Config) (libnetwork.NetworkController, error) { |
128 |
- // TODO Windows |
|
128 |
+ // Set the name of the virtual switch if not specified by -b on daemon start |
|
129 |
+ if config.Bridge.VirtualSwitchName == "" { |
|
130 |
+ config.Bridge.VirtualSwitchName = DefaultVirtualSwitch |
|
131 |
+ } |
|
129 | 132 |
return nil, nil |
130 | 133 |
} |
131 | 134 |
|
... | ... |
@@ -81,10 +81,6 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba |
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
if c.Network.Interface != nil { |
84 |
- |
|
85 |
- // TODO Windows: Temporary |
|
86 |
- c.Network.Interface.Bridge = "Virtual Switch" |
|
87 |
- |
|
88 | 84 |
dev := device{ |
89 | 85 |
DeviceType: "Network", |
90 | 86 |
Connection: &networkConnection{ |
... | ... |
@@ -101,7 +97,11 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba |
101 | 101 |
} |
102 | 102 |
} |
103 | 103 |
|
104 |
+ logrus.Debugf("Virtual switch '%s', mac='%s'", c.Network.Interface.Bridge, c.Network.Interface.MacAddress) |
|
105 |
+ |
|
104 | 106 |
cu.Devices = append(cu.Devices, dev) |
107 |
+ } else { |
|
108 |
+ logrus.Debugln("No network interface") |
|
105 | 109 |
} |
106 | 110 |
|
107 | 111 |
configurationb, err := json.Marshal(cu) |