Skip to content

Commit 0883a73

Browse files
add catalystcenter_fabric_ewlc resource to enable fabric embedded wireless capabilities on switch devices (#303)
1 parent 8e8bba8 commit 0883a73

File tree

13 files changed

+605
-8
lines changed

13 files changed

+605
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.2 (unreleased)
2+
3+
- Add `catalystcenter_fabric_ewlc` resource to enable fabric embedded wireless capabilities on switch devices
4+
15
## 0.4.1
26

37
- Add `catalystcenter_provision_access_points` resource to provision multiple access points within single resource

docs/guides/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ description: |-
77

88
# Changelog
99

10+
## 0.4.2 (unreleased)
11+
12+
- Add `catalystcenter_fabric_ewlc` resource to enable fabric embedded wireless capabilities on switch devices
13+
1014
## 0.4.1
1115

1216
- Add `catalystcenter_provision_access_points` resource to provision multiple access points within single resource

docs/resources/fabric_ewlc.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "catalystcenter_fabric_ewlc Resource - terraform-provider-catalystcenter"
4+
subcategory: "SDA"
5+
description: |-
6+
This resource is used to enable or disable fabric embedded wireless capabilities on switch devices, along with configuring rolling AP upgrades on the fabric site. Reboot action is required to remove wireless configurations.
7+
---
8+
9+
# catalystcenter_fabric_ewlc (Resource)
10+
11+
This resource is used to enable or disable fabric embedded wireless capabilities on switch devices, along with configuring rolling AP upgrades on the fabric site. Reboot action is required to remove wireless configurations.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "catalystcenter_fabric_ewlc" "example" {
17+
fabric_id = "8e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
18+
network_device_id = "12345678-1234-1234-1234-123456789012"
19+
enable_wireless = true
20+
enable_rolling_ap_upgrade = false
21+
ap_reboot_percentage = 25
22+
}
23+
```
24+
25+
<!-- schema generated by tfplugindocs -->
26+
## Schema
27+
28+
### Required
29+
30+
- `enable_wireless` (Boolean) Flag to enable or disable embedded wireless capabilities
31+
- `fabric_id` (String) Fabric Site ID
32+
- `network_device_id` (String) Network Device ID of the wireless capable switch
33+
34+
### Optional
35+
36+
- `ap_reboot_percentage` (Number) Percentage of APs to reboot during rolling upgrade
37+
- Choices: `5`, `15`, `25`
38+
- `enable_rolling_ap_upgrade` (Boolean) Flag to enable or disable rolling AP upgrades
39+
40+
### Read-Only
41+
42+
- `id` (String) The id of the object

docs/resources/provision_access_points.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ resource "catalystcenter_provision_access_points" "example" {
3030

3131
- `network_devices` (Attributes Set) List of access points to be provisioned (see [below for nested schema](#nestedatt--network_devices))
3232
- `rf_profile_name` (String) RF Profile Name. RF Profile is not allowed for custom AP Zones.
33-
- Choices: `LOW`, `TYPICAL`, `HIGH`
3433
- `site_id` (String) ID of the site this network device needs to be provisioned
3534

3635
### Optional
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "catalystcenter_fabric_ewlc" "example" {
2+
fabric_id = "8e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
3+
network_device_id = "12345678-1234-1234-1234-123456789012"
4+
enable_wireless = true
5+
enable_rolling_ap_upgrade = false
6+
ap_reboot_percentage = 25
7+
}

gen/definitions/fabric_ewlc.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Fabric EWLC
3+
rest_endpoint: /dna/intent/api/v1/sda/fabrics/%v/switchWirelessSetting
4+
get_rest_endpoint: /dna/intent/api/v1/sda/fabricDevices
5+
res_description: This resource is used to enable or disable fabric embedded wireless capabilities on switch devices, along with configuring rolling AP upgrades on the fabric site. Reboot action is required to remove wireless configurations.
6+
no_import: true
7+
no_read: true
8+
delete_no_id: true
9+
no_data_source: true
10+
put_create: true
11+
put_delete: true
12+
mutex: true
13+
device_unreachability_warning: true
14+
doc_category: SDA
15+
test_tags: [SDA]
16+
attributes:
17+
- model_name: fabricId
18+
type: String
19+
reference: true
20+
query_param: true
21+
example: 8e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1
22+
description: Fabric Site ID
23+
- model_name: id
24+
tf_name: network_device_id
25+
query_param_name: networkDeviceId
26+
type: String
27+
query_param: true
28+
id: true
29+
description: Network Device ID of the wireless capable switch
30+
example: 12345678-1234-1234-1234-123456789012
31+
- model_name: enableWireless
32+
mandatory: true
33+
type: Bool
34+
description: Flag to enable or disable embedded wireless capabilities
35+
example: true
36+
- model_name: enableRollingApUpgrade
37+
tf_name: enable_rolling_ap_upgrade
38+
type: Bool
39+
data_path: rollingApUpgrade
40+
description: Flag to enable or disable rolling AP upgrades
41+
example: false
42+
- model_name: apRebootPercentage
43+
tf_name: ap_reboot_percentage
44+
type: Int64
45+
enum_values: [5, 15, 25]
46+
data_path: rollingApUpgrade
47+
description: Percentage of APs to reboot during rolling upgrade
48+
example: 25

gen/definitions/provision_access_points.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ attributes:
4242
mandatory: true
4343
description: RF Profile Name. RF Profile is not allowed for custom AP Zones.
4444
type: String
45-
enum_values: [LOW, TYPICAL, HIGH]
4645
example: TYPICAL
4746
- model_name: apZoneName
4847
requires_replace: true
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
2+
// All rights reserved.
3+
//
4+
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://mozilla.org/MPL/2.0/
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
// SPDX-License-Identifier: MPL-2.0
17+
18+
package provider
19+
20+
// Section below is generated&owned by "gen/generator.go". //template:begin imports
21+
import (
22+
"context"
23+
"fmt"
24+
"net/url"
25+
26+
"github.com/hashicorp/terraform-plugin-framework/types"
27+
"github.com/tidwall/gjson"
28+
"github.com/tidwall/sjson"
29+
)
30+
31+
// End of section. //template:end imports
32+
33+
// Section below is generated&owned by "gen/generator.go". //template:begin types
34+
type FabricEWLC struct {
35+
Id types.String `tfsdk:"id"`
36+
FabricId types.String `tfsdk:"fabric_id"`
37+
NetworkDeviceId types.String `tfsdk:"network_device_id"`
38+
EnableWireless types.Bool `tfsdk:"enable_wireless"`
39+
EnableRollingApUpgrade types.Bool `tfsdk:"enable_rolling_ap_upgrade"`
40+
ApRebootPercentage types.Int64 `tfsdk:"ap_reboot_percentage"`
41+
}
42+
43+
// End of section. //template:end types
44+
45+
// Section below is generated&owned by "gen/generator.go". //template:begin getPath
46+
func (data FabricEWLC) getPath() string {
47+
return fmt.Sprintf("/dna/intent/api/v1/sda/fabrics/%v/switchWirelessSetting", url.QueryEscape(data.FabricId.ValueString()))
48+
}
49+
50+
// End of section. //template:end getPath
51+
52+
// Section below is generated&owned by "gen/generator.go". //template:begin getFallbackPath
53+
func (data FabricEWLC) getFallbackPath() string {
54+
return fmt.Sprintf("", url.QueryEscape(data.FabricId.ValueString()))
55+
}
56+
57+
// End of section. //template:end getFallbackPath
58+
59+
// Section below is generated&owned by "gen/generator.go". //template:begin getPathDelete
60+
61+
// End of section. //template:end getPathDelete
62+
63+
// Section below is generated&owned by "gen/generator.go". //template:begin toBody
64+
func (data FabricEWLC) toBody(ctx context.Context, state FabricEWLC) string {
65+
body := ""
66+
put := false
67+
if state.Id.ValueString() != "" {
68+
put = true
69+
}
70+
_ = put
71+
if !data.NetworkDeviceId.IsNull() {
72+
body, _ = sjson.Set(body, "id", data.NetworkDeviceId.ValueString())
73+
}
74+
if !data.EnableWireless.IsNull() {
75+
body, _ = sjson.Set(body, "enableWireless", data.EnableWireless.ValueBool())
76+
}
77+
if !data.EnableRollingApUpgrade.IsNull() {
78+
body, _ = sjson.Set(body, "rollingApUpgrade.enableRollingApUpgrade", data.EnableRollingApUpgrade.ValueBool())
79+
}
80+
if !data.ApRebootPercentage.IsNull() {
81+
body, _ = sjson.Set(body, "rollingApUpgrade.apRebootPercentage", data.ApRebootPercentage.ValueInt64())
82+
}
83+
return body
84+
}
85+
86+
// End of section. //template:end toBody
87+
88+
// Section below is generated&owned by "gen/generator.go". //template:begin fromBody
89+
func (data *FabricEWLC) fromBody(ctx context.Context, res gjson.Result) {
90+
if value := res.Get("id"); value.Exists() {
91+
data.NetworkDeviceId = types.StringValue(value.String())
92+
} else {
93+
data.NetworkDeviceId = types.StringNull()
94+
}
95+
if value := res.Get("enableWireless"); value.Exists() {
96+
data.EnableWireless = types.BoolValue(value.Bool())
97+
} else {
98+
data.EnableWireless = types.BoolNull()
99+
}
100+
if value := res.Get("rollingApUpgrade.enableRollingApUpgrade"); value.Exists() {
101+
data.EnableRollingApUpgrade = types.BoolValue(value.Bool())
102+
} else {
103+
data.EnableRollingApUpgrade = types.BoolNull()
104+
}
105+
if value := res.Get("rollingApUpgrade.apRebootPercentage"); value.Exists() {
106+
data.ApRebootPercentage = types.Int64Value(value.Int())
107+
} else {
108+
data.ApRebootPercentage = types.Int64Null()
109+
}
110+
}
111+
112+
// End of section. //template:end fromBody
113+
114+
// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody
115+
func (data *FabricEWLC) updateFromBody(ctx context.Context, res gjson.Result) {
116+
if value := res.Get("id"); value.Exists() && !data.NetworkDeviceId.IsNull() {
117+
data.NetworkDeviceId = types.StringValue(value.String())
118+
} else {
119+
data.NetworkDeviceId = types.StringNull()
120+
}
121+
if value := res.Get("enableWireless"); value.Exists() && !data.EnableWireless.IsNull() {
122+
data.EnableWireless = types.BoolValue(value.Bool())
123+
} else {
124+
data.EnableWireless = types.BoolNull()
125+
}
126+
if value := res.Get("rollingApUpgrade.enableRollingApUpgrade"); value.Exists() && !data.EnableRollingApUpgrade.IsNull() {
127+
data.EnableRollingApUpgrade = types.BoolValue(value.Bool())
128+
} else {
129+
data.EnableRollingApUpgrade = types.BoolNull()
130+
}
131+
if value := res.Get("rollingApUpgrade.apRebootPercentage"); value.Exists() && !data.ApRebootPercentage.IsNull() {
132+
data.ApRebootPercentage = types.Int64Value(value.Int())
133+
} else {
134+
data.ApRebootPercentage = types.Int64Null()
135+
}
136+
}
137+
138+
// End of section. //template:end updateFromBody
139+
140+
// Section below is generated&owned by "gen/generator.go". //template:begin isNull
141+
func (data *FabricEWLC) isNull(ctx context.Context, res gjson.Result) bool {
142+
if !data.EnableWireless.IsNull() {
143+
return false
144+
}
145+
if !data.EnableRollingApUpgrade.IsNull() {
146+
return false
147+
}
148+
if !data.ApRebootPercentage.IsNull() {
149+
return false
150+
}
151+
return true
152+
}
153+
154+
// End of section. //template:end isNull

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ func (p *CcProvider) Resources(ctx context.Context) []func() resource.Resource {
320320
NewDiscoveryResource,
321321
NewDNSSettingsResource,
322322
NewFabricDeviceResource,
323+
NewFabricEWLCResource,
323324
NewFabricL2HandoffResource,
324325
NewFabricL2VirtualNetworkResource,
325326
NewFabricL3HandoffIPTransitResource,

0 commit comments

Comments
 (0)