From e2ef92f50f514ed88afc3e26c869ccc17fe690ca Mon Sep 17 00:00:00 2001 From: Pete Shima Date: Mon, 16 Nov 2015 21:02:57 -0800 Subject: [PATCH] Populate the provisioner connection info for packet.net devices with the ipv4 public address --- .../providers/packet/resource_packet_device.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builtin/providers/packet/resource_packet_device.go b/builtin/providers/packet/resource_packet_device.go index 6bee26cf9..c7cd777a2 100644 --- a/builtin/providers/packet/resource_packet_device.go +++ b/builtin/providers/packet/resource_packet_device.go @@ -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 }