Skip to content

Commit

Permalink
Properly support secundary IP addresses (hashicorp#10420)
Browse files Browse the repository at this point in the history
And remove the deprecated `network_id` field.
  • Loading branch information
Sander van Harmelen authored and Gustavo Mateus committed Dec 6, 2016
1 parent 79d9b36 commit f426bab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
17 changes: 9 additions & 8 deletions builtin/providers/cloudstack/resource_cloudstack_static_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ func resourceCloudStackStaticNAT() *schema.Resource {
ForceNew: true,
},

"network_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "network_id is deprecated and can be safely omitted",
},

"virtual_machine_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -73,10 +66,18 @@ func resourceCloudStackStaticNATCreate(d *schema.ResourceData, meta interface{})
p.SetVmguestip(vmGuestIP.(string))

// Set the network ID based on the guest IP, needed when the public IP address
// is not associated with any network yet (VPC case)
// is not associated with any network yet
NICS:
for _, nic := range vm.Nic {
if vmGuestIP.(string) == nic.Ipaddress {
p.SetNetworkid(nic.Networkid)
break NICS
}
for _, ip := range nic.Secondaryip {
if vmGuestIP.(string) == ip.Ipaddress {
p.SetNetworkid(nic.Networkid)
break NICS
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ The following arguments are supported:
* `ip_address_id` - (Required) The public IP address ID for which static
NAT will be enabled. Changing this forces a new resource to be created.

* `network_id` - (Deprecated) The network ID of the VM the static NAT will be
enabled for. This argument is no longer needed and can be safely omitted.

* `virtual_machine_id` - (Required) The virtual machine ID to enable the
static NAT feature for. Changing this forces a new resource to be created.

Expand Down

0 comments on commit f426bab

Please sign in to comment.