1
0
mirror of https://github.com/rancher/os.git synced 2025-09-05 00:37:12 +00:00

Move in code from netconf and docker-from-scratch

This commit is contained in:
Josh Curl
2016-10-19 16:21:35 -07:00
parent 1f4d23bf50
commit 691f7cb42c
16 changed files with 1567 additions and 38 deletions

View File

@@ -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)
}
}