Skip to content

Commit

Permalink
Merge pull request #3948 from pshima/f-packet-net-provisioner-ip
Browse files Browse the repository at this point in the history
Populate the provisioner connection info for packet.net devices
  • Loading branch information
jen20 committed Nov 17, 2015
2 parents 24ee563 + e2ef92f commit edaaab9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion builtin/providers/packet/resource_packet_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ 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 {
tags = append(tags, tag)
}
d.Set("tags", tags)

provisionerAddress := ""

networks := make([]map[string]interface{}, 0, 1)
for _, ip := range device.Network {
network := make(map[string]interface{})
Expand All @@ -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
}

Expand Down

0 comments on commit edaaab9

Please sign in to comment.