From 5cc6029fec7c413cc7318c88dbb256db327cce2d Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:12:02 +0530 Subject: [PATCH] [minor_change] Added aci_l3out_node_sid_profile resource and data-source files --- docs/data-sources/annotation.md | 10 +- docs/data-sources/l3out_node_sid_profile.md | 63 ++ docs/data-sources/tag.md | 10 +- docs/resources/annotation.md | 10 +- docs/resources/l3out_node_sid_profile.md | 126 ++++ docs/resources/tag.md | 10 +- .../aci_l3out_node_sid_profile/data-source.tf | 5 + .../aci_l3out_node_sid_profile/provider.tf | 14 + .../aci_l3out_node_sid_profile/provider.tf | 14 + .../resource-all-attributes.tf | 22 + .../aci_l3out_node_sid_profile/resource.tf | 5 + gen/definitions/classes.yaml | 19 + gen/definitions/properties.yaml | 29 + gen/generator.go | 2 +- gen/meta/mplsNodeSidP.json | 683 ++++++++++++++++++ gen/testvars/mplsNodeSidP.yaml | 47 ++ .../data_source_aci_l3out_node_sid_profile.go | 165 +++++ ..._source_aci_l3out_node_sid_profile_test.go | 54 ++ internal/provider/provider.go | 2 + .../resource_aci_l3out_node_sid_profile.go | 623 ++++++++++++++++ ...esource_aci_l3out_node_sid_profile_test.go | 256 +++++++ internal/provider/test_constants.go | 18 + 22 files changed, 2166 insertions(+), 21 deletions(-) create mode 100644 docs/data-sources/l3out_node_sid_profile.md create mode 100644 docs/resources/l3out_node_sid_profile.md create mode 100644 examples/data-sources/aci_l3out_node_sid_profile/data-source.tf create mode 100644 examples/data-sources/aci_l3out_node_sid_profile/provider.tf create mode 100644 examples/resources/aci_l3out_node_sid_profile/provider.tf create mode 100644 examples/resources/aci_l3out_node_sid_profile/resource-all-attributes.tf create mode 100644 examples/resources/aci_l3out_node_sid_profile/resource.tf create mode 100644 gen/meta/mplsNodeSidP.json create mode 100644 gen/testvars/mplsNodeSidP.yaml create mode 100644 internal/provider/data_source_aci_l3out_node_sid_profile.go create mode 100644 internal/provider/data_source_aci_l3out_node_sid_profile_test.go create mode 100644 internal/provider/resource_aci_l3out_node_sid_profile.go create mode 100644 internal/provider/resource_aci_l3out_node_sid_profile_test.go diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index eb9424eeb..952b20f3e 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -53,6 +53,7 @@ data "aci_annotation" "example_application_epg" { ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - Too many parent DNs to display, see model documentation for all possible parents of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) @@ -61,19 +62,18 @@ data "aci_annotation" "example_application_epg" { - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) + - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) + - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/l3out_node_sid_profile.md b/docs/data-sources/l3out_node_sid_profile.md new file mode 100644 index 000000000..f92089845 --- /dev/null +++ b/docs/data-sources/l3out_node_sid_profile.md @@ -0,0 +1,63 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "L3Out" +layout: "aci" +page_title: "ACI: aci_l3out_node_sid_profile" +sidebar_current: "docs-aci-data-source-aci_l3out_node_sid_profile" +description: |- + Data source for L3out Node Sid Profile +--- + +# aci_l3out_node_sid_profile # + +Data source for L3out Node Sid Profile + +## API Information ## + +* Class: [mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Logical Node Profiles -> Policy -> Nodes -> Policy -> Loopback Addresses` + +## Example Usage ## + +```hcl + +data "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + sid_offset = "1" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) +* `sid_offset` (sidoffset) - (string) The offset ID of the L3out Node Sid Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the L3out Node Sid Profile object. +* `annotation` (annotation) - (string) The annotation of the L3out Node Sid Profile object. +* `description` (descr) - (string) The description of the L3out Node Sid Profile object. +* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3out Node Sid Profile object. +* `name` (name) - (string) The name of the L3out Node Sid Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the L3out Node Sid Profile object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/tag.md b/docs/data-sources/tag.md index 17b078e92..ceb44f415 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -53,6 +53,7 @@ data "aci_tag" "example_application_epg" { ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - Too many parent DNs to display, see model documentation for all possible parents of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) @@ -61,19 +62,18 @@ data "aci_tag" "example_application_epg" { - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) + - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) + - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/resources/annotation.md b/docs/resources/annotation.md index 9f4be718b..cf0e75839 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -62,6 +62,7 @@ All examples for the Annotation resource can be found in the [examples](https:// ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - Too many parent DNs to display, see model documentation for all possible parents of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) @@ -70,19 +71,18 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) + - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) + - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview). * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/resources/l3out_node_sid_profile.md b/docs/resources/l3out_node_sid_profile.md new file mode 100644 index 000000000..2ad935c18 --- /dev/null +++ b/docs/resources/l3out_node_sid_profile.md @@ -0,0 +1,126 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "L3Out" +layout: "aci" +page_title: "ACI: aci_l3out_node_sid_profile" +sidebar_current: "docs-aci-resource-aci_l3out_node_sid_profile" +description: |- + Manages ACI L3out Node Sid Profile +--- + +# aci_l3out_node_sid_profile # + +Manages ACI L3out Node Sid Profile + + + +## API Information ## + +* Class: [mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview) + +* Supported in ACI versions: 5.0(1k) and later. + +* Distinguished Name Format: `uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}` + +## GUI Information ## + +* Location: `Tenants -> Networking -> L3Outs -> Logical Node Profiles -> Policy -> Nodes -> Policy -> Loopback Addresses` + +## Example Usage ## + +The configuration snippet below creates a L3out Node Sid Profile with only required attributes. + +```hcl + +resource "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + sid_offset = "1" +} + +``` +The configuration snippet below shows all possible attributes of the L3out Node Sid Profile. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_l3out_node_sid_profile" "full_example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + annotation = "annotation" + description = "description" + loopback_address = "1.1.1.1" + name = "node_sid_profile" + name_alias = "name_alias" + sid_offset = "1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the L3out Node Sid Profile resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_l3out_node_sid_profile) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) +* `sid_offset` (sidoffset) - (string) The offset ID of the L3out Node Sid Profile object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the L3out Node Sid Profile object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the L3out Node Sid Profile object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the L3out Node Sid Profile object. +* `loopback_address` (loopbackAddr) - (string) The loopback address of the L3out Node Sid Profile object. +* `name` (name) - (string) The name of the L3out Node Sid Profile object. +* `name_alias` (nameAlias) - (string) The name alias of the L3out Node Sid Profile object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing L3out Node Sid Profile can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_l3out_node_sid_profile.example_l3out_loopback_interface_profile uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset} +``` + +Starting in Terraform version 1.5, an existing L3out Node Sid Profile can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}" + to = aci_l3out_node_sid_profile.example_l3out_loopback_interface_profile +} +``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index 1cf431ae8..fab200a68 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -62,6 +62,7 @@ All examples for the Tag resource can be found in the [examples](https://github. ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - Too many parent DNs to display, see model documentation for all possible parents of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_vrf](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf) ([fvCtx](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvCtx/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) @@ -70,19 +71,18 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) + - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) + - [aci_l3out_loopback_interface_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_loopback_interface_profile) ([l3extLoopBackIfP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLoopBackIfP/overview)) - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) + - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) + - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - [aci_pim_route_map_entry](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_entry) ([pimRouteMapEntry](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapEntry/overview)) - - [aci_pim_route_map_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/pim_route_map_policy) ([pimRouteMapPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pimRouteMapPol/overview)) - - [aci_route_control_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/route_control_profile) ([rtctrlProfile](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/rtctrlProfile/overview)) - - [aci_contract_interface](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/contract_interface) ([vzCPIf](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzCPIf/overview)) - - [aci_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/out_of_band_contract) ([vzOOBBrCP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/vzOOBBrCP/overview)) - - Too many classes to display, see model documentation for all possible classes of [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview). * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/examples/data-sources/aci_l3out_node_sid_profile/data-source.tf b/examples/data-sources/aci_l3out_node_sid_profile/data-source.tf new file mode 100644 index 000000000..8cb7d7bf7 --- /dev/null +++ b/examples/data-sources/aci_l3out_node_sid_profile/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + sid_offset = "1" +} diff --git a/examples/data-sources/aci_l3out_node_sid_profile/provider.tf b/examples/data-sources/aci_l3out_node_sid_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/data-sources/aci_l3out_node_sid_profile/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_l3out_node_sid_profile/provider.tf b/examples/resources/aci_l3out_node_sid_profile/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_l3out_node_sid_profile/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_l3out_node_sid_profile/resource-all-attributes.tf b/examples/resources/aci_l3out_node_sid_profile/resource-all-attributes.tf new file mode 100644 index 000000000..e2f63f9eb --- /dev/null +++ b/examples/resources/aci_l3out_node_sid_profile/resource-all-attributes.tf @@ -0,0 +1,22 @@ + +resource "aci_l3out_node_sid_profile" "full_example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + annotation = "annotation" + description = "description" + loopback_address = "1.1.1.1" + name = "node_sid_profile" + name_alias = "name_alias" + sid_offset = "1" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_l3out_node_sid_profile/resource.tf b/examples/resources/aci_l3out_node_sid_profile/resource.tf new file mode 100644 index 000000000..7f58419c5 --- /dev/null +++ b/examples/resources/aci_l3out_node_sid_profile/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_l3out_node_sid_profile" "example_l3out_loopback_interface_profile" { + parent_dn = aci_l3out_loopback_interface_profile.example.id + sid_offset = "1" +} diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index 462ca67ca..6069fb19c 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -77,6 +77,15 @@ l3extConsLbl: - "Tenants -> Networking -> SR MPLS VRF L3Outs -> SR-MPLS Infra L3Outs" sub_category: "L3Out" +l3extLoopBackIfP: + resource_name: "l3out_loopback_interface_profile" + +l3extRsNodeL3OutAtt: + resource_name: "logical_node_to_fabric_node" + +l3extLNodeP: + resource_name: "logical_node_profile" + l3extRsRedistributePol: resource_name: "l3out_redistribute_policy" ui_locations: @@ -164,3 +173,13 @@ l3extProvLbl: ui_locations: - "Tenants (infra) -> Networking -> L3Outs -> Policy -> Main -> Provider Label" sub_category: "L3Out" + +mplsNodeSidP: + resource_name: "l3out_node_sid_profile" + ui_locations: + - "Tenants -> Networking -> L3Outs -> Logical Node Profiles -> Policy -> Nodes -> Policy -> Loopback Addresses" + sub_category: "L3Out" + dn_formats: + - "uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}" + contained_by: + - "l3extLoopBackIfP" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index ec4edb1d2..3591884c4 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -233,3 +233,32 @@ l3extProvLbl: parent_dependency_name: "infra" parent_dn: "aci_l3_outside.test.id" class_in_parent: false + +mplsNodeSidP: + overwrites: + loopback_addr: "loopback_address" + sidoffset: "sid_offset" + documentation: + loopbackAddr: "The loopback address of the %s object." + sidoffset: "The offset ID of the %s object." + test_values: + default: + sid_offset: "1" + loopback_address: "0.0.0.0" + name: "" + all: + loopback_address: "1.1.1.1" + sid_offset: "1" + name: "node_sid_profile" + resource_required: + sid_offset: "1" + name: "node_sid_profile" + loopback_address: "1.1.1.1" + datasource_required: + sid_offset: "1" + datasource_non_existing: + sid_offset: "2" + parents: + - class_name: "l3extLoopBackIfP" + parent_dependency: "l3extRsNodeL3OutAtt" + parent_dn: "aci_logical_node_to_fabric_node.test.id" diff --git a/gen/generator.go b/gen/generator.go index 6f669327e..bc4d472a4 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -1493,7 +1493,7 @@ func setDocumentationData(m *Model, definitions Definitions) { } } - if len(resourcesNotFound) != 0 { + if len(resourcesNotFound) != 0 && len(resourcesFound) < docsParentDnAmount { if len(resourcesNotFound) > docsParentDnAmount-len(resourcesFound) { // TODO catch default classes and add to documentation resourcesNotFound = resourcesNotFound[0:(docsParentDnAmount - len(resourcesFound))] diff --git a/gen/meta/mplsNodeSidP.json b/gen/meta/mplsNodeSidP.json new file mode 100644 index 000000000..966f643a2 --- /dev/null +++ b/gen/meta/mplsNodeSidP.json @@ -0,0 +1,683 @@ +{ + "mpls:NodeSidP": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Delegate": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "sidoffset" + ], + "rnFormat": "nodesidp-{sidoffset}", + "containedBy": { + "l3ext:LoopBackIfP": "", + "l3ext:RsNodeL3OutAtt": "" + }, + "superClasses": [ + "mpls:ANodeSidP", + "fabric:L3ProtoComp", + "fabric:ProtoComp", + "pol:Comp", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/lbp-[{addr}]/nodesidp-{sidoffset}", + "uni/tn-{name}/out-{name}/lnodep-{name}/rsnodeL3OutAtt-[{tDn}]/nodesidp-{sidoffset}" + ], + "writeAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "readAccess": [ + "admin", + "tenant-ext-connectivity" + ], + "faults": { + + }, + "events": { + "E4217369": "creation||mpls:NodeSidP", + "E4217370": "modification||mpls:NodeSidP", + "E4217371": "deletion||mpls:NodeSidP" + }, + "stats": { + + }, + "versions": "5.0(1k)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": false, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": false, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "apic" + ], + "classId": "16663", + "className": "NodeSidP", + "classPkg": "mpls", + "featureTag": "", + "moCategory": "Regular", + "label": "Node Sid Profile", + "comment": [ + "MPLS-SR Sid Node Profile" + ], + "properties": { + "annotation": { + "versions": "5.0(1k)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "56765", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies the description of a policy component." + ], + "isConfigurable": true, + "propGlobalId": "5582", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "5.0(1k)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "56766", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "loopbackAddr": { + "versions": "5.0(1k)-", + "comment": [ + "Data plane TEP" + ], + "isConfigurable": true, + "propGlobalId": "56734", + "propLocalId": "12842", + "label": "Loopback Address for Mpls data plane", + "baseType": "address:Ip", + "modelType": "address:Ip", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validateAsIPv4OrIPv6": true, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "sidoffset": { + "versions": "5.0(1k)-", + "comment": [ + "Index" + ], + "isConfigurable": true, + "propGlobalId": "56737", + "propLocalId": "12841", + "label": "SRGB Index", + "baseType": "scalar:Uint32", + "modelType": "scalar:Uint32", + "needsPropDelimiters": false, + "uitype": "number", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/testvars/mplsNodeSidP.yaml b/gen/testvars/mplsNodeSidP.yaml new file mode 100644 index 000000000..3fbfc48e7 --- /dev/null +++ b/gen/testvars/mplsNodeSidP.yaml @@ -0,0 +1,47 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + loopback_address: "0.0.0.0" + name: "" + name_alias: "" + +datasource_non_existing: + sid_offset: "2" + +datasource_required: + sid_offset: "1" + +resource_required: + sid_offset: "1" + +all: + annotation: "annotation" + description: "description" + loopback_address: "1.1.1.1" + name: "node_sid_profile" + name_alias: "name_alias" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: + - class_name: "l3extLoopBackIfP" + parent_dependency: "l3extRsNodeL3OutAtt" + parent_dn: "aci_l3out_loopback_interface_profile.test.id" + class_in_parent: false diff --git a/internal/provider/data_source_aci_l3out_node_sid_profile.go b/internal/provider/data_source_aci_l3out_node_sid_profile.go new file mode 100644 index 000000000..1f131c32c --- /dev/null +++ b/internal/provider/data_source_aci_l3out_node_sid_profile.go @@ -0,0 +1,165 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &MplsNodeSidPDataSource{} + +func NewMplsNodeSidPDataSource() datasource.DataSource { + return &MplsNodeSidPDataSource{} +} + +// MplsNodeSidPDataSource defines the data source implementation. +type MplsNodeSidPDataSource struct { + client *client.Client +} + +func (d *MplsNodeSidPDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_l3out_node_sid_profile") + resp.TypeName = req.ProviderTypeName + "_l3out_node_sid_profile" + tflog.Debug(ctx, "End metadata of datasource: aci_l3out_node_sid_profile") +} + +func (d *MplsNodeSidPDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_l3out_node_sid_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The l3out_node_sid_profile datasource for the 'mplsNodeSidP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the L3out Node Sid Profile object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the L3out Node Sid Profile object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the L3out Node Sid Profile object.`, + }, + "loopback_address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The loopback address of the L3out Node Sid Profile object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the L3out Node Sid Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the L3out Node Sid Profile object.`, + }, + "sid_offset": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The offset ID of the L3out Node Sid Profile object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_l3out_node_sid_profile") +} + +func (d *MplsNodeSidPDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_l3out_node_sid_profile") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_l3out_node_sid_profile") +} + +func (d *MplsNodeSidPDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_l3out_node_sid_profile") + var data *MplsNodeSidPResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setMplsNodeSidPId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetMplsNodeSidPAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) + + getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_l3out_node_sid_profile data source", + fmt.Sprintf("The aci_l3out_node_sid_profile data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_l3out_node_sid_profile_test.go b/internal/provider/data_source_aci_l3out_node_sid_profile_test.go new file mode 100644 index 000000000..7d5e3bccf --- /dev/null +++ b/internal/provider/data_source_aci_l3out_node_sid_profile_test.go @@ -0,0 +1,54 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceMplsNodeSidPWithL3extLoopBackIfP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigMplsNodeSidPDataSourceDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_l3out_node_sid_profile.test", "name_alias", ""), + ), + }, + { + Config: testConfigMplsNodeSidPNotExistingL3extLoopBackIfP, + ExpectError: regexp.MustCompile("Failed to read aci_l3out_node_sid_profile data source"), + }, + }, + }) +} + +const testConfigMplsNodeSidPDataSourceDependencyWithL3extLoopBackIfP = testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP + ` +data "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + depends_on = [aci_l3out_node_sid_profile.test] +} +` + +const testConfigMplsNodeSidPNotExistingL3extLoopBackIfP = testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP + ` +data "aci_l3out_node_sid_profile" "test_non_existing" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "2" + depends_on = [aci_l3out_node_sid_profile.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2f962970d..b870740db 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -207,6 +207,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewMgmtInstPResource, NewMgmtRsOoBConsResource, NewMgmtSubnetResource, + NewMplsNodeSidPResource, NewPimRouteMapEntryResource, NewPimRouteMapPolResource, NewTagAnnotationResource, @@ -229,6 +230,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewMgmtInstPDataSource, NewMgmtRsOoBConsDataSource, NewMgmtSubnetDataSource, + NewMplsNodeSidPDataSource, NewPimRouteMapEntryDataSource, NewPimRouteMapPolDataSource, NewTagAnnotationDataSource, diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go new file mode 100644 index 000000000..587198326 --- /dev/null +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -0,0 +1,623 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &MplsNodeSidPResource{} +var _ resource.ResourceWithImportState = &MplsNodeSidPResource{} + +func NewMplsNodeSidPResource() resource.Resource { + return &MplsNodeSidPResource{} +} + +// MplsNodeSidPResource defines the resource implementation. +type MplsNodeSidPResource struct { + client *client.Client +} + +// MplsNodeSidPResourceModel describes the resource data model. +type MplsNodeSidPResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + LoopbackAddr types.String `tfsdk:"loopback_address"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + Sidoffset types.String `tfsdk:"sid_offset"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationMplsNodeSidPResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationMplsNodeSidPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagMplsNodeSidPResourceModel describes the resource data model for the children without relation ships. +type TagTagMplsNodeSidPResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type MplsNodeSidPIdentifier struct { + Sidoffset types.String +} + +func (r *MplsNodeSidPResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_l3out_node_sid_profile") + resp.TypeName = req.ProviderTypeName + "_l3out_node_sid_profile" + tflog.Debug(ctx, "End metadata of resource: aci_l3out_node_sid_profile") +} + +func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_l3out_node_sid_profile") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The l3out_node_sid_profile resource for the 'mplsNodeSidP' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the L3out Node Sid Profile object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the L3out Node Sid Profile object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the L3out Node Sid Profile object.`, + }, + "loopback_address": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The loopback address of the L3out Node Sid Profile object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the L3out Node Sid Profile object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the L3out Node Sid Profile object.`, + }, + "sid_offset": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The offset ID of the L3out Node Sid Profile object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_l3out_node_sid_profile") +} + +func (r *MplsNodeSidPResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_l3out_node_sid_profile") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client + tflog.Debug(ctx, "End configure of resource: aci_l3out_node_sid_profile") +} + +func (r *MplsNodeSidPResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_l3out_node_sid_profile") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *MplsNodeSidPResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setMplsNodeSidPId(ctx, stateData) + getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *MplsNodeSidPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setMplsNodeSidPId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) +} + +func (r *MplsNodeSidPResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_l3out_node_sid_profile") + var data *MplsNodeSidPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) + + getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *MplsNodeSidPResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) +} + +func (r *MplsNodeSidPResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_l3out_node_sid_profile") + var data *MplsNodeSidPResourceModel + var stateData *MplsNodeSidPResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getMplsNodeSidPCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetMplsNodeSidPAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) +} + +func (r *MplsNodeSidPResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_l3out_node_sid_profile") + var data *MplsNodeSidPResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "mplsNodeSidP", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_l3out_node_sid_profile with id '%s'", data.Id.ValueString())) +} + +func (r *MplsNodeSidPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_l3out_node_sid_profile") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *MplsNodeSidPResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_l3out_node_sid_profile with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_l3out_node_sid_profile") +} + +func getAndSetMplsNodeSidPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *MplsNodeSidPResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "mplsNodeSidP,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("mplsNodeSidP").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("mplsNodeSidP").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + setMplsNodeSidPParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "loopbackAddr" { + data.LoopbackAddr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "sidoffset" { + data.Sidoffset = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationMplsNodeSidPList := make([]TagAnnotationMplsNodeSidPResourceModel, 0) + TagTagMplsNodeSidPList := make([]TagTagMplsNodeSidPResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationMplsNodeSidP := TagAnnotationMplsNodeSidPResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationMplsNodeSidP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationMplsNodeSidP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationMplsNodeSidPList = append(TagAnnotationMplsNodeSidPList, TagAnnotationMplsNodeSidP) + } + if childClassName == "tagTag" { + TagTagMplsNodeSidP := TagTagMplsNodeSidPResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagMplsNodeSidP.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagMplsNodeSidP.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagMplsNodeSidPList = append(TagTagMplsNodeSidPList, TagTagMplsNodeSidP) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationMplsNodeSidPList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagMplsNodeSidPList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'mplsNodeSidP'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getMplsNodeSidPRn(ctx context.Context, data *MplsNodeSidPResourceModel) string { + rn := "nodesidp-{sidoffset}" + for _, identifier := range []string{"sidoffset"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setMplsNodeSidPParentDn(ctx context.Context, dn string, data *MplsNodeSidPResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setMplsNodeSidPId(ctx context.Context, data *MplsNodeSidPResourceModel) { + rn := getMplsNodeSidPRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getMplsNodeSidPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getMplsNodeSidPTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *MplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getMplsNodeSidPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *MplsNodeSidPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationMplsNodeSidPResourceModel, tagTagPlan, tagTagState []TagTagMplsNodeSidPResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getMplsNodeSidPTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getMplsNodeSidPTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.LoopbackAddr.IsNull() && !data.LoopbackAddr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["loopbackAddr"] = data.LoopbackAddr.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + if !data.Sidoffset.IsNull() && !data.Sidoffset.IsUnknown() { + payloadMap["attributes"].(map[string]string)["sidoffset"] = data.Sidoffset.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"mplsNodeSidP": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_l3out_node_sid_profile_test.go b/internal/provider/resource_aci_l3out_node_sid_profile_test.go new file mode 100644 index 000000000..5a10ea8c2 --- /dev/null +++ b/internal/provider/resource_aci_l3out_node_sid_profile_test.go @@ -0,0 +1,256 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceMplsNodeSidPWithL3extLoopBackIfP(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigMplsNodeSidPAllDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", "description"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "1.1.1.1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", "node_sid_profile"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", "name_alias"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigMplsNodeSidPResetDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", ""), + ), + }, + // Import testing + { + ResourceName: "aci_l3out_node_sid_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", ""), + ), + }, + // Update with children + { + Config: testConfigMplsNodeSidPChildrenDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.value", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_l3out_node_sid_profile.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "sid_offset", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "description", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "loopback_address", "0.0.0.0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.value", "value_2"), + ), + }, + // Update with children removed from config + { + Config: testConfigMplsNodeSidPChildrenRemoveFromConfigDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigMplsNodeSidPChildrenRemoveOneDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigMplsNodeSidPChildrenRemoveAllDependencyWithL3extLoopBackIfP, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_l3out_node_sid_profile.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigMplsNodeSidPMinDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" +} +` + +const testConfigMplsNodeSidPAllDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + annotation = "annotation" + description = "description" + loopback_address = "1.1.1.1" + name = "node_sid_profile" + name_alias = "name_alias" +} +` + +const testConfigMplsNodeSidPResetDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + annotation = "orchestrator:terraform" + description = "" + loopback_address = "0.0.0.0" + name = "" + name_alias = "" +} +` +const testConfigMplsNodeSidPChildrenDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigMplsNodeSidPChildrenRemoveFromConfigDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" +} +` + +const testConfigMplsNodeSidPChildrenRemoveOneDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigMplsNodeSidPChildrenRemoveAllDependencyWithL3extLoopBackIfP = testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt + ` +resource "aci_l3out_node_sid_profile" "test" { + parent_dn = aci_l3out_loopback_interface_profile.test.id + sid_offset = "1" + annotations = [] + tags = [] +} +` diff --git a/internal/provider/test_constants.go b/internal/provider/test_constants.go index 426d357a4..e44ac5da0 100644 --- a/internal/provider/test_constants.go +++ b/internal/provider/test_constants.go @@ -70,3 +70,21 @@ resource "aci_l3_outside" "test" { relation_l3ext_rs_ectx = aci_vrf.test.id } ` + +const testConfigL3extLoopBackIfPMinDependencyWithL3extRsNodeL3OutAtt = testConfigL3extOutMin + ` +resource "aci_logical_node_profile" "test" { + l3_outside_dn = aci_l3_outside.test.id + name = "logical_node_profile" +} + +resource "aci_logical_node_to_fabric_node" "test" { + logical_node_profile_dn = aci_logical_node_profile.test.id + tdn = "topology/pod-2/node-2011" + rtr_id = "1.2.3.4" +} + +resource "aci_l3out_loopback_interface_profile" "test" { + fabric_node_dn = aci_logical_node_to_fabric_node.test.id + addr = "1.2.3.5" +} +`