diff --git a/CHANGELOG.md b/CHANGELOG.md index e2d6701d..037e52dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.1.8-beta (June 26, 2023) +BUGFIXES: +* Local state of Authenticate Template not updated #176 +* Resource dnacenter_pnp_device_site_claim generates wrong POST BODY when multiple config_parameterssections are present #175 +* Creation of enterprise SSID #148 + ## 1.1.7-beta (May 11, 2023) BUGFIXES: * Resource dnacenter_pnp_device_site_claim generates wrong POST BODY when multiple config_parameters sections are present #175 diff --git a/README.md b/README.md index b52dc3c9..f41ef3f9 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,27 @@ provider "dnacenter" { There are several examples of the use of the provider within the folder [samples](./examples/samples) +## Example for_each +```hcl +locals { + interfaces = { + "1" = { description = "desc1", interface_uuid = "c6820b57-ecde-4b6d-98db-06ba10486809" }, + "2" = { description = "desc2", interface_uuid = "c6820b57-ecde-4b6d-98db-06ba10486801" }, + "3" = { description = "desc3", interface_uuid = "c6820b57-ecde-4b6d-98db-06ba10486802" } + } +} + +resource "dnacenter_interface_update" "example" { + provider = dnacenter + for_each = local.interfaces + parameters { + description = each.value.description + interface_uuid = each.value.interface_uuid + vlan_id = each.key + } +} +``` + ## Developing the Provider If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed diff --git a/dnacenter/data_source_sda_fabric_authentication_profile.go b/dnacenter/data_source_sda_fabric_authentication_profile.go index 3943adbf..02745477 100644 --- a/dnacenter/data_source_sda_fabric_authentication_profile.go +++ b/dnacenter/data_source_sda_fabric_authentication_profile.go @@ -156,7 +156,7 @@ func flattenSdaGetDefaultAuthenticationProfileFromSdaFabricItem(item *dnacenters respItem["authenticate_template_name"] = item.AuthenticateTemplateName respItem["authentication_order"] = item.AuthenticationOrder respItem["dot1x_to_mab_fallback_timeout"] = item.Dot1XToMabFallbackTimeout - respItem["wake_on_lan"] = boolPtrToString(item.WakeOnLan) + respItem["wake_on_lan"] = item.WakeOnLan respItem["number_of_hosts"] = item.NumberOfHosts respItem["status"] = item.Status respItem["description"] = item.Description @@ -164,3 +164,14 @@ func flattenSdaGetDefaultAuthenticationProfileFromSdaFabricItem(item *dnacenters respItem, } } + +func flattenSdaGetDefaultAuthenticationProfileFromSdaFabricPayload(item *dnacentersdkgo.ResponseSdaGetDefaultAuthenticationProfileFromSdaFabric) []map[string]interface{} { + if item == nil { + return nil + } + respItem := make(map[string]interface{}) + respItem["payload"] = flattenSdaGetDefaultAuthenticationProfileFromSdaFabricItem(item) + return []map[string]interface{}{ + respItem, + } +} diff --git a/dnacenter/resource_pnp_device_site_claim.go b/dnacenter/resource_pnp_device_site_claim.go index f4810c5b..787e07d0 100644 --- a/dnacenter/resource_pnp_device_site_claim.go +++ b/dnacenter/resource_pnp_device_site_claim.go @@ -280,7 +280,7 @@ func expandRequestPnpDeviceSiteClaimClaimADeviceToASite(ctx context.Context, key request.ImageInfo = *expandRequestPnpDeviceSiteClaimClaimADeviceToASiteImageInfo(ctx, key+".image_info.0", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_info")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_info")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_info")))) { - request.ConfigInfo = *expandRequestPnpDeviceSiteClaimClaimADeviceToASiteConfigInfoArray(ctx, key+".config_info", d) + request.ConfigInfo = *expandRequestPnpDeviceSiteClaimClaimADeviceToASiteConfigInfo(ctx, key+".config_info", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".rf_profile")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rf_profile")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rf_profile")))) { request.RfProfile = interfaceToString(v) @@ -317,26 +317,6 @@ func expandRequestPnpDeviceSiteClaimClaimADeviceToASiteImageInfo(ctx context.Con return &request } -func expandRequestPnpDeviceSiteClaimClaimADeviceToASiteConfigInfoArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestDeviceOnboardingPnpClaimADeviceToASiteConfigInfo { - request := []dnacentersdkgo.RequestDeviceOnboardingPnpClaimADeviceToASiteConfigInfo{} - key = fixKeyAccess(key) - o := d.Get(key) - if o == nil { - return nil - } - objs := o.([]interface{}) - if len(objs) == 0 { - return nil - } - for item_no := range objs { - i := expandRequestPnpDeviceSiteClaimClaimADeviceToASiteConfigInfo(ctx, fmt.Sprintf("%s.%d", key, item_no), d) - if i != nil { - request = append(request, *i) - } - } - return &request -} - func expandRequestPnpDeviceSiteClaimClaimADeviceToASiteConfigInfo(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDeviceOnboardingPnpClaimADeviceToASiteConfigInfo { request := dnacentersdkgo.RequestDeviceOnboardingPnpClaimADeviceToASiteConfigInfo{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_id")))) { diff --git a/dnacenter/resource_sda_fabric_authentication_profile.go b/dnacenter/resource_sda_fabric_authentication_profile.go index 81f5ea7e..6c33306e 100644 --- a/dnacenter/resource_sda_fabric_authentication_profile.go +++ b/dnacenter/resource_sda_fabric_authentication_profile.go @@ -115,40 +115,64 @@ func resourceSdaFabricAuthenticationProfile() *schema.Resource { "authenticate_template_name": &schema.Schema{ Description: `Authenticate Template Name `, - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, }, "authentication_order": &schema.Schema{ Description: `Authentication Order `, - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, }, "dot1x_to_mab_fallback_timeout": &schema.Schema{ Description: `Dot1x To MabFallback Timeout( Allowed range is [3-120]) `, - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, }, "number_of_hosts": &schema.Schema{ Description: `Number Of Hosts `, - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, }, "site_name_hierarchy": &schema.Schema{ Description: `Path of sda Fabric Site `, - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, }, "wake_on_lan": &schema.Schema{ Description: `Wake On Lan `, - Type: schema.TypeString, - ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), - Optional: true, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + DiffSuppressFunc: diffSupressOptional(), + Computed: true, + }, + "description": &schema.Schema{ + Description: `Authenticate Template info reterieved successfully in sda fabric site + `, + Type: schema.TypeString, + Computed: true, + }, + "status": &schema.Schema{ + Description: `Status + `, + Type: schema.TypeString, + Computed: true, }, }, }, @@ -189,6 +213,7 @@ func resourceSdaFabricAuthenticationProfileCreate(ctx context.Context, d *schema d.SetId(joinResourceID(resourceMap)) return resourceSdaFabricAuthenticationProfileRead(ctx, d, m) } + response1, restyResp1, err := client.Sda.AddDefaultAuthenticationTemplateInSdaFabric(request1) if err != nil || response1 == nil { if restyResp1 != nil { @@ -200,6 +225,7 @@ func resourceSdaFabricAuthenticationProfileCreate(ctx context.Context, d *schema "Failure when executing DeployAuthenticationTemplateInSdaFabric", err)) return diags } + executionId := response1.ExecutionID log.Printf("[DEBUG] ExecutionID => %s", executionId) if executionId != "" { @@ -234,6 +260,7 @@ func resourceSdaFabricAuthenticationProfileCreate(ctx context.Context, d *schema return diags } } + resourceMap := make(map[string]string) resourceMap["site_name_hierarchy"] = vvSiteNameHierarchy resourceMap["authenticate_template_name"] = vvAuthenticateTemplateName @@ -285,6 +312,15 @@ func resourceSdaFabricAuthenticationProfileRead(ctx context.Context, d *schema.R err)) return diags } + + vItem2 := flattenSdaGetDefaultAuthenticationProfileFromSdaFabricPayload(response1) + + if err := d.Set("parameters", vItem2); err != nil { + diags = append(diags, diagError( + "Failure when setting GetDefaultAuthenticationProfileFromSdaFabric response", + err)) + return diags + } return diags } diff --git a/dnacenter/resource_wireless_enterprise_ssid.go b/dnacenter/resource_wireless_enterprise_ssid.go index 651eb4de..9b8b7b74 100644 --- a/dnacenter/resource_wireless_enterprise_ssid.go +++ b/dnacenter/resource_wireless_enterprise_ssid.go @@ -379,7 +379,7 @@ func resourceWirelessEnterpriseSSID() *schema.Resource { Description: `ssidName path parameter. Enter the SSID name to be deleted `, Type: schema.TypeString, - Required: true, + Optional: true, }, "traffic_type": &schema.Schema{ Description: `Traffic Type Enum (voicedata or data ) diff --git a/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf b/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf index 9762808c..435f2fc1 100644 --- a/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf @@ -14,7 +14,7 @@ provider "dnacenter" { data "dnacenter_sda_virtual_network" "example" { provider = dnacenter site_name_hierarchy = "Global/San Francisco" - virtual_network_name = "string" + virtual_network_name = "Test_terraform" } output "dnacenter_sda_virtual_network_example" { diff --git a/examples/samples/resources/dnacenter_pnp_device_site_claim/resource.tf b/examples/samples/resources/dnacenter_pnp_device_site_claim/resource.tf index 9454f3f5..7228e643 100644 --- a/examples/samples/resources/dnacenter_pnp_device_site_claim/resource.tf +++ b/examples/samples/resources/dnacenter_pnp_device_site_claim/resource.tf @@ -20,7 +20,7 @@ resource "dnacenter_pnp_device_site_claim" "example" { device_id = "61fd411fd86a6c29631156f2" site_id = "9625864c-2228-42ec-ac9c-1d0e8e099825" type = "Default" - hostname = "Catalyst2" + # hostname = "Catalyst2" image_info { image_id = "" skip = "true" diff --git a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf index 7864ff2b..c92a9cc4 100644 --- a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf +++ b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf @@ -16,13 +16,13 @@ resource "dnacenter_reserve_ip_subpool" "example" { provider = dnacenter parameters { ipv4_prefix = "false" - ipv4_global_pool = "10.43.192.0" + ipv4_global_pool = "10.0.0.0" //id = "string" # ipv4_dhcp_servers = [] # ipv4_dns_servers = [] - ipv4_gate_way = "10.43.192.1" - ipv4_prefix_length = 1 + ipv4_gate_way = "10.0.0.1" + ipv4_prefix_length = 27 ipv4_subnet = "17" # ipv4_total_host = 2 # ipv6_address_space = "false" diff --git a/examples/samples/resources/dnacenter_sda_fabric_authentication_profile/resource.tf b/examples/samples/resources/dnacenter_sda_fabric_authentication_profile/resource.tf index b99e21bc..1c8f44af 100644 --- a/examples/samples/resources/dnacenter_sda_fabric_authentication_profile/resource.tf +++ b/examples/samples/resources/dnacenter_sda_fabric_authentication_profile/resource.tf @@ -16,11 +16,11 @@ resource "dnacenter_sda_fabric_authentication_profile" "example" { provider = dnacenter parameters { payload { - authenticate_template_name = "string" - authentication_order = "string" - dot1x_to_mab_fallback_timeout = "string" - number_of_hosts = "string" - site_name_hierarchy = "string" + authenticate_template_name = "Open Authentication" + authentication_order = "dot1x" + dot1x_to_mab_fallback_timeout = "21" + number_of_hosts = "Unlimited" + site_name_hierarchy = "Global/San Francisco" wake_on_lan = "false" } } diff --git a/examples/samples/resources/dnacenter_sda_virtual_network/resource.tf b/examples/samples/resources/dnacenter_sda_virtual_network/resource.tf index 08bb5ec2..a2a25f31 100644 --- a/examples/samples/resources/dnacenter_sda_virtual_network/resource.tf +++ b/examples/samples/resources/dnacenter_sda_virtual_network/resource.tf @@ -11,10 +11,8 @@ terraform { resource "dnacenter_sda_virtual_network" "example" { provider = dnacenter parameters { - payload { site_name_hierarchy = "Global/New Jersey/MurrayHill/test/TestFloor" - virtual_network_name = "GUEST_VN" - } + virtual_network_name = "ANSIBLE80" } } diff --git a/examples/samples/resources/dnacenter_sda_virtual_network_ip_pool/resource.tf b/examples/samples/resources/dnacenter_sda_virtual_network_ip_pool/resource.tf index b0428eda..6ae0b823 100644 --- a/examples/samples/resources/dnacenter_sda_virtual_network_ip_pool/resource.tf +++ b/examples/samples/resources/dnacenter_sda_virtual_network_ip_pool/resource.tf @@ -1,23 +1,35 @@ +terraform { + required_providers { + dnacenter = { + version = "1.1.7-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} +provider "dnacenter" { + debug = "true" +} resource "dnacenter_sda_virtual_network_ip_pool" "example" { provider = dnacenter parameters { - auto_generate_vlan_name = "false" - ip_pool_name = "string" - is_common_pool = "false" - is_ip_directed_broadcast = "false" - is_l2_flooding_enabled = "false" - is_layer2_only = "false" - is_this_critical_pool = "false" - is_wireless_pool = "false" - pool_type = "string" - scalable_group_name = "string" - site_name_hierarchy = "string" - traffic_type = "string" - virtual_network_name = "string" - vlan_id = "string" - vlan_name = "string" + # auto_generate_vlan_name = "false" + ip_pool_name = "Customer_C_ZH-Transit-Pool" + # is_common_pool = "false" + # is_ip_directed_broadcast = "false" + # is_l2_flooding_enabled = "false" + # is_layer2_only = "false" + # is_this_critical_pool = "false" + # is_wireless_pool = "false" + # pool_type = "string" + # scalable_group_name = "string" + # traffic_type = "string" + site_name_hierarchy = "Global/San Francisco" + virtual_network_name = "Test_Terraform2" + # vlan_id = "string" + # vlan_name = "string" } } diff --git a/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf b/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf index af40d3c3..2fefc5d5 100644 --- a/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf @@ -16,27 +16,8 @@ provider "dnacenter" { resource "dnacenter_wireless_enterprise_ssid" "example" { provider = dnacenter parameters { - - basic_service_set_client_idle_timeout = 0 - client_exclusion_timeout = 0 - enable_basic_service_set_max_idle = "true" - enable_broadcast_ssi_d = "true" - enable_client_exclusion = "true" - enable_directed_multicast_service = "true" - enable_fast_lane = "true" - enable_mac_filtering = "true" - enable_neighbor_list = "true" - enable_session_time_out = "true" - fast_transition = "Adaptive" - mfp_client_protection = "Optional" - name = "TestPersonal2" - passphrase = "testtest3" - radio_policy = "Dual band operation (2.4GHz and 5GHz)" - security_level = "WPA2_PERSONAL" - session_time_out = 0 - traffic_type = "voicedata" - site = "Global/New Jersey" - + name = "TestPersonal2" + security_level = "WPA2_ENTERPRISE" } } diff --git a/go.mod b/go.mod index 9904e019..a21fd869 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,7 @@ require ( ) require ( - github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.5 + github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.6 github.com/mattn/go-isatty v0.0.18 // indirect golang.org/x/text v0.9.0 // indirect ) diff --git a/go.sum b/go.sum index 86eb5a38..b9667564 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.5 h1:XdxheMSe+v+F30ocE5ZlI6LA1YGRvsvCD+0Fi2sx5hw= -github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.5/go.mod h1:1Ff9JsyS1dAyeEr+xa2cUtTiFO411++mVEUo9ROZXj8= +github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.6 h1:7AM6UD/WLTsEK3sSILmrzr9/Q5BM3XZVnUgI+KXemfk= +github.com/cisco-en-programmability/dnacenter-go-sdk/v5 v5.0.6/go.mod h1:1Ff9JsyS1dAyeEr+xa2cUtTiFO411++mVEUo9ROZXj8= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=