1
0
mirror of https://github.com/rancher/os.git synced 2025-07-06 03:26:12 +00:00

Merge pull request #1256 from joshwget/move-packet-datasource

Move Packet datasource from cloud-init-pre to cloud-init
This commit is contained in:
Darren Shepherd 2016-09-30 07:29:39 -07:00 committed by GitHub
commit bdcda45a11
2 changed files with 7 additions and 19 deletions

View File

@ -108,6 +108,11 @@ func currentDatasource() (datasource.Datasource, error) {
}
ds := selectDatasource(dss)
if ds.Type() == "packet-metadata-service" {
enablePacketNetwork(&cfg.Rancher)
}
return ds, nil
}
@ -220,10 +225,9 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
dss = append(dss, gce.NewDatasource("http://metadata.google.internal/"))
}
case "packet":
if !network {
enablePacketNetwork(&cfg.Rancher)
if network {
dss = append(dss, packet.NewDatasource("https://metadata.packet.net/"))
}
dss = append(dss, packet.NewDatasource("https://metadata.packet.net/"))
}
}

View File

@ -16,22 +16,6 @@ import (
)
func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
bootStrapped := false
for _, v := range cfg.Network.Interfaces {
if v.Address != "" {
if err := netconf.ApplyNetworkConfigs(&cfg.Network); err != nil {
logrus.Errorf("Failed to bootstrap network: %v", err)
return
}
bootStrapped = true
break
}
}
if !bootStrapped {
return
}
c := metadata.NewClient(http.DefaultClient)
m, err := c.Metadata.Get()
if err != nil {