From 6146b61fd4968cf72fca298d2766b21d12fdc323 Mon Sep 17 00:00:00 2001 From: bzub Date: Wed, 6 Sep 2017 10:05:56 -0500 Subject: [PATCH] Use management designation to determine access IPs --- packet/resource_packet_device.go | 19 +++++++++++-------- vendor/github.com/packethost/packngo/ip.go | 2 ++ vendor/vendor.json | 8 +++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packet/resource_packet_device.go b/packet/resource_packet_device.go index fe3e1ee8..363e4506 100644 --- a/packet/resource_packet_device.go +++ b/packet/resource_packet_device.go @@ -295,16 +295,19 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error { } networks = append(networks, network) - if ip.AddressFamily == 4 { - if ip.Public == true { - host = ip.Address - ipv4SubnetSize = ip.CIDR - d.Set("access_public_ipv4", ip.Address) + // Initial device IPs are fixed and marked as "Management" + if ip.Management { + if ip.AddressFamily == 4 { + if ip.Public { + host = ip.Address + ipv4SubnetSize = ip.CIDR + d.Set("access_public_ipv4", ip.Address) + } else { + d.Set("access_private_ipv4", ip.Address) + } } else { - d.Set("access_private_ipv4", ip.Address) + d.Set("access_public_ipv6", ip.Address) } - } else { - d.Set("access_public_ipv6", ip.Address) } } d.Set("network", networks) diff --git a/vendor/github.com/packethost/packngo/ip.go b/vendor/github.com/packethost/packngo/ip.go index 0a57281f..d580f4bc 100644 --- a/vendor/github.com/packethost/packngo/ip.go +++ b/vendor/github.com/packethost/packngo/ip.go @@ -37,6 +37,8 @@ type ipAddressCommon struct { Created string `json:"created_at,omitempty"` Updated string `json:"updated_at,omitempty"` Href string `json:"href"` + Management bool `json:"management"` + Manageable bool `json:"manageable"` } // IPAddressReservation is created when user sends IP reservation request for a project (considering it's within quota). diff --git a/vendor/vendor.json b/vendor/vendor.json index 951a4635..88272cf4 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -620,10 +620,12 @@ "revisionTime": "2016-10-03T17:45:16Z" }, { - "checksumSHA1": "IV/ufjfpq6nYH2v3Y583Nwx3a+8=", + "checksumSHA1": "DxROQsabA/KchJMOyyV92KquswQ=", "path": "github.com/packethost/packngo", - "revision": "36f34102fc1464824b8069cbd65ad5a0185d2dc7", - "revisionTime": "2017-09-01T15:06:29Z" + "revision": "b467bc62ab07434fb341df598ec2c7d9fe2e30d6", + "revisionTime": "2017-09-06T14:46:34Z", + "version": "master", + "versionExact": "master" }, { "checksumSHA1": "rTNABfFJ9wtLQRH8uYNkEZGQOrY=",