forked from CiscoDevNet/terraform-provider-catalystcenter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fabric_l2_virtual_network and add device unreachability warning i…
…n fabric_l3_handoff_ip_transit
- Loading branch information
1 parent
b6775e3
commit e8aa354
Showing
19 changed files
with
958 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "catalystcenter_fabric_l2_virtual_network Data Source - terraform-provider-catalystcenter" | ||
subcategory: "SDA" | ||
description: |- | ||
This data source can read the Fabric L2 Virtual Network. | ||
--- | ||
|
||
# catalystcenter_fabric_l2_virtual_network (Data Source) | ||
|
||
This data source can read the Fabric L2 Virtual Network. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "catalystcenter_fabric_l2_virtual_network" "example" { | ||
fabric_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1" | ||
vlan_name = "VLAN401" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `fabric_id` (String) ID of the fabric this layer 2 virtual network is to be assigned to | ||
- `vlan_name` (String) Name of the VLAN of the layer 2 virtual network. Must contain only alphanumeric characters, underscores, and hyphens | ||
|
||
### Read-Only | ||
|
||
- `associated_l3_virtual_network_name` (String) Name of the layer 3 virtual network associated with the layer 2 virtual network. This field is provided to support requests related to virtual network anchoring. The layer 3 virtual network must have already been added to the fabric before association. This field must either be present in all payload elements or none | ||
- `fabric_enabled_wireless` (Boolean) Set to true to enable wireless. Default is false | ||
- `id` (String) The id of the object | ||
- `traffic_type` (String) The type of traffic that is served | ||
- `vlan_id` (Number) ID of the VLAN of the layer 2 virtual network. Allowed VLAN range is 2-4093 except for reserved VLANs 1002-1005, and 2046. If deploying on a fabric zone, this vlanId must match the vlanId of the corresponding layer 2 virtual network on the fabric site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "catalystcenter_fabric_l2_virtual_network Resource - terraform-provider-catalystcenter" | ||
subcategory: "SDA" | ||
description: |- | ||
This resource can manage a Fabric L2 Virtual Network. | ||
--- | ||
|
||
# catalystcenter_fabric_l2_virtual_network (Resource) | ||
|
||
This resource can manage a Fabric L2 Virtual Network. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "catalystcenter_fabric_l2_virtual_network" "example" { | ||
fabric_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1" | ||
vlan_name = "VLAN401" | ||
vlan_id = 401 | ||
traffic_type = "DATA" | ||
fabric_enabled_wireless = false | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `fabric_id` (String) ID of the fabric this layer 2 virtual network is to be assigned to | ||
- `traffic_type` (String) The type of traffic that is served | ||
- Choices: `DATA`, `VOICE` | ||
- `vlan_name` (String) Name of the VLAN of the layer 2 virtual network. Must contain only alphanumeric characters, underscores, and hyphens | ||
|
||
### Optional | ||
|
||
- `associated_l3_virtual_network_name` (String) Name of the layer 3 virtual network associated with the layer 2 virtual network. This field is provided to support requests related to virtual network anchoring. The layer 3 virtual network must have already been added to the fabric before association. This field must either be present in all payload elements or none | ||
- `fabric_enabled_wireless` (Boolean) Set to true to enable wireless. Default is false | ||
- `vlan_id` (Number) ID of the VLAN of the layer 2 virtual network. Allowed VLAN range is 2-4093 except for reserved VLANs 1002-1005, and 2046. If deploying on a fabric zone, this vlanId must match the vlanId of the corresponding layer 2 virtual network on the fabric site | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The id of the object | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import catalystcenter_fabric_l2_virtual_network.example "<fabric_id>,<vlan_name>" | ||
``` |
4 changes: 4 additions & 0 deletions
4
examples/data-sources/catalystcenter_fabric_l2_virtual_network/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
data "catalystcenter_fabric_l2_virtual_network" "example" { | ||
fabric_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1" | ||
vlan_name = "VLAN401" | ||
} |
1 change: 1 addition & 0 deletions
1
examples/resources/catalystcenter_fabric_l2_virtual_network/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import catalystcenter_fabric_l2_virtual_network.example "<fabric_id>,<vlan_name>" |
7 changes: 7 additions & 0 deletions
7
examples/resources/catalystcenter_fabric_l2_virtual_network/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "catalystcenter_fabric_l2_virtual_network" "example" { | ||
fabric_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1" | ||
vlan_name = "VLAN401" | ||
vlan_id = 401 | ||
traffic_type = "DATA" | ||
fabric_enabled_wireless = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
name: Fabric L2 Virtual Network | ||
rest_endpoint: /dna/intent/api/v1/sda/layer2VirtualNetworks | ||
id_from_query_path: response.0 | ||
id_from_query_path_attribute: id | ||
import_no_id: true | ||
data_source_no_id: true | ||
skip_minimum_test: true | ||
put_id_include_path: "0.id" | ||
put_no_id: true | ||
doc_category: SDA | ||
attributes: | ||
- model_name: fabricId | ||
requires_replace: true | ||
data_path: '0' | ||
query_param: true | ||
response_data_path: response.0.fabricId | ||
mandatory: true | ||
description: ID of the fabric this layer 2 virtual network is to be assigned to | ||
type: String | ||
example: 5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1 | ||
test_value: catalystcenter_fabric_site.test.id | ||
- model_name: vlanName | ||
requires_replace: true | ||
data_path: '0' | ||
query_param: true | ||
response_data_path: response.0.vlanName | ||
type: String | ||
mandatory: true | ||
description: Name of the VLAN of the layer 2 virtual network. Must contain only alphanumeric characters, underscores, and hyphens | ||
example: VLAN401 | ||
- model_name: vlanId | ||
requires_replace: true | ||
data_path: '0' | ||
response_data_path: response.0.vlanId | ||
type: Int64 | ||
description: ID of the VLAN of the layer 2 virtual network. Allowed VLAN range is 2-4093 except for reserved VLANs 1002-1005, and 2046. If deploying on a fabric zone, this vlanId must match the vlanId of the corresponding layer 2 virtual network on the fabric site | ||
example: 401 | ||
- model_name: trafficType | ||
data_path: '0' | ||
response_data_path: response.0.trafficType | ||
type: String | ||
enum_values: [DATA, VOICE] | ||
mandatory: true | ||
description: The type of traffic that is served | ||
example: DATA | ||
- model_name: isFabricEnabledWireless | ||
data_path: '0' | ||
response_data_path: response.0.isFabricEnabledWireless | ||
tf_name: fabric_enabled_wireless | ||
type: Bool | ||
description: Set to true to enable wireless. Default is false | ||
example: false | ||
- model_name: associatedLayer3VirtualNetworkName | ||
requires_replace: true | ||
data_path: '0' | ||
response_data_path: response.0.associatedLayer3VirtualNetworkName | ||
tf_name: associated_l3_virtual_network_name | ||
type: String | ||
description: Name of the layer 3 virtual network associated with the layer 2 virtual network. This field is provided to support requests related to virtual network anchoring. The layer 3 virtual network must have already been added to the fabric before association. This field must either be present in all payload elements or none | ||
example: SDA_VN1 | ||
exclude_test: true | ||
test_prerequisites: | | ||
resource "catalystcenter_area" "test" { | ||
name = "Area1" | ||
parent_name = "Global" | ||
} | ||
resource "catalystcenter_fabric_site" "test" { | ||
site_id = catalystcenter_area.test.id | ||
pub_sub_enabled = false | ||
authentication_profile_name = "No Authentication" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
internal/provider/data_source_catalystcenter_fabric_l2_virtual_network.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Mozilla Public License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://mozilla.org/MPL/2.0/ | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package provider | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin imports | ||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
cc "github.com/netascode/go-catalystcenter" | ||
) | ||
|
||
// End of section. //template:end imports | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin model | ||
|
||
// Ensure the implementation satisfies the expected interfaces. | ||
var ( | ||
_ datasource.DataSource = &FabricL2VirtualNetworkDataSource{} | ||
_ datasource.DataSourceWithConfigure = &FabricL2VirtualNetworkDataSource{} | ||
) | ||
|
||
func NewFabricL2VirtualNetworkDataSource() datasource.DataSource { | ||
return &FabricL2VirtualNetworkDataSource{} | ||
} | ||
|
||
type FabricL2VirtualNetworkDataSource struct { | ||
client *cc.Client | ||
} | ||
|
||
func (d *FabricL2VirtualNetworkDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_fabric_l2_virtual_network" | ||
} | ||
|
||
func (d *FabricL2VirtualNetworkDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
// This description is used by the documentation generator and the language server. | ||
MarkdownDescription: "This data source can read the Fabric L2 Virtual Network.", | ||
|
||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
MarkdownDescription: "The id of the object", | ||
Computed: true, | ||
}, | ||
"fabric_id": schema.StringAttribute{ | ||
MarkdownDescription: "ID of the fabric this layer 2 virtual network is to be assigned to", | ||
Required: true, | ||
}, | ||
"vlan_name": schema.StringAttribute{ | ||
MarkdownDescription: "Name of the VLAN of the layer 2 virtual network. Must contain only alphanumeric characters, underscores, and hyphens", | ||
Required: true, | ||
}, | ||
"vlan_id": schema.Int64Attribute{ | ||
MarkdownDescription: "ID of the VLAN of the layer 2 virtual network. Allowed VLAN range is 2-4093 except for reserved VLANs 1002-1005, and 2046. If deploying on a fabric zone, this vlanId must match the vlanId of the corresponding layer 2 virtual network on the fabric site", | ||
Computed: true, | ||
}, | ||
"traffic_type": schema.StringAttribute{ | ||
MarkdownDescription: "The type of traffic that is served", | ||
Computed: true, | ||
}, | ||
"fabric_enabled_wireless": schema.BoolAttribute{ | ||
MarkdownDescription: "Set to true to enable wireless. Default is false", | ||
Computed: true, | ||
}, | ||
"associated_l3_virtual_network_name": schema.StringAttribute{ | ||
MarkdownDescription: "Name of the layer 3 virtual network associated with the layer 2 virtual network. This field is provided to support requests related to virtual network anchoring. The layer 3 virtual network must have already been added to the fabric before association. This field must either be present in all payload elements or none", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (d *FabricL2VirtualNetworkDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
d.client = req.ProviderData.(*CcProviderData).Client | ||
} | ||
|
||
// End of section. //template:end model | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin read | ||
func (d *FabricL2VirtualNetworkDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
var config FabricL2VirtualNetwork | ||
|
||
// Read config | ||
diags := req.Config.Get(ctx, &config) | ||
resp.Diagnostics.Append(diags...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) | ||
|
||
params := "" | ||
params += "?fabricId=" + url.QueryEscape(config.FabricId.ValueString()) + "&vlanName=" + url.QueryEscape(config.VlanName.ValueString()) | ||
res, err := d.client.Get(config.getPath() + params) | ||
if err != nil { | ||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) | ||
return | ||
} | ||
|
||
config.fromBody(ctx, res) | ||
|
||
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString())) | ||
|
||
diags = resp.State.Set(ctx, &config) | ||
resp.Diagnostics.Append(diags...) | ||
} | ||
|
||
// End of section. //template:end read |
Oops, something went wrong.