From 275d8b0ffe5853729154276d9ccad324f9610fa7 Mon Sep 17 00:00:00 2001 From: Ashleigh Crosby Date: Thu, 27 Mar 2025 11:52:19 +0000 Subject: [PATCH 1/3] add bypass_vlan_check to network and private_gateway --- cloudstack/resource_cloudstack_network.go | 9 +++++++++ cloudstack/resource_cloudstack_private_gateway.go | 7 +++++++ .../resource_cloudstack_private_gateway_test.go | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/cloudstack/resource_cloudstack_network.go b/cloudstack/resource_cloudstack_network.go index e7329f82..da5c928d 100644 --- a/cloudstack/resource_cloudstack_network.go +++ b/cloudstack/resource_cloudstack_network.go @@ -153,6 +153,12 @@ func resourceCloudStackNetwork() *schema.Resource { ForceNew: true, }, + "bypass_vlan_check": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "tags": tagsSchema(), }, } @@ -218,6 +224,9 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e p.SetVlan(strconv.Itoa(vlan.(int))) } + // Bypass VLAN overlap check if necessary + p.SetBypassvlanoverlapcheck(d.Get("bypass_vlan_check").(bool)) + // Check is this network needs to be created in a VPC if vpcid, ok := d.GetOk("vpc_id"); ok { // Set the vpc id diff --git a/cloudstack/resource_cloudstack_private_gateway.go b/cloudstack/resource_cloudstack_private_gateway.go index 6d4e0078..e923093b 100644 --- a/cloudstack/resource_cloudstack_private_gateway.go +++ b/cloudstack/resource_cloudstack_private_gateway.go @@ -85,6 +85,12 @@ func resourceCloudStackPrivateGateway() *schema.Resource { Required: true, ForceNew: true, }, + + "bypass_vlan_check": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, }, } } @@ -103,6 +109,7 @@ func resourceCloudStackPrivateGatewayCreate(d *schema.ResourceData, meta interfa d.Get("vpc_id").(string), ) p.SetVlan(d.Get("vlan").(string)) + p.SetBypassvlanoverlapcheck(d.Get("bypass_vlan_check").(bool)) // Retrieve the network_offering ID if networkofferingid != "" { diff --git a/cloudstack/resource_cloudstack_private_gateway_test.go b/cloudstack/resource_cloudstack_private_gateway_test.go index a20a8141..96c3da3c 100644 --- a/cloudstack/resource_cloudstack_private_gateway_test.go +++ b/cloudstack/resource_cloudstack_private_gateway_test.go @@ -159,4 +159,15 @@ resource "cloudstack_private_gateway" "foo" { vpc_id = cloudstack_vpc.foo.id acl_id = cloudstack_network_acl.foo.id depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo"] +} + +resource "cloudstack_private_gateway" "bar" { + gateway = "10.1.1.253" + ip_address = "192.168.0.2" + netmask = "255.255.255.0" + vlan = "1" + vpc_id = cloudstack_vpc.foo.id + acl_id = cloudstack_network_acl.foo.id + bypass_vlan_check = true + depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo","cloudstack_private_gateway.foo"] }` From 416353d38873c752502afda47b00ec3a954cad06 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Mon, 17 Aug 2026 17:01:30 +0530 Subject: [PATCH 2/3] Remove duplicate bypass_vlan_check from private gateway, fix network import test The merge with main pulled in bypass_vlan_overlap_check (added separately in #283), which duplicates this branch's own bypass_vlan_check field on cloudstack_private_gateway. Drop the stale duplicate and the overlapping test resource that relied on it, and ignore bypass_vlan_check on network import since CloudStack's network API never returns it. --- cloudstack/resource_cloudstack_network_test.go | 16 +++++++++------- .../resource_cloudstack_private_gateway.go | 7 ------- .../resource_cloudstack_private_gateway_test.go | 11 ----------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/cloudstack/resource_cloudstack_network_test.go b/cloudstack/resource_cloudstack_network_test.go index 044ac889..c09c0edd 100644 --- a/cloudstack/resource_cloudstack_network_test.go +++ b/cloudstack/resource_cloudstack_network_test.go @@ -171,9 +171,10 @@ func TestAccCloudStackNetwork_import(t *testing.T) { }, { - ResourceName: "cloudstack_network.foo", - ImportState: true, - ImportStateVerify: true, + ResourceName: "cloudstack_network.foo", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"bypass_vlan_check"}, }, }, }) @@ -190,10 +191,11 @@ func TestAccCloudStackNetwork_importProject(t *testing.T) { }, { - ResourceName: "cloudstack_network.foo", - ImportState: true, - ImportStateIdPrefix: "terraform/", - ImportStateVerify: true, + ResourceName: "cloudstack_network.foo", + ImportState: true, + ImportStateIdPrefix: "terraform/", + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"bypass_vlan_check"}, }, }, }) diff --git a/cloudstack/resource_cloudstack_private_gateway.go b/cloudstack/resource_cloudstack_private_gateway.go index 20d9647e..c2123a15 100644 --- a/cloudstack/resource_cloudstack_private_gateway.go +++ b/cloudstack/resource_cloudstack_private_gateway.go @@ -86,12 +86,6 @@ func resourceCloudStackPrivateGateway() *schema.Resource { ForceNew: true, }, - "bypass_vlan_check": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - "bypass_vlan_overlap_check": { Type: schema.TypeBool, Optional: true, @@ -115,7 +109,6 @@ func resourceCloudStackPrivateGatewayCreate(d *schema.ResourceData, meta interfa d.Get("vpc_id").(string), ) p.SetVlan(d.Get("vlan").(string)) - p.SetBypassvlanoverlapcheck(d.Get("bypass_vlan_check").(bool)) // Retrieve the network_offering ID if networkofferingid != "" { diff --git a/cloudstack/resource_cloudstack_private_gateway_test.go b/cloudstack/resource_cloudstack_private_gateway_test.go index 916e40c5..058cce90 100644 --- a/cloudstack/resource_cloudstack_private_gateway_test.go +++ b/cloudstack/resource_cloudstack_private_gateway_test.go @@ -202,17 +202,6 @@ resource "cloudstack_private_gateway" "foo" { vpc_id = cloudstack_vpc.foo.id acl_id = cloudstack_network_acl.foo.id depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo"] -} - -resource "cloudstack_private_gateway" "bar" { - gateway = "10.1.1.253" - ip_address = "192.168.0.2" - netmask = "255.255.255.0" - vlan = "1" - vpc_id = cloudstack_vpc.foo.id - acl_id = cloudstack_network_acl.foo.id - bypass_vlan_check = true - depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo","cloudstack_private_gateway.foo"] }` const testAccCloudStackPrivateGateway_bypassVlanOverlapCheck = ` From 98bb7aa11ec90da4e4dbefd30c5df597d95a5087 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Mon, 17 Aug 2026 17:12:49 +0530 Subject: [PATCH 3/3] Rename network's bypass_vlan_check to bypass_vlan_overlap_check Issue #160 asked for the actual CloudStack API attribute (bypassvlanoverlapcheck), and the private gateway resource already exposes it under that name. The network resource introduced a differently-named field for the same underlying parameter; align the name and only send it to the API when explicitly set, matching the private gateway resource's pattern. --- cloudstack/resource_cloudstack_network.go | 6 ++++-- cloudstack/resource_cloudstack_network_test.go | 4 ++-- website/docs/r/network.html.markdown | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cloudstack/resource_cloudstack_network.go b/cloudstack/resource_cloudstack_network.go index 2d55dcd1..1aebe76e 100644 --- a/cloudstack/resource_cloudstack_network.go +++ b/cloudstack/resource_cloudstack_network.go @@ -204,7 +204,7 @@ func resourceCloudStackNetwork() *schema.Resource { ForceNew: true, }, - "bypass_vlan_check": { + "bypass_vlan_overlap_check": { Type: schema.TypeBool, Optional: true, Default: false, @@ -303,7 +303,9 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e } // Bypass VLAN overlap check if necessary - p.SetBypassvlanoverlapcheck(d.Get("bypass_vlan_check").(bool)) + if bypassVlanOverlapCheck, ok := d.GetOk("bypass_vlan_overlap_check"); ok { + p.SetBypassvlanoverlapcheck(bypassVlanOverlapCheck.(bool)) + } // Check is this network needs to be created in a VPC if vpcid, ok := d.GetOk("vpc_id"); ok { diff --git a/cloudstack/resource_cloudstack_network_test.go b/cloudstack/resource_cloudstack_network_test.go index c09c0edd..6fc82ac5 100644 --- a/cloudstack/resource_cloudstack_network_test.go +++ b/cloudstack/resource_cloudstack_network_test.go @@ -174,7 +174,7 @@ func TestAccCloudStackNetwork_import(t *testing.T) { ResourceName: "cloudstack_network.foo", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"bypass_vlan_check"}, + ImportStateVerifyIgnore: []string{"bypass_vlan_overlap_check"}, }, }, }) @@ -195,7 +195,7 @@ func TestAccCloudStackNetwork_importProject(t *testing.T) { ImportState: true, ImportStateIdPrefix: "terraform/", ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"bypass_vlan_check"}, + ImportStateVerifyIgnore: []string{"bypass_vlan_overlap_check"}, }, }, }) diff --git a/website/docs/r/network.html.markdown b/website/docs/r/network.html.markdown index 72f6d568..4adae633 100644 --- a/website/docs/r/network.html.markdown +++ b/website/docs/r/network.html.markdown @@ -126,7 +126,7 @@ The following arguments are supported: * `zone` - (Required) The name or ID of the zone where this network will be available. Changing this forces a new resource to be created. -* `bypass_vlan_check` - (Optional) if set to `true` it bypasses VLAN id/range overlap +* `bypass_vlan_overlap_check` - (Optional) if set to `true` it bypasses VLAN id/range overlap check during network creation for shared and L2 networks