2013-10-04 22:25:15 -04:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2013-10-21 12:04:42 -04:00
|
|
|
"github.com/dotcloud/docker/engine"
|
2013-11-07 15:19:24 -05:00
|
|
|
"net"
|
2013-10-04 22:25:15 -04:00
|
|
|
)
|
|
|
|
|
2014-01-29 21:34:43 -05:00
|
|
|
const (
|
|
|
|
DefaultNetworkMtu = 1500
|
|
|
|
DisableNetworkBridge = "none"
|
|
|
|
)
|
|
|
|
|
2013-10-21 12:04:42 -04:00
|
|
|
// FIXME: separate runtime configuration from http api configuration
|
2013-10-04 22:25:15 -04:00
|
|
|
type DaemonConfig struct {
|
2013-10-10 16:48:22 -04:00
|
|
|
Pidfile string
|
2013-10-23 04:09:16 -04:00
|
|
|
Root string
|
2013-10-10 16:48:22 -04:00
|
|
|
AutoRestart bool
|
|
|
|
Dns []string
|
|
|
|
EnableIptables bool
|
2014-01-27 23:35:05 -05:00
|
|
|
EnableIpForward bool
|
2013-10-10 16:48:22 -04:00
|
|
|
DefaultIp net.IP
|
2014-01-29 21:34:43 -05:00
|
|
|
BridgeIface string
|
|
|
|
BridgeIP string
|
2013-10-10 16:48:22 -04:00
|
|
|
InterContainerCommunication bool
|
2013-11-15 02:02:09 -05:00
|
|
|
GraphDriver string
|
2013-12-19 18:16:54 -05:00
|
|
|
Mtu int
|
2014-01-29 21:34:43 -05:00
|
|
|
DisableNetwork bool
|
2013-10-04 22:25:15 -04:00
|
|
|
}
|
2013-10-21 12:04:42 -04:00
|
|
|
|
2013-10-23 04:00:31 -04:00
|
|
|
// ConfigFromJob creates and returns a new DaemonConfig object
|
2013-10-21 12:04:42 -04:00
|
|
|
// by parsing the contents of a job's environment.
|
2014-01-30 15:45:32 -05:00
|
|
|
func DaemonConfigFromJob(job *engine.Job) *DaemonConfig {
|
|
|
|
config := &DaemonConfig{
|
|
|
|
Pidfile: job.Getenv("Pidfile"),
|
|
|
|
Root: job.Getenv("Root"),
|
|
|
|
AutoRestart: job.GetenvBool("AutoRestart"),
|
|
|
|
EnableIptables: job.GetenvBool("EnableIptables"),
|
|
|
|
EnableIpForward: job.GetenvBool("EnableIpForward"),
|
2014-01-29 21:34:43 -05:00
|
|
|
BridgeIP: job.Getenv("BridgeIp"),
|
2014-01-30 15:45:32 -05:00
|
|
|
DefaultIp: net.ParseIP(job.Getenv("DefaultIp")),
|
|
|
|
InterContainerCommunication: job.GetenvBool("InterContainerCommunication"),
|
|
|
|
GraphDriver: job.Getenv("GraphDriver"),
|
|
|
|
}
|
2013-11-22 12:55:27 -05:00
|
|
|
if dns := job.GetenvList("Dns"); dns != nil {
|
|
|
|
config.Dns = dns
|
2013-10-21 12:04:42 -04:00
|
|
|
}
|
2014-01-30 21:06:08 -05:00
|
|
|
if mtu := job.GetenvInt("Mtu"); mtu != 0 {
|
2013-12-19 18:16:54 -05:00
|
|
|
config.Mtu = mtu
|
|
|
|
} else {
|
|
|
|
config.Mtu = DefaultNetworkMtu
|
|
|
|
}
|
2014-01-29 21:34:43 -05:00
|
|
|
config.DisableNetwork = job.Getenv("BridgeIface") == DisableNetworkBridge
|
2014-01-30 15:45:32 -05:00
|
|
|
|
|
|
|
return config
|
2013-10-21 12:04:42 -04:00
|
|
|
}
|