Skip to content

Commit e81f8d8

Browse files
modify catalystcenter_lan_automation to use V2 LAN Automation Start API (#209)
1 parent 0e3ff14 commit e81f8d8

15 files changed

+377
-51
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.2.5 (unreleased)
22

3+
- Modify `catalystcenter_lan_automation` to use V2 LAN Automation Start API, which supports optional auto-stop processing feature based on the provided timeout or a specific device list, or both.
34
- Add `catalystcenter_assign_device_to_site` resource. This resource only works with Catalyst Center version 2.3.7.9+
45
- Improve delete operations to treat `404 Not Found` responses as successful, ensuring idempotent behavior when resources are already removed
56

docs/data-sources/lan_automation.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ data "catalystcenter_lan_automation" "example" {
2828
### Read-Only
2929

3030
- `discovered_device_site_name_hierarchy` (String) Discovered device site name.
31+
- `discovery_devices` (Attributes Set) List of specific devices that will be LAN Automated in this session (see [below for nested schema](#nestedatt--discovery_devices))
32+
- `discovery_level` (Number) Level below primary seed device upto which the new devices will be LAN Automated by this session, level + seed = tier
33+
- `discovery_timeout` (Number) Discovery timeout in minutes. Until this time, the stop processing will not be triggered.
3134
- `host_name_file_id` (String) File ID of the CSV file containing the host name list.
3235
- `host_name_prefix` (String) Host name prefix which shall be assigned to the discovered device.
3336
- `ip_pools` (Attributes List) The list of IP pools with its name and role. (see [below for nested schema](#nestedatt--ip_pools))
@@ -38,6 +41,17 @@ data "catalystcenter_lan_automation" "example" {
3841
- `primary_device_management_ip_address` (String) Primary seed management IP address.
3942
- `redistribute_isis_to_bgp` (Boolean) Advertise LAN Automation summary route into BGP.
4043

44+
<a id="nestedatt--discovery_devices"></a>
45+
### Nested Schema for `discovery_devices`
46+
47+
Read-Only:
48+
49+
- `device_host_name` (String) Hostname of the device
50+
- `device_management_ip_address` (String) Management IP Address of the device
51+
- `device_serial_number` (String) Serial number of the device
52+
- `device_site_name_hierarchy` (String) Site name hierarchy for the device, must be a child site of the discoveredDeviceSiteNameHierarchy or same if it’s not area type
53+
54+
4155
<a id="nestedatt--ip_pools"></a>
4256
### Nested Schema for `ip_pools`
4357

docs/guides/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: |-
99

1010
## 0.2.5 (unreleased)
1111

12+
- Modify `catalystcenter_lan_automation` to use V2 LAN Automation Start API, which supports optional auto-stop processing feature based on the provided timeout or a specific device list, or both.
1213
- Add `catalystcenter_assign_device_to_site` resource. This resource only works with Catalyst Center version 2.3.7.9+
1314
- Improve delete operations to treat `404 Not Found` responses as successful, ensuring idempotent behavior when resources are already removed
1415

docs/resources/lan_automation.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ This resource can Start LAN Automation on resource creation and Stop LAN Automat
1616
resource "catalystcenter_lan_automation" "example" {
1717
discovered_device_site_name_hierarchy = "Global/Area1/Area2"
1818
primary_device_management_ip_address = "1.2.3.4"
19-
peer_device_management_ip_address = "1.2.3.5"
2019
primary_device_interface_names = ["HundredGigE1/0/1"]
2120
ip_pools = [
2221
{
@@ -28,6 +27,16 @@ resource "catalystcenter_lan_automation" "example" {
2827
host_name_prefix = "TEST"
2928
isis_domain_password = "cisco123"
3029
redistribute_isis_to_bgp = true
30+
discovery_level = 2
31+
discovery_timeout = 20
32+
discovery_devices = [
33+
{
34+
device_serial_number = "FOC12345678"
35+
device_host_name = "EDGE01"
36+
device_site_name_hierarchy = "Global/Area1/Area2"
37+
device_management_ip_address = "10.0.0.1"
38+
}
39+
]
3140
}
3241
```
3342

@@ -37,14 +46,20 @@ resource "catalystcenter_lan_automation" "example" {
3746
### Required
3847

3948
- `discovered_device_site_name_hierarchy` (String) Discovered device site name.
49+
- `ip_pools` (Attributes List) The list of IP pools with its name and role. (see [below for nested schema](#nestedatt--ip_pools))
4050
- `primary_device_interface_names` (Set of String) The list of interfaces on primary seed via which the discovered devices are connected.
4151
- `primary_device_management_ip_address` (String) Primary seed management IP address.
4252

4353
### Optional
4454

55+
- `discovery_devices` (Attributes Set) List of specific devices that will be LAN Automated in this session (see [below for nested schema](#nestedatt--discovery_devices))
56+
- `discovery_level` (Number) Level below primary seed device upto which the new devices will be LAN Automated by this session, level + seed = tier
57+
- Range: `1`-`5`
58+
- Default value: `2`
59+
- `discovery_timeout` (Number) Discovery timeout in minutes. Until this time, the stop processing will not be triggered.
60+
- Range: `20`-`10080`
4561
- `host_name_file_id` (String) File ID of the CSV file containing the host name list.
4662
- `host_name_prefix` (String) Host name prefix which shall be assigned to the discovered device.
47-
- `ip_pools` (Attributes List) The list of IP pools with its name and role. (see [below for nested schema](#nestedatt--ip_pools))
4863
- `isis_domain_password` (String) ISIS domain password.
4964
- `multicast_enabled` (Boolean) To enable underlay native multicast.
5065
- `peer_device_management_ip_address` (String) Secondary seed management IP address.
@@ -63,6 +78,20 @@ Required:
6378
- `ip_pool_role` (String) Role of the IP pool.
6479
- Choices: `MAIN_POOL`, `PHYSICAL_LINK_POOL`
6580

81+
82+
<a id="nestedatt--discovery_devices"></a>
83+
### Nested Schema for `discovery_devices`
84+
85+
Required:
86+
87+
- `device_serial_number` (String) Serial number of the device
88+
89+
Optional:
90+
91+
- `device_host_name` (String) Hostname of the device
92+
- `device_management_ip_address` (String) Management IP Address of the device
93+
- `device_site_name_hierarchy` (String) Site name hierarchy for the device, must be a child site of the discoveredDeviceSiteNameHierarchy or same if it’s not area type
94+
6695
## Import
6796

6897
Import is supported using the following syntax:

examples/resources/catalystcenter_lan_automation/resource.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
resource "catalystcenter_lan_automation" "example" {
22
discovered_device_site_name_hierarchy = "Global/Area1/Area2"
33
primary_device_management_ip_address = "1.2.3.4"
4-
peer_device_management_ip_address = "1.2.3.5"
54
primary_device_interface_names = ["HundredGigE1/0/1"]
65
ip_pools = [
76
{
@@ -13,4 +12,14 @@ resource "catalystcenter_lan_automation" "example" {
1312
host_name_prefix = "TEST"
1413
isis_domain_password = "cisco123"
1514
redistribute_isis_to_bgp = true
15+
discovery_level = 2
16+
discovery_timeout = 20
17+
discovery_devices = [
18+
{
19+
device_serial_number = "FOC12345678"
20+
device_host_name = "EDGE01"
21+
device_site_name_hierarchy = "Global/Area1/Area2"
22+
device_management_ip_address = "10.0.0.1"
23+
}
24+
]
1625
}

gen/definitions/lan_automation.yaml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
22
name: LAN Automation
3-
rest_endpoint: /dna/intent/api/v1/lan-automation
3+
rest_endpoint: /dna/intent/api/v2/lan-automation
4+
delete_rest_endpoint: /dna/intent/api/v1/lan-automation
45
get_rest_endpoint: /dna/intent/api/v1/lan-automation/status
56
no_update: true
6-
id_path: response.id
7+
id_path: response.taskId
8+
no_wait: true
9+
skip_minimum_test: true
710
doc_category: LAN Automation
811
res_description:
912
'This resource can Start LAN Automation on resource creation and Stop LAN Automation on resource deletion'
@@ -30,7 +33,7 @@ attributes:
3033
tf_name: peer_device_management_ip_address
3134
type: String
3235
description: Secondary seed management IP address.
33-
example: 1.2.3.5
36+
exclude_test: true
3437
- model_name: primaryDeviceInterfaceNames
3538
data_path: "0"
3639
response_data_path: response.0.primaryDeviceInterfaceNames
@@ -41,6 +44,7 @@ attributes:
4144
example: HundredGigE1/0/1
4245
- model_name: ipPools
4346
data_path: "0"
47+
mandatory: true
4448
response_data_path: response.0.ipPools
4549
type: List
4650
description: The list of IP pools with its name and role.
@@ -60,7 +64,7 @@ attributes:
6064
example: MAIN_POOL
6165
- model_name: multicastEnabled
6266
data_path: "0"
63-
response_data_path: response.0.multicatEnabled
67+
response_data_path: response.0.multicastEnabled
6468
type: Bool
6569
description: To enable underlay native multicast.
6670
example: true
@@ -80,6 +84,7 @@ attributes:
8084
- model_name: isisDomainPwd
8185
data_path: "0"
8286
response_data_path: response.0.isisDomainPwd
87+
write_only: true
8388
tf_name: isis_domain_password
8489
type: String
8590
description: ISIS domain password.
@@ -90,3 +95,45 @@ attributes:
9095
type: Bool
9196
description: Advertise LAN Automation summary route into BGP.
9297
example: true
98+
- model_name: discoveryLevel
99+
data_path: "0"
100+
response_data_path: response.0.discoveryLevel
101+
type: Int64
102+
description: Level below primary seed device upto which the new devices will be LAN Automated by this session, level + seed = tier
103+
min_int: 1
104+
max_int: 5
105+
default_value: 2
106+
example: 2
107+
- model_name: discoveryTimeout
108+
data_path: "0"
109+
response_data_path: response.0.discoveryTimeout
110+
type: Int64
111+
description: Discovery timeout in minutes. Until this time, the stop processing will not be triggered.
112+
min_int: 20
113+
max_int: 10080
114+
example: 20
115+
- model_name: discoveryDevices
116+
data_path: "0"
117+
response_data_path: response.0.discoveryDevices
118+
type: Set
119+
description: List of specific devices that will be LAN Automated in this session
120+
attributes:
121+
- model_name: deviceSerialNumber
122+
type: String
123+
mandatory: true
124+
id: true
125+
description: Serial number of the device
126+
example: FOC12345678
127+
- model_name: deviceHostName
128+
type: String
129+
description: Hostname of the device
130+
example: EDGE01
131+
- model_name: deviceSiteNameHierarchy
132+
type: String
133+
description: Site name hierarchy for the device, must be a child site of the discoveredDeviceSiteNameHierarchy or same if it’s not area type
134+
example: Global/Area1/Area2
135+
- model_name: deviceManagementIPAddress
136+
tf_name: device_management_ip_address
137+
type: String
138+
description: Management IP Address of the device
139+
example: 10.0.0.1

gen/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ type YamlConfig struct {
118118
UpdateComputed bool `yaml:"update_computed"`
119119
RootList bool `yaml:"root_list"`
120120
NoReadPrefix bool `yaml:"no_read_prefix"`
121+
NoWait bool `yaml:"no_wait"`
121122
IdPath string `yaml:"id_path"`
122123
IdFromQueryPath string `yaml:"id_from_query_path"`
123124
IdFromQueryPathAttribute string `yaml:"id_from_query_path_attribute"`

gen/schema/schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ put_id_query_param: str(required=False) # If PUT needs to have specific query pa
3434
put_no_id: bool(required=False) # Set to true if the PUT request does not require an ID
3535
put_update_id: bool(required=False) # Set to true if the PUT request updates the ID
3636
delete_id_query_param: str(required=False) # If DELETE needs to have specific query parameter where ID should be inserted
37+
no_wait: bool(required=False) # Set to true to indicate that the task should not wait for completion
3738
minimum_version: str(required=False) # Define a minimum supported version
3839
ds_description: str(required=False) # Define a data source description
3940
res_description: str(required=False) # Define a resource description

gen/templates/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C
453453
{{- if .PutCreate}}
454454
res, err := r.client.Put(plan.getPath() + params, body {{- if .MaxAsyncWaitTime }}, func(r *cc.Req) { r.MaxAsyncWaitTime={{.MaxAsyncWaitTime}} }{{end}}{{- if .Mutex }}, cc.UseMutex{{- end}})
455455
{{- else}}
456-
res, err := r.client.Post(plan.getPath() + params, body {{- if .MaxAsyncWaitTime }}, func(r *cc.Req) { r.MaxAsyncWaitTime={{.MaxAsyncWaitTime}} }{{end}}{{- if .Mutex }}, cc.UseMutex{{- end}})
456+
res, err := r.client.Post(plan.getPath() + params, body {{- if .MaxAsyncWaitTime }}, func(r *cc.Req) { r.MaxAsyncWaitTime={{.MaxAsyncWaitTime}} }{{end}}{{- if .Mutex }}, cc.UseMutex{{- end}}{{- if .NoWait }}, cc.NoWait{{- end}})
457457
{{- end}}
458458
if err != nil {
459459
{{- if .DeviceUnreachabilityWarning}}

internal/provider/data_source_catalystcenter_lan_automation.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,38 @@ func (d *LANAutomationDataSource) Schema(ctx context.Context, req datasource.Sch
115115
MarkdownDescription: "Advertise LAN Automation summary route into BGP.",
116116
Computed: true,
117117
},
118+
"discovery_level": schema.Int64Attribute{
119+
MarkdownDescription: "Level below primary seed device upto which the new devices will be LAN Automated by this session, level + seed = tier",
120+
Computed: true,
121+
},
122+
"discovery_timeout": schema.Int64Attribute{
123+
MarkdownDescription: "Discovery timeout in minutes. Until this time, the stop processing will not be triggered.",
124+
Computed: true,
125+
},
126+
"discovery_devices": schema.SetNestedAttribute{
127+
MarkdownDescription: "List of specific devices that will be LAN Automated in this session",
128+
Computed: true,
129+
NestedObject: schema.NestedAttributeObject{
130+
Attributes: map[string]schema.Attribute{
131+
"device_serial_number": schema.StringAttribute{
132+
MarkdownDescription: "Serial number of the device",
133+
Computed: true,
134+
},
135+
"device_host_name": schema.StringAttribute{
136+
MarkdownDescription: "Hostname of the device",
137+
Computed: true,
138+
},
139+
"device_site_name_hierarchy": schema.StringAttribute{
140+
MarkdownDescription: "Site name hierarchy for the device, must be a child site of the discoveredDeviceSiteNameHierarchy or same if it’s not area type",
141+
Computed: true,
142+
},
143+
"device_management_ip_address": schema.StringAttribute{
144+
MarkdownDescription: "Management IP Address of the device",
145+
Computed: true,
146+
},
147+
},
148+
},
149+
},
118150
},
119151
}
120152
}

0 commit comments

Comments
 (0)