12bd8318 |
package daemonconfig |
1cbdaeba |
import ( |
359b7df5 |
"github.com/dotcloud/docker/daemon/networkdriver" |
4d0a026c |
"github.com/dotcloud/docker/engine" |
ca422476 |
"net" |
1cbdaeba |
)
|
c712e74b |
const ( |
4d0a026c |
defaultNetworkMtu = 1500 |
c712e74b |
DisableNetworkBridge = "none"
)
|
0d1a8251 |
// FIXME: separate runtime configuration from http api configuration |
12bd8318 |
type Config struct { |
ce965b8c |
Pidfile string |
7e691e11 |
Root string |
ce965b8c |
AutoRestart bool
Dns []string |
fbfac21e |
DnsSearch []string |
ce965b8c |
EnableIptables bool |
cabe624c |
EnableIpForward bool |
ce965b8c |
DefaultIp net.IP |
c712e74b |
BridgeIface string
BridgeIP string |
ce965b8c |
InterContainerCommunication bool |
6dbeed89 |
GraphDriver string |
822ea97f |
GraphOptions []string |
5f84d7f3 |
ExecDriver string |
566ff54d |
Mtu int |
c712e74b |
DisableNetwork bool |
82f37b87 |
EnableSelinuxSupport bool |
f0e6e135 |
Context map[string][]string |
1cbdaeba |
} |
0d1a8251 |
|
c542b2f8 |
// ConfigFromJob creates and returns a new DaemonConfig object |
0d1a8251 |
// by parsing the contents of a job's environment. |
12bd8318 |
func ConfigFromJob(job *engine.Job) *Config {
config := &Config{ |
9261511a |
Pidfile: job.Getenv("Pidfile"),
Root: job.Getenv("Root"),
AutoRestart: job.GetenvBool("AutoRestart"),
EnableIptables: job.GetenvBool("EnableIptables"),
EnableIpForward: job.GetenvBool("EnableIpForward"), |
cb3bd916 |
BridgeIP: job.Getenv("BridgeIP"), |
347dc394 |
BridgeIface: job.Getenv("BridgeIface"), |
9261511a |
DefaultIp: net.ParseIP(job.Getenv("DefaultIp")),
InterContainerCommunication: job.GetenvBool("InterContainerCommunication"),
GraphDriver: job.Getenv("GraphDriver"), |
5f84d7f3 |
ExecDriver: job.Getenv("ExecDriver"), |
b7942ec2 |
EnableSelinuxSupport: job.GetenvBool("EnableSelinuxSupport"), |
9261511a |
} |
822ea97f |
if graphOpts := job.GetenvList("GraphOptions"); graphOpts != nil {
config.GraphOptions = graphOpts
}
|
3cd9b2aa |
if dns := job.GetenvList("Dns"); dns != nil {
config.Dns = dns |
0d1a8251 |
} |
fbfac21e |
if dnsSearch := job.GetenvList("DnsSearch"); dnsSearch != nil {
config.DnsSearch = dnsSearch
} |
28b5ae8c |
if mtu := job.GetenvInt("Mtu"); mtu != 0 { |
566ff54d |
config.Mtu = mtu
} else { |
92e61f89 |
config.Mtu = GetDefaultNetworkMtu() |
566ff54d |
} |
347dc394 |
config.DisableNetwork = config.BridgeIface == DisableNetworkBridge |
9261511a |
return config |
0d1a8251 |
} |
4d0a026c |
func GetDefaultNetworkMtu() int {
if iface, err := networkdriver.GetDefaultRouteIface(); err == nil {
return iface.MTU
}
return defaultNetworkMtu
} |