Browse code

Move daemonconfig into daemon

Signed-off-by: Solomon Hykes <solomon@docker.com>

Solomon Hykes authored on 2014/08/10 07:30:27
Showing 6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,44 @@
0
+package daemon
1
+
2
+import (
3
+	"github.com/docker/docker/daemon/networkdriver"
4
+	"net"
5
+)
6
+
7
+const (
8
+	defaultNetworkMtu    = 1500
9
+	DisableNetworkBridge = "none"
10
+)
11
+
12
+// Config define the configuration of a docker daemon
13
+//  These are the configuration settings that you pass
14
+// to the docker daemon when you launch it with say: `docker -d -e lxc`
15
+// FIXME: separate runtime configuration from http api configuration
16
+type Config struct {
17
+	Pidfile                     string
18
+	Root                        string
19
+	AutoRestart                 bool
20
+	Dns                         []string
21
+	DnsSearch                   []string
22
+	EnableIptables              bool
23
+	EnableIpForward             bool
24
+	DefaultIp                   net.IP
25
+	BridgeIface                 string
26
+	BridgeIP                    string
27
+	InterContainerCommunication bool
28
+	GraphDriver                 string
29
+	GraphOptions                []string
30
+	ExecDriver                  string
31
+	Mtu                         int
32
+	DisableNetwork              bool
33
+	EnableSelinuxSupport        bool
34
+	Context                     map[string][]string
35
+	Sockets                     []string
36
+}
37
+
38
+func GetDefaultNetworkMtu() int {
39
+	if iface, err := networkdriver.GetDefaultRouteIface(); err == nil {
40
+		return iface.MTU
41
+	}
42
+	return defaultNetworkMtu
43
+}
... ...
@@ -21,7 +21,6 @@ import (
21 21
 	_ "github.com/docker/docker/daemon/graphdriver/vfs"
22 22
 	_ "github.com/docker/docker/daemon/networkdriver/bridge"
23 23
 	"github.com/docker/docker/daemon/networkdriver/portallocator"
24
-	"github.com/docker/docker/daemonconfig"
25 24
 	"github.com/docker/docker/dockerversion"
26 25
 	"github.com/docker/docker/engine"
27 26
 	"github.com/docker/docker/graph"
... ...
@@ -95,7 +94,7 @@ type Daemon struct {
95 95
 	sysInfo        *sysinfo.SysInfo
96 96
 	volumes        *graph.Graph
97 97
 	eng            *engine.Engine
98
-	config         *daemonconfig.Config
98
+	config         *Config
99 99
 	containerGraph *graphdb.Database
100 100
 	driver         graphdriver.Driver
101 101
 	execDriver     execdriver.Driver
... ...
@@ -664,7 +663,7 @@ func (daemon *Daemon) RegisterLinks(container *Container, hostConfig *runconfig.
664 664
 }
665 665
 
666 666
 // FIXME: harmonize with NewGraph()
667
-func NewDaemon(config *daemonconfig.Config, eng *engine.Engine) (*Daemon, error) {
667
+func NewDaemon(config *Config, eng *engine.Engine) (*Daemon, error) {
668 668
 	daemon, err := NewDaemonFromDirectory(config, eng)
669 669
 	if err != nil {
670 670
 		return nil, err
... ...
@@ -672,7 +671,7 @@ func NewDaemon(config *daemonconfig.Config, eng *engine.Engine) (*Daemon, error)
672 672
 	return daemon, nil
673 673
 }
674 674
 
675
-func NewDaemonFromDirectory(config *daemonconfig.Config, eng *engine.Engine) (*Daemon, error) {
675
+func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) {
676 676
 	// Claim the pidfile first, to avoid any and all unexpected race conditions.
677 677
 	// Some of the init doesn't need a pidfile lock - but let's not try to be smart.
678 678
 	if config.Pidfile != "" {
... ...
@@ -1010,7 +1009,7 @@ func (daemon *Daemon) Repositories() *graph.TagStore {
1010 1010
 	return daemon.repositories
1011 1011
 }
1012 1012
 
1013
-func (daemon *Daemon) Config() *daemonconfig.Config {
1013
+func (daemon *Daemon) Config() *Config {
1014 1014
 	return daemon.config
1015 1015
 }
1016 1016
 
1017 1017
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-This directory contains code pertaining to the configuration of the docker daemon
2
-
3
-These are the configuration settings that you pass to the docker daemon when you launch it with say: `docker -d -e lxc`
4 1
deleted file mode 100644
... ...
@@ -1,41 +0,0 @@
1
-package daemonconfig
2
-
3
-import (
4
-	"github.com/docker/docker/daemon/networkdriver"
5
-	"net"
6
-)
7
-
8
-const (
9
-	defaultNetworkMtu    = 1500
10
-	DisableNetworkBridge = "none"
11
-)
12
-
13
-// FIXME: separate runtime configuration from http api configuration
14
-type Config struct {
15
-	Pidfile                     string
16
-	Root                        string
17
-	AutoRestart                 bool
18
-	Dns                         []string
19
-	DnsSearch                   []string
20
-	EnableIptables              bool
21
-	EnableIpForward             bool
22
-	DefaultIp                   net.IP
23
-	BridgeIface                 string
24
-	BridgeIP                    string
25
-	InterContainerCommunication bool
26
-	GraphDriver                 string
27
-	GraphOptions                []string
28
-	ExecDriver                  string
29
-	Mtu                         int
30
-	DisableNetwork              bool
31
-	EnableSelinuxSupport        bool
32
-	Context                     map[string][]string
33
-	Sockets                     []string
34
-}
35
-
36
-func GetDefaultNetworkMtu() int {
37
-	if iface, err := networkdriver.GetDefaultRouteIface(); err == nil {
38
-		return iface.MTU
39
-	}
40
-	return defaultNetworkMtu
41
-}
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"github.com/docker/docker/daemon"
11 11
 	_ "github.com/docker/docker/daemon/execdriver/lxc"
12 12
 	_ "github.com/docker/docker/daemon/execdriver/native"
13
-	"github.com/docker/docker/daemonconfig"
14 13
 	"github.com/docker/docker/dockerversion"
15 14
 	"github.com/docker/docker/engine"
16 15
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -48,8 +47,8 @@ func mainDaemon() {
48 48
 	// the http api so that connections don't fail while the daemon
49 49
 	// is booting
50 50
 	go func() {
51
-		// FIXME: daemonconfig and CLI flag parsing should be directly integrated
52
-		cfg := &daemonconfig.Config{
51
+		// FIXME: daemon config and CLI flag parsing should be directly integrated
52
+		cfg := &daemon.Config{
53 53
 			Pidfile:                     *pidfile,
54 54
 			Root:                        *flRoot,
55 55
 			AutoRestart:                 *flAutoRestart,
... ...
@@ -68,12 +67,12 @@ func mainDaemon() {
68 68
 			Mtu:                         *flMtu,
69 69
 			Sockets:                     flHosts.GetAll(),
70 70
 		}
71
-		// FIXME this should be initialized in NewDaemon or somewhere in daemonconfig.
71
+		// FIXME this should be initialized in NewDaemon or somewhere in daemon.
72 72
 		// Currently it is copy-pasted in `integration` to create test daemons that work.
73 73
 		if cfg.Mtu == 0 {
74
-			cfg.Mtu = daemonconfig.GetDefaultNetworkMtu()
74
+			cfg.Mtu = daemon.GetDefaultNetworkMtu()
75 75
 		}
76
-		cfg.DisableNetwork = cfg.BridgeIface == daemonconfig.DisableNetworkBridge
76
+		cfg.DisableNetwork = cfg.BridgeIface == daemon.DisableNetworkBridge
77 77
 
78 78
 		d, err := daemon.NewDaemon(cfg, eng)
79 79
 		if err != nil {
... ...
@@ -17,7 +17,6 @@ import (
17 17
 
18 18
 	"github.com/docker/docker/builtins"
19 19
 	"github.com/docker/docker/daemon"
20
-	"github.com/docker/docker/daemonconfig"
21 20
 	"github.com/docker/docker/engine"
22 21
 	"github.com/docker/docker/runconfig"
23 22
 	"github.com/docker/docker/utils"
... ...
@@ -179,17 +178,20 @@ func newTestEngine(t utils.Fataler, autorestart bool, root string) *engine.Engin
179 179
 	// Load default plugins
180 180
 	builtins.Register(eng)
181 181
 	// (This is manually copied and modified from main() until we have a more generic plugin system)
182
-	cfg := &daemonconfig.Config{
182
+	cfg := &daemon.Config{
183 183
 		Root:        root,
184 184
 		AutoRestart: autorestart,
185 185
 		ExecDriver:  "native",
186
+		// Either InterContainerCommunication or EnableIptables must be set,
187
+		// otherwise NewDaemon will fail because of conflicting settings.
188
+		InterContainerCommunication: true,
186 189
 	}
187
-	// FIXME: this should be initialized in NewDaemon or somewhere in daemonconfig.
190
+	// FIXME: this should be initialized in NewDaemon
188 191
 	// Currently it is copy-pasted from daemonMain()
189 192
 	if cfg.Mtu == 0 {
190
-		cfg.Mtu = daemonconfig.GetDefaultNetworkMtu()
193
+		cfg.Mtu = daemon.GetDefaultNetworkMtu()
191 194
 	}
192
-	cfg.DisableNetwork = cfg.BridgeIface == daemonconfig.DisableNetworkBridge
195
+	cfg.DisableNetwork = cfg.BridgeIface == daemon.DisableNetworkBridge
193 196
 	d, err := daemon.NewDaemon(cfg, eng)
194 197
 	if err != nil {
195 198
 		t.Fatal(err)