diff --git a/cmd/cloudinitsave/packet.go b/cmd/cloudinitsave/packet.go index 23cd2957..6e093907 100644 --- a/cmd/cloudinitsave/packet.go +++ b/cmd/cloudinitsave/packet.go @@ -1,6 +1,7 @@ package cloudinitsave import ( + "bytes" "fmt" "net/http" "os" @@ -76,8 +77,8 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) { } netCfg.Interfaces["bond0"] = bondCfg - bytes, _ := yaml.Marshal(netCfg) - logrus.Debugf("Generated network config: %s", string(bytes)) + b, _ := yaml.Marshal(netCfg) + logrus.Debugf("Generated network config: %s", string(b)) cc := rancherConfig.CloudConfig{ Rancher: rancherConfig.RancherConfig{ @@ -85,6 +86,13 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) { }, } + // Post to phone home URL on first boot + if _, err = os.Stat(rancherConfig.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) } diff --git a/trash.conf b/trash.conf index 2bbb50f3..a39ada32 100644 --- a/trash.conf +++ b/trash.conf @@ -33,7 +33,7 @@ github.com/mattn/go-shellwords v1.0.0 github.com/opencontainers/runc edc34c4a8c1e261b5ce926ff557ecde1aff19ce3 https://github.com/ibuildthecloud/runc.git github.com/opencontainers/runtime-spec f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/opencontainers/specs f955d90e70a98ddfb886bd930ffd076da9b67998 -github.com/packethost/packngo 92012705236896736875186c9e49557897c6af90 https://github.com/ibuildthecloud/packngo.git +github.com/packethost/packngo 7b3a781a3c8c45b0e55390fa3c4d24981402b99f https://github.com/joshwget/packngo.git github.com/pkg/errors d62207b3dc916c342cd6a7180fa861d898cf42ee github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d github.com/rancher/cniglue b56bd68e5df113ad3fcc59c58034c22afaede877 diff --git a/vendor/github.com/packethost/packngo/metadata/metadata.go b/vendor/github.com/packethost/packngo/metadata/metadata.go index edb38fc5..a681f8ce 100644 --- a/vendor/github.com/packethost/packngo/metadata/metadata.go +++ b/vendor/github.com/packethost/packngo/metadata/metadata.go @@ -9,6 +9,7 @@ const ( ) type Metadata struct { + PhoneHomeURL string `json:"phone_home_url"` ApiUrl string `json:"api_url"` Id string `json:"id"` Hostname string `json:"hostname"`