Merge pull request #3948 from pshima/f-packet-net-provisioner-ip
Populate the provisioner connection info for packet.net devices
This commit is contained in:
commit
edaaab9f62
|
@ -184,7 +184,7 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("billing_cycle", device.BillingCycle)
|
||||
d.Set("locked", device.Locked)
|
||||
d.Set("created", device.Created)
|
||||
d.Set("udpated", device.Updated)
|
||||
d.Set("updated", device.Updated)
|
||||
|
||||
tags := make([]string, 0)
|
||||
for _, tag := range device.Tags {
|
||||
|
@ -192,6 +192,8 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
d.Set("tags", tags)
|
||||
|
||||
provisionerAddress := ""
|
||||
|
||||
networks := make([]map[string]interface{}, 0, 1)
|
||||
for _, ip := range device.Network {
|
||||
network := make(map[string]interface{})
|
||||
|
@ -201,9 +203,21 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
network["cidr"] = ip.Cidr
|
||||
network["public"] = ip.Public
|
||||
networks = append(networks, network)
|
||||
if ip.Family == 4 && ip.Public == true {
|
||||
provisionerAddress = ip.Address
|
||||
}
|
||||
}
|
||||
d.Set("network", networks)
|
||||
|
||||
log.Printf("[DEBUG] Provisioner Address set to %v", provisionerAddress)
|
||||
|
||||
if provisionerAddress != "" {
|
||||
d.SetConnInfo(map[string]string{
|
||||
"type": "ssh",
|
||||
"host": provisionerAddress,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue