mirror of
https://github.com/rancher/os.git
synced 2025-08-09 18:48:05 +00:00
remove the non-network cloud-init option
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
4126cdbba7
commit
00af8545d6
@ -62,7 +62,7 @@ func Main() {
|
|||||||
cfg := rancherConfig.LoadConfig()
|
cfg := rancherConfig.LoadConfig()
|
||||||
network.ApplyNetworkConfig(cfg)
|
network.ApplyNetworkConfig(cfg)
|
||||||
|
|
||||||
if err := SaveCloudConfig(true); err != nil {
|
if err := SaveCloudConfig(); err != nil {
|
||||||
log.Errorf("Failed to save cloud-config: %v", err)
|
log.Errorf("Failed to save cloud-config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,11 +72,11 @@ func Main() {
|
|||||||
network.ApplyNetworkConfig(cfg)
|
network.ApplyNetworkConfig(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveCloudConfig(network bool) error {
|
func SaveCloudConfig() error {
|
||||||
log.Debugf("SaveCloudConfig")
|
log.Debugf("SaveCloudConfig")
|
||||||
cfg := rancherConfig.LoadConfig()
|
cfg := rancherConfig.LoadConfig()
|
||||||
|
|
||||||
dss := getDatasources(cfg, network)
|
dss := getDatasources(cfg)
|
||||||
if len(dss) == 0 {
|
if len(dss) == 0 {
|
||||||
log.Errorf("currentDatasource - none found")
|
log.Errorf("currentDatasource - none found")
|
||||||
return nil
|
return nil
|
||||||
@ -88,6 +88,7 @@ func SaveCloudConfig(network bool) error {
|
|||||||
|
|
||||||
func RequiresNetwork(datasource string) bool {
|
func RequiresNetwork(datasource string) bool {
|
||||||
// TODO: move into the datasources (and metadatasources)
|
// TODO: move into the datasources (and metadatasources)
|
||||||
|
// and then we can enable that platforms defaults..
|
||||||
parts := strings.SplitN(datasource, ":", 2)
|
parts := strings.SplitN(datasource, ":", 2)
|
||||||
requiresNetwork, ok := map[string]bool{
|
requiresNetwork, ok := map[string]bool{
|
||||||
"ec2": true,
|
"ec2": true,
|
||||||
@ -208,7 +209,7 @@ func fetchAndSave(ds datasource.Datasource) error {
|
|||||||
|
|
||||||
// getDatasources creates a slice of possible Datasources for cloudinit based
|
// getDatasources creates a slice of possible Datasources for cloudinit based
|
||||||
// on the different source command-line flags.
|
// on the different source command-line flags.
|
||||||
func getDatasources(cfg *rancherConfig.CloudConfig, network bool) []datasource.Datasource {
|
func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
|
||||||
dss := make([]datasource.Datasource, 0, 5)
|
dss := make([]datasource.Datasource, 0, 5)
|
||||||
|
|
||||||
for _, ds := range cfg.Rancher.CloudInit.Datasources {
|
for _, ds := range cfg.Rancher.CloudInit.Datasources {
|
||||||
@ -221,43 +222,29 @@ func getDatasources(cfg *rancherConfig.CloudConfig, network bool) []datasource.D
|
|||||||
|
|
||||||
switch parts[0] {
|
switch parts[0] {
|
||||||
case "ec2":
|
case "ec2":
|
||||||
if network {
|
dss = append(dss, ec2.NewDatasource(root))
|
||||||
dss = append(dss, ec2.NewDatasource(root))
|
|
||||||
}
|
|
||||||
case "file":
|
case "file":
|
||||||
if root != "" {
|
if root != "" {
|
||||||
dss = append(dss, file.NewDatasource(root))
|
dss = append(dss, file.NewDatasource(root))
|
||||||
}
|
}
|
||||||
case "url":
|
case "url":
|
||||||
if network {
|
if root != "" {
|
||||||
if root != "" {
|
dss = append(dss, url.NewDatasource(root))
|
||||||
dss = append(dss, url.NewDatasource(root))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "cmdline":
|
case "cmdline":
|
||||||
if network {
|
if len(parts) == 1 {
|
||||||
if len(parts) == 1 {
|
dss = append(dss, proccmdline.NewDatasource())
|
||||||
dss = append(dss, proccmdline.NewDatasource())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "configdrive":
|
case "configdrive":
|
||||||
if root != "" {
|
if root != "" {
|
||||||
dss = append(dss, configdrive.NewDatasource(root))
|
dss = append(dss, configdrive.NewDatasource(root))
|
||||||
}
|
}
|
||||||
case "digitalocean":
|
case "digitalocean":
|
||||||
if network {
|
// TODO: should we enableDoLinkLocal() - to avoid the need for the other kernel/oem options?
|
||||||
dss = append(dss, digitalocean.NewDatasource(root))
|
dss = append(dss, digitalocean.NewDatasource(root))
|
||||||
} else {
|
|
||||||
enableDoLinkLocal()
|
|
||||||
}
|
|
||||||
case "gce":
|
case "gce":
|
||||||
if network {
|
dss = append(dss, gce.NewDatasource(root))
|
||||||
dss = append(dss, gce.NewDatasource(root))
|
|
||||||
}
|
|
||||||
case "packet":
|
case "packet":
|
||||||
if !network {
|
|
||||||
enablePacketNetwork(&cfg.Rancher)
|
|
||||||
}
|
|
||||||
dss = append(dss, packet.NewDatasource(root))
|
dss = append(dss, packet.NewDatasource(root))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package cloudinitsave
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rancher/os/log"
|
|
||||||
|
|
||||||
"github.com/rancher/os/config"
|
|
||||||
"github.com/rancher/os/netconf"
|
|
||||||
)
|
|
||||||
|
|
||||||
func enablePacketNetwork(cfg *config.RancherConfig) {
|
|
||||||
bootStrapped := false
|
|
||||||
for _, v := range cfg.Network.Interfaces {
|
|
||||||
if v.Address != "" {
|
|
||||||
if err := netconf.ApplyNetworkConfigs(&cfg.Network); err != nil {
|
|
||||||
log.Errorf("Failed to bootstrap network: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
bootStrapped = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !bootStrapped {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post to phone home URL on first boot
|
|
||||||
/*
|
|
||||||
// TODO: bring this back
|
|
||||||
if _, err = os.Stat(config.CloudConfigNetworkFile); err != nil {
|
|
||||||
if _, err = http.Post(m.PhoneHomeURL, "application/json", bytes.NewReader([]byte{})); err != nil {
|
|
||||||
log.Errorf("Failed to post to Packet phone home URL: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
cc := config.CloudConfig{
|
|
||||||
Rancher: config.RancherConfig{
|
|
||||||
Network: netCfg,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.MkdirAll(path.Dir(config.CloudConfigNetworkFile), 0700); err != nil {
|
|
||||||
log.Errorf("Failed to create directory for file %s: %v", config.CloudConfigNetworkFile, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := config.WriteToFile(cc, config.CloudConfigNetworkFile); err != nil {
|
|
||||||
log.Errorf("Failed to save config file %s: %v", config.CloudConfigNetworkFile, err)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user