mirror of
https://github.com/rancher/os.git
synced 2025-09-07 17:54:57 +00:00
Add digitalocean cloud-init datasource
This commit is contained in:
@@ -29,12 +29,14 @@ import (
|
|||||||
"github.com/coreos/coreos-cloudinit/datasource"
|
"github.com/coreos/coreos-cloudinit/datasource"
|
||||||
"github.com/coreos/coreos-cloudinit/datasource/configdrive"
|
"github.com/coreos/coreos-cloudinit/datasource/configdrive"
|
||||||
"github.com/coreos/coreos-cloudinit/datasource/file"
|
"github.com/coreos/coreos-cloudinit/datasource/file"
|
||||||
|
"github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean"
|
||||||
"github.com/coreos/coreos-cloudinit/datasource/metadata/ec2"
|
"github.com/coreos/coreos-cloudinit/datasource/metadata/ec2"
|
||||||
"github.com/coreos/coreos-cloudinit/datasource/proc_cmdline"
|
"github.com/coreos/coreos-cloudinit/datasource/proc_cmdline"
|
||||||
"github.com/coreos/coreos-cloudinit/datasource/url"
|
"github.com/coreos/coreos-cloudinit/datasource/url"
|
||||||
"github.com/coreos/coreos-cloudinit/initialize"
|
"github.com/coreos/coreos-cloudinit/initialize"
|
||||||
"github.com/coreos/coreos-cloudinit/pkg"
|
"github.com/coreos/coreos-cloudinit/pkg"
|
||||||
"github.com/coreos/coreos-cloudinit/system"
|
"github.com/coreos/coreos-cloudinit/system"
|
||||||
|
rancherNetwork "github.com/rancherio/os/cmd/network"
|
||||||
rancherConfig "github.com/rancherio/os/config"
|
rancherConfig "github.com/rancherio/os/config"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@@ -199,7 +201,6 @@ func Main() {
|
|||||||
}
|
}
|
||||||
log.Printf("Wrote file %s to filesystem", fullPath)
|
log.Printf("Wrote file %s to filesystem", fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mergeConfigs merges certain options from md (meta-data from the datasource)
|
// mergeConfigs merges certain options from md (meta-data from the datasource)
|
||||||
@@ -266,12 +267,35 @@ func getDatasources(cfg *rancherConfig.Config) []datasource.Datasource {
|
|||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
dss = append(dss, configdrive.NewDatasource(parts[1]))
|
dss = append(dss, configdrive.NewDatasource(parts[1]))
|
||||||
}
|
}
|
||||||
|
case "digitalocean":
|
||||||
|
if network {
|
||||||
|
if len(parts) == 1 {
|
||||||
|
dss = append(dss, digitalocean.NewDatasource(digitalocean.DefaultAddress))
|
||||||
|
} else {
|
||||||
|
dss = append(dss, digitalocean.NewDatasource(parts[1]))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enableDoLinkLocal()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dss
|
return dss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func enableDoLinkLocal() {
|
||||||
|
err := rancherNetwork.ApplyNetworkConfigs(&rancherConfig.NetworkConfig{
|
||||||
|
Interfaces: map[string]rancherConfig.InterfaceConfig{
|
||||||
|
"eth0": {
|
||||||
|
IPV4LL: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to apply link local on eth0: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// selectDatasource attempts to choose a valid Datasource to use based on its
|
// selectDatasource attempts to choose a valid Datasource to use based on its
|
||||||
// current availability. The first Datasource to report to be available is
|
// current availability. The first Datasource to report to be available is
|
||||||
// returned. Datasources will be retried if possible if they are not
|
// returned. Datasources will be retried if possible if they are not
|
||||||
|
Reference in New Issue
Block a user