Permalink
Browse files

Move in code from netconf and docker-from-scratch

  • Loading branch information...
1 parent 1f4d23b commit 691f7cb42c6136af58be7cc41b1d9296e8b3892f @joshwget joshwget committed Oct 19, 2016
@@ -36,9 +36,9 @@ import (
"github.com/coreos/coreos-cloudinit/datasource/proc_cmdline"
"github.com/coreos/coreos-cloudinit/datasource/url"
"github.com/coreos/coreos-cloudinit/pkg"
- "github.com/rancher/netconf"
"github.com/rancher/os/cmd/cloudinitsave/gce"
rancherConfig "github.com/rancher/os/config"
+ "github.com/rancher/os/netconf"
"github.com/rancher/os/util"
)
@@ -231,8 +231,8 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
}
func enableDoLinkLocal() {
- err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{
- Interfaces: map[string]netconf.InterfaceConfig{
+ err := netconf.ApplyNetworkConfigs(&rancherConfig.NetworkConfig{
+ Interfaces: map[string]rancherConfig.InterfaceConfig{
"eth0": {
IPV4LL: true,
},
@@ -12,11 +12,11 @@ import (
"github.com/Sirupsen/logrus"
"github.com/packethost/packngo/metadata"
- "github.com/rancher/netconf"
- rancherConfig "github.com/rancher/os/config"
+ "github.com/rancher/os/config"
+ "github.com/rancher/os/netconf"
)
-func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
+func enablePacketNetwork(cfg *config.RancherConfig) {
bootStrapped := false
for _, v := range cfg.Network.Interfaces {
if v.Address != "" {
@@ -40,7 +40,7 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
return
}
- bondCfg := netconf.InterfaceConfig{
+ bondCfg := config.InterfaceConfig{
Addresses: []string{},
BondOpts: map[string]string{
"lacp_rate": "1",
@@ -51,11 +51,11 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
"mode": "4",
},
}
- netCfg := netconf.NetworkConfig{
- Interfaces: map[string]netconf.InterfaceConfig{},
+ netCfg := config.NetworkConfig{
+ Interfaces: map[string]config.InterfaceConfig{},
}
for _, iface := range m.Network.Interfaces {
- netCfg.Interfaces["mac="+iface.Mac] = netconf.InterfaceConfig{
+ netCfg.Interfaces["mac="+iface.Mac] = config.InterfaceConfig{
Bond: "bond0",
}
}
@@ -80,24 +80,24 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
b, _ := yaml.Marshal(netCfg)
logrus.Debugf("Generated network config: %s", string(b))
- cc := rancherConfig.CloudConfig{
- Rancher: rancherConfig.RancherConfig{
+ cc := config.CloudConfig{
+ Rancher: config.RancherConfig{
Network: netCfg,
},
}
// Post to phone home URL on first boot
- if _, err = os.Stat(rancherConfig.CloudConfigNetworkFile); err != nil {
+ if _, err = os.Stat(config.CloudConfigNetworkFile); err != nil {
if _, err = http.Post(m.PhoneHomeURL, "application/json", bytes.NewReader([]byte{})); err != nil {
logrus.Errorf("Failed to post to Packet phone home URL: %v", err)
}
}
- if err := os.MkdirAll(path.Dir(rancherConfig.CloudConfigNetworkFile), 0700); err != nil {
- logrus.Errorf("Failed to create directory for file %s: %v", rancherConfig.CloudConfigNetworkFile, err)
+ if err := os.MkdirAll(path.Dir(config.CloudConfigNetworkFile), 0700); err != nil {
+ logrus.Errorf("Failed to create directory for file %s: %v", config.CloudConfigNetworkFile, err)
}
- if err := rancherConfig.WriteToFile(cc, rancherConfig.CloudConfigNetworkFile); err != nil {
- logrus.Errorf("Failed to save config file %s: %v", rancherConfig.CloudConfigNetworkFile, err)
+ if err := config.WriteToFile(cc, config.CloudConfigNetworkFile); err != nil {
+ logrus.Errorf("Failed to save config file %s: %v", config.CloudConfigNetworkFile, err)
}
}
@@ -9,10 +9,10 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/docker/libnetwork/resolvconf"
- "github.com/rancher/netconf"
"github.com/rancher/os/config"
"github.com/rancher/os/docker"
"github.com/rancher/os/hostname"
+ "github.com/rancher/os/netconf"
)
var (
View
@@ -7,7 +7,6 @@ import (
"github.com/coreos/coreos-cloudinit/config"
"github.com/docker/engine-api/types"
composeConfig "github.com/docker/libcompose/config"
- "github.com/rancher/netconf"
)
const (
@@ -113,8 +112,8 @@ type RancherConfig struct {
Disable []string `yaml:"disable,omitempty"`
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
Modules []string `yaml:"modules,omitempty"`
- Network netconf.NetworkConfig `yaml:"network,omitempty"`
- DefaultNetwork netconf.NetworkConfig `yaml:"default_network,omitempty"`
+ Network NetworkConfig `yaml:"network,omitempty"`
+ DefaultNetwork NetworkConfig `yaml:"default_network,omitempty"`
Repositories Repositories `yaml:"repositories,omitempty"`
Ssh SshConfig `yaml:"ssh,omitempty"`
State StateConfig `yaml:"state,omitempty"`
@@ -169,6 +168,39 @@ type DockerConfig struct {
Exec bool `yaml:"exec,omitempty"`
}
+type NetworkConfig struct {
+ PreCmds []string `yaml:"pre_cmds,omitempty"`
+ Dns DnsConfig `yaml:"dns,omitempty"`
+ Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
+ PostCmds []string `yaml:"post_cmds,omitempty"`
+ HttpProxy string `yaml:"http_proxy,omitempty"`
+ HttpsProxy string `yaml:"https_proxy,omitempty"`
+ NoProxy string `yaml:"no_proxy,omitempty"`
+}
+
+type InterfaceConfig struct {
+ Match string `yaml:"match,omitempty"`
+ DHCP bool `yaml:"dhcp,omitempty"`
+ DHCPArgs string `yaml:"dhcp_args,omitempty"`
+ Address string `yaml:"address,omitempty"`
+ Addresses []string `yaml:"addresses,omitempty"`
+ IPV4LL bool `yaml:"ipv4ll,omitempty"`
+ Gateway string `yaml:"gateway,omitempty"`
+ GatewayIpv6 string `yaml:"gateway_ipv6,omitempty"`
+ MTU int `yaml:"mtu,omitempty"`
+ Bridge string `yaml:"bridge,omitempty"`
+ Bond string `yaml:"bond,omitempty"`
+ BondOpts map[string]string `yaml:"bond_opts,omitempty"`
+ PostUp []string `yaml:"post_up,omitempty"`
+ PreUp []string `yaml:"pre_up,omitempty"`
+ Vlans string `yaml:"vlans,omitempty"`
+}
+
+type DnsConfig struct {
+ Nameservers []string `yaml:"nameservers,flow,omitempty"`
+ Search []string `yaml:"search,flow,omitempty"`
+}
+
type SshConfig struct {
Keys map[string]string `yaml:"keys,omitempty"`
}
@@ -191,9 +223,9 @@ type CloudInit struct {
}
type Defaults struct {
- Hostname string `yaml:"hostname,omitempty"`
- Docker DockerConfig `yaml:"docker,omitempty"`
- Network netconf.NetworkConfig `yaml:"network,omitempty"`
+ Hostname string `yaml:"hostname,omitempty"`
+ Docker DockerConfig `yaml:"docker,omitempty"`
+ Network NetworkConfig `yaml:"network,omitempty"`
}
func (r Repositories) ToArray() []string {
View
@@ -0,0 +1,24 @@
+// +build linux
+
+package dfs
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+func PidOne() error {
+ c := make(chan os.Signal, 2048)
+ signal.Notify(c, syscall.SIGCHLD)
+
+ for range c {
+ for {
+ if pid, err := syscall.Wait4(-1, nil, syscall.WNOHANG, nil); err != nil || pid <= 0 {
+ break
+ }
+ }
+ }
+
+ return nil
+}
Oops, something went wrong.

0 comments on commit 691f7cb

Please sign in to comment.