Skip to content

Commit

Permalink
Filter static ip only for secondary_ip_addresses parameter (#110)
Browse files Browse the repository at this point in the history
* Fixed secondary_ip_addresses and secondary_ip_count properties in virtual_guest.
* Updated DiffSuppressFunc to support update in creation.
  • Loading branch information
minsikl authored and renier committed Feb 24, 2017
1 parent 1852722 commit dc263e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion softlayer/resource_softlayer_virtual_guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ func resourceSoftLayerVirtualGuest() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
DiffSuppressFunc: func(k, o, n string, d *schema.ResourceData) bool {
// secondary_ip_count is only used when a virtual_guest resource is created.
if d.State() == nil {
return false
}
return true
},
},

"secondary_ip_addresses": {
Expand Down Expand Up @@ -768,9 +775,13 @@ func resourceSoftLayerVirtualGuestRead(d *schema.ResourceData, meta interface{})
// Read secondary IP addresses
d.Set("secondary_ip_addresses", nil)
if result.PrimaryIpAddress != nil {
// Filter static secondary ip addresses.
staticSubnetFilterStr := fmt.Sprintf("{\"publicSubnets\":{\"endPointIpAddress\":{\"ipAddress\":{\"operation\":\"%s\"}}},"+
"\"publicSubnets\":{\"subnetType\":{\"operation\":\"STATIC_IP_ROUTED\"}}}", *result.PrimaryIpAddress)

secondarySubnetResult, err := services.GetAccountService(meta.(ProviderConfig).SoftLayerSession()).
Mask("ipAddresses[id,ipAddress]").
Filter(filter.Build(filter.Path("publicSubnets.endPointIpAddress.ipAddress").Eq(*result.PrimaryIpAddress))).
Filter(staticSubnetFilterStr).
GetPublicSubnets()
if err != nil {
log.Printf("Error getting secondary Ip addresses: %s", err)
Expand Down

0 comments on commit dc263e9

Please sign in to comment.