Skip to content

Commit

Permalink
Merge pull request #185 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop v1.1.8-beta
  • Loading branch information
fmunozmiranda authored Jun 26, 2023
2 parents 40e45e7 + 05680e7 commit e30604f
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 88 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion dnacenter/data_source_sda_fabric_authentication_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,22 @@ 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
return []map[string]interface{}{
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,
}
}
22 changes: 1 addition & 21 deletions dnacenter/resource_pnp_device_site_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")))) {
Expand Down
62 changes: 49 additions & 13 deletions dnacenter/resource_sda_fabric_authentication_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down Expand Up @@ -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 {
Expand All @@ -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 != "" {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

}
Expand Down
2 changes: 1 addition & 1 deletion dnacenter/resource_wireless_enterprise_ssid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit e30604f

Please sign in to comment.