Properly support secundary IP addresses (#10420)

And remove the deprecated `network_id` field.
This commit is contained in:
Sander van Harmelen 2016-11-29 20:48:38 +01:00 committed by GitHub
parent facce6816f
commit a3c6fec4e6
2 changed files with 9 additions and 11 deletions

View File

@ -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,
@ -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 {

View File

@ -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.