From a3c6fec4e69100738a165ac068b7ecbf54f785a3 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 29 Nov 2016 20:48:38 +0100 Subject: [PATCH] Properly support secundary IP addresses (#10420) And remove the deprecated `network_id` field. --- .../resource_cloudstack_static_nat.go | 17 +++++++++-------- .../cloudstack/r/static_nat.html.markdown | 3 --- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_static_nat.go b/builtin/providers/cloudstack/resource_cloudstack_static_nat.go index 8f41e05846..bf416c8851 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_static_nat.go +++ b/builtin/providers/cloudstack/resource_cloudstack_static_nat.go @@ -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 { diff --git a/website/source/docs/providers/cloudstack/r/static_nat.html.markdown b/website/source/docs/providers/cloudstack/r/static_nat.html.markdown index 04630fe355..43f6fe7d00 100644 --- a/website/source/docs/providers/cloudstack/r/static_nat.html.markdown +++ b/website/source/docs/providers/cloudstack/r/static_nat.html.markdown @@ -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.