cisco-en-programmability / terraform-provider-dnacenter

https://registry.terraform.io/providers/cisco-en-programmability/dnacenter/latest/docs
MIT License
14 stars 12 forks source link

GET operations on ´dnacenter_sda_fabric_border_device´ not working #230

Closed edudppaz closed 1 year ago

edudppaz commented 1 year ago

Prerequisites

Describe the bug The read operations on the resource ´dnacenter_sda_fabric_border_device´ are not working. After doing changes with the resource, there is no data coming back from DNA Center being saved into the state file. When using the "data" type of the resource, the data being saved in terraform state is empty.

Tested via API directly towards DNA Center, the data is returned with no issue.

The terraform logs, show the DNA Center correctly sending the data back, however, this data is not being saved into the state, neither on the resource type, nor the data type:

TF logs DNAC response:

=============================================================================: timestamp=2023-10-23T20:59:34.223+0200
2023-10-23T20:59:34.223+0200 [INFO]  provider.terraform-provider-dnacenter_v1.1.22-beta: 2023/10/23 20:59:34 [DEBUG] Retrieved response {"status":"success","description":"Border device info retrieved successfully from sda fabric."}: timestamp=2023-10-23T20:59:34.223+0200
2023-10-23T20:59:34.227+0200 [INFO]  provider.terraform-provider-dnacenter_v1.1.22-beta: 2023/10/23 20:59:34 [DEBUG] Selected method: GetBorderDeviceDetailFromSdaFabric: timestamp=2023-10-23T20:59:34.227+0200
2023-10-23T20:59:34.933+0200 [INFO]  provider.terraform-provider-dnacenter_v1.1.22-beta: 2023/10/23 20:59:34 [DEBUG] [RESTY]
==============================================================================
~~~ REQUEST ~~~
GET  /dna/intent/api/v1/business/sda/border-device?deviceManagementIpAddress=100.68.0.190  HTTP/1.1
HOST   : 100.68.0.71
HEADERS:
                Accept: application/json
                Content-Type: application/json
                User-Agent: go-resty/2.7.0 (https://github.com/go-resty/resty)
                X-Auth-Token: 
BODY   :
***** NO CONTENT *****
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS       : 200 OK
PROTO        : HTTP/1.1
RECEIVED AT  : 2023-10-23T20:59:34.932470247+02:00
TIME DURATION: 705.329721ms
HEADERS      :
                Bapiexecutionid: c1a94226-5cfe-41b4-9e7b-9bbf22becb3d
                Cache-Control: no-store
                Connection: keep-alive
                Content-Length: 10042
                Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: data:
                Content-Type: application/json
                Date: Mon, 23 Oct 2023 18:59:29 GMT
                Pragma: no-cache
                Strict-Transport-Security: max-age=31536000; includeSubDomains
                Via: api-gateway
                X-Content-Type-Options: nosniff
                X-Frame-Options: SAMEORIGIN
                X-Xss-Protection: 1
BODY         :
{
   "id": "d6595a5e-e3da-423f-9063-b5af725b55e2",
   "instanceId": 946323378,
   "instanceCreatedOn": 1697716699914,
   "instanceUpdatedOn": 1697716699914,
  "instanceVersion": 7,
   "createTime": 1697716699898,
   "deployed": false,
   "isSeeded": false,
   "isStale": false,
   "lastUpdateTime": 1697716699898,
   "name": "devhf-osl-bn1.monet.local",
   "namespace": "a1739dc3-748d-4549-8dd6-a805b9b95cf7",
   "provisioningState": "DEFINED",
   "resourceVersion": 7,
   "targetIdList": [],
   "type": "DeviceInfo",
   "cfsChangeInfo": [],
   "customProvisions": [],
   "anchoredManagedSites": [],
   "configs": [],
   "lineCardMigrationStatus": "NOT_NEEDED",
   "managedSites": [],
   "networkDeviceId": "aecb362f-163f-4188-bacd-55900c3b0ddc",
   "primaryManagedSites": [],
   "rlanList": [],
   "roles": [
      "MAPSERVER",
      "BORDERNODE"
   ],
   "saveWanConnectivityDetailsOnly": false,
   "secondaryManagedSites": [],
   "siteId": "7191cdbb-6f57-4403-87a5-fbd24520ed0f",
   "tertiaryManagedSites": [],
   "akcSettingsCfs": [],
   "deviceInterfaceGroupInfo": [],
   "deviceInterfaceInfo": [],
   "deviceInterfaceInfoContainer": {
      "idRef": "cabfa7fa-9019-47ae-931b-479743d14f69"
   },
   "deviceSettings": {
      "id": "d268aeb6-0f71-4140-bac8-ccb1c7b89afa",
      "instanceId": 946375432,
      "instanceCreatedOn": 1697725146876,
      "instanceUpdatedOn": 1697725146876,
      "instanceVersion": 3,
      "connectedTo": [],
      "cpu": 0,
      "dhcpEnabled": true,
      "externalConnectivityIpPool": "8f1dca5c-f84b-4bb6-a545-3392085d1c37",
      "externalDomainRoutingProtocol": "BGP",
      "internalDomainProtocolNotation": "ASDOT",
      "internalDomainProtocolNumber": "65003",
      "isMulticastOverTransitEnabled": false,
      "memory": 0,
      "nodeType": [
         "EXTERNAL"
      ],
      "priority": 10,
      "storage": 0,
      "extConnectivitySettings": [
         {
            "id": "c87519b4-0f0d-409e-a8b1-04977947bcdb",
            "instanceId": 946376433,
            "instanceCreatedOn": 1697725146876,
            "instanceUpdatedOn": 1697725146876,
            "instanceVersion": 3,
            "description": "Uplink to Fusion",
            "externalDomainProtocolNotation": "ASDOT",
            "externalDomainProtocolNumber": "65010",
            "interfaceUuid": "GigabitEthernet1/0/1",
            "policyPropagationEnabled": false,
            "policySgtTag": 0,
            "l2Handoff": [],
            "l3Handoff": [
               {
                  "id": "7b64f7f2-2a55-49c0-a7d9-8cf9b50dec38",
                  "instanceId": 946377438,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                  "localIpAddress": "100.64.0.9/30",
                  "remoteIpAddress": "100.64.0.10/30",
                  "remoteIpAddresses": [
                     "100.64.0.10/30"
                  ],
                  "vlanId": 2208,
                  "virtualNetwork": {
                     "idRef": "8fc3cfb7-4e3a-42bd-bd09-50cf5fbfcdcc"
                  },
                  "displayName": "0"
               },
               {
                  "id": "8ce54d8e-bdf5-4edb-8967-07a9349ba352",
                  "instanceId": 946377439,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                  "localIpAddress": "100.64.0.1/30",
                  "remoteIpAddress": "100.64.0.2/30",
                  "remoteIpAddresses": [
                     "100.64.0.2/30"
                  ],
                  "vlanId": 2206,
                  "virtualNetwork": {
                     "idRef": "5f1ebc91-a547-4c5e-91b9-6694c7031625"
                  },
                  "displayName": "0"
               },
               {
                  "id": "e3c27557-3dba-4e4d-b472-078d8a7e66c0",
                  "instanceId": 946377440,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                  "localIpAddress": "100.64.0.5/30",
                  "remoteIpAddress": "100.64.0.6/30",
                  "remoteIpAddresses": [
                     "100.64.0.6/30"
                  ],
                  "vlanId": 2207,
                  "virtualNetwork": {
                     "idRef": "d6c0a384-673d-4189-bf73-73ad0ee2ac77"
                  },
                  "displayName": "0"
               }
            ],
            "displayName": "0"
         },
         {
            "id": "e3f52bcc-45d7-447d-a3bd-915dc03a3d8f",
            "instanceId": 946376434,
            "instanceCreatedOn": 1697725146876,
            "instanceUpdatedOn": 1697725146876,
            "instanceVersion": 3,
            "description": "Uplink to Fusion",
            "externalDomainProtocolNotation": "ASDOT",
            "externalDomainProtocolNumber": "65010",
            "interfaceUuid": "GigabitEthernet1/0/2",
            "policyPropagationEnabled": false,
            "policySgtTag": 0,
            "l2Handoff": [],
            "l3Handoff": [
               {
                  "id": "7094b48b-b6db-4f0e-9f75-a978c89be415",
                  "instanceId": 946377441,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                  "localIpAddress": "100.64.0.13/30",
                  "remoteIpAddress": "100.64.0.14/30",
                  "remoteIpAddresses": [
                     "100.64.0.14/30"
                  ],
                  "vlanId": 2306,
                  "virtualNetwork": {
                     "idRef": "5f1ebc91-a547-4c5e-91b9-6694c7031625"
                  },
                  "displayName": "0"
               },
               {
                  "id": "6b114ee1-46c2-42d6-a20d-a9fcb08dece1",
                  "instanceId": 946377442,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                 "localIpAddress": "100.64.0.17/30",
                  "remoteIpAddress": "100.64.0.18/30",
                  "remoteIpAddresses": [
                     "100.64.0.18/30"
                  ],
                  "vlanId": 2307,
                  "virtualNetwork": {
                     "idRef": "d6c0a384-673d-4189-bf73-73ad0ee2ac77"
                  },
                  "displayName": "0"
               },
               {
                  "id": "51e30d3d-76bb-4ad4-acd0-2b8de36277c0",
                  "instanceId": 946377443,
                  "instanceCreatedOn": 1697725146876,
                  "instanceUpdatedOn": 1697725146876,
                  "instanceVersion": 3,
                  "localIpAddress": "100.64.0.21/30",
                  "remoteIpAddress": "100.64.0.22/30",
                  "remoteIpAddresses": [
                     "100.64.0.22/30"
                  ],
                  "vlanId": 2308,
                  "virtualNetwork": {
                     "idRef": "8fc3cfb7-4e3a-42bd-bd09-50cf5fbfcdcc"
                  },
                  "displayName": "0"
               }
            ],
            "displayName": "0"
         }
      ],
      "internetVn": [],
      "displayName": "0"
   },
   "deviceWlanSchedulerInfo": [],
   "migrationStatus": [],
   "networkWideSettings": {
      "id": "4056639e-8922-4fa5-b3d6-aebcb8e3dc14",
      "instanceId": 946324379,
      "instanceCreatedOn": 1697716699914,
      "instanceUpdatedOn": 1697716699914,
      "instanceVersion": 2,
      "aaa": [
         {
            "id": "626c40f8-d5ca-4e3f-9095-c732b362cd0f",
            "acctPort": 1813,
            "authPort": 1812,
            "authenticationType": [
               "NETWORKAUTH"
            ],
            "encryptionScheme": "",
            "ipAddress": {
               "id": "de2f5a1e-f1af-4840-955a-e74b7dd3beb3",
               "address": "100.68.0.137"
            },
            "isIseEnabled": true,
            "panIpAddress": [
               "100.68.0.137"
            ],
            "panSharedKey": 
            "protocol": "TACACS",
            "retries": "3",
            "serverPriority": 1,
            "sharedKey": ,
            "timeout": "3"
         },
         {
            "id": "18e1fd24-e95b-4133-8f24-740ecb0ac0e0",
            "acctPort": 1813,
            "authPort": 1812,
            "authenticationType": [
               "CLIENTAUTH"
            ],
            "encryptionScheme": "",
            "ipAddress": {
               "id": "a7f8988c-00c8-4d76-b446-a920437edf44",
               "address": "100.68.0.137"
            },
            "isIseEnabled": true,
            "panIpAddress": [
               "100.68.0.137"
            ],
            "panSharedKey": 
            "protocol": "RADIUS",
            "retries": "3",
            "serverPriority": 1,
            "sharedKey": ",
            "timeout": "3"
         }
      ],
      "acl": [],
      "apjoinprofile": [],
      "cmx": [],
      "dhcp": [],
      "dns": [
         {
            "id": "fcc02ca3-7dc0-4c09-8347-eca82ce4644e",
            "domainName": "monet.local",
            "ip": {
               "id": "ae4f56af-7cb0-4585-9211-e2c654b85049",
               "address": "100.68.0.141"
            },
            "secondaryIp": {
               "id": "2dcbe6b2-dca8-402d-8487-bf152f1a5070",
               "address": "100.68.0.135"
            }
         }
      ],
      "ipdtEnabled": true,
      "isBridgeModeVm": false,
      "ldap": [],
      "mesh": [],
      "nativeVlan": [],
      "netflow": [],
      "ntp": [
         {
            "id": "cf21bf87-013a-4bb9-87a4-e037951d8a73",
            "ipAddress": {
               "id": "9010f534-e083-4f39-b657-ea22322b12fb",
               "address": "100.68.0.141"
            }
         },
         {
            "id": "f840baf0-8b24-47e3-9d4e-6b4da7e8cd15",
            "ipAddress": {
               "id": "b12e9166-1980-4985-9466-1428758561aa",
               "address": "10.179.27.1"
            }
         },
         {
            "id": "414de424-e11d-4a90-9794-51eae5997614",
            "ipAddress": {
               "id": "681285c3-fe3a-4a1d-b97c-3e9b0115a88c",
               "address": "10.179.27.2"
            }
         },
         {
            "id": "f75a5f51-a9f3-4cc6-a001-aabc38818101",
            "ipAddress": {
               "id": "c65d2b28-9ac1-454f-9937-6891eb1515fb",
               "address": "10.179.27.3"
            }
         },
         {
            "id": "96074012-9a6b-4620-9fc2-8a1e4e34e886",
            "ipAddress": {
               "id": "b5e90c61-deac-414a-882d-ed305b242e16",
               "address": "10.179.27.4"
            }
         }
      ],
      "snmp": [],
      "syslogs": [],
      "displayName": "0"
   },
   "otherDevice": [],
   "rlan": [],
   "transitNetworks": [
      {
         "idRef": "eaf5b193-cede-4fad-8d1d-ce626015f64b"
      }
   ],
   "virtualNetwork": [],
   "wirelessAAAPolicy": [],
   "wlan": [],
   "displayName": "f5ba231e[aecb362f-163f-4188-bacd-55900c3b0ddc]",
   "deviceManagementIpAddress": "100.68.0.190",
   "deviceName": "devhf-osl-bn1.monet.local",
   "siteNameHierarchy": "Global/devhf/OSL/Main Building/Floor 1",
   "fabricSiteNameHierarchy": "Global/devhf/OSL",
   "status": "success",
   "description": "Border device info retrieved successfully from sda fabric.",
   "executionId": "c1a94226-5cfe-41b4-9e7b-9bbf22becb3d"

Data being saved:

 type": [
        "tuple",
        [
          [
            "object",
            {
              "devhf-osl-bn1": [
                "object",
                {
                  "device_management_ip_address": "string",
                  "id": "string",
                  "item": [
                    "list",
                    [
                      "object",
                      {
                        "description": "string",
                        "payload": [
                          "list",
                          [
                            "object",
                            {
                              "akc_settings_cfs": [
                                "list",
                                "string"
                              ],
                              "auth_entity_class": "number",
                              "auth_entity_id": "number",
                              "cfs_change_info": [
                                "list",
                                "string"
                              ],
                              "configs": [
                                "list",
                                "string"
                              ],
                              "create_time": "number",
                              "custom_provisions": [
                                "list",
                                "string"
                              ],
                              "deploy_pending": "string",
                             "deployed": "string",
                              "device_interface_info": [
                                "list",
                                "string"
                              ],
                              "device_settings": [
                                "list",
                                [
                                  "object",
                                  {
                                    "connected_to": [
                                      "list",
                                      "string"
                                    ],
                                    "cpu": "number",
                                    "deploy_pending": "string",
                                    "dhcp_enabled": "string",
                                    "display_name": "string",
                                    "ext_connectivity_settings": [
                                      "list",
                                      [
                                        "object",
                                        {
                                          "deploy_pending": "string",
                                          "display_name": "string",
                                          "external_domain_protocol_number": "string",
                                          "id": "string",
                                          "instance_id": "number",
                                          "instance_tenant_id": "string",
                                          "instance_version": "number",
                                          "interface_uuid": "string",
                                          "l2_handoff": [
                                            "list",
                                            "string"
                                          ],
                                          "l3_handoff": [
                                            "list",
                                            [
                                              "object",
                                              {
                                                "deploy_pending": "string",
                                                "display_name": "string",
                                                "id": "string",
                                                "instance_id": "number",
                                                "instance_tenant_id": "string",
                                                "instance_version": "number",
                                                "local_ip_address": "string",
                                                "remote_ip_address": "string",
                                                "virtual_network": [
                                                  "list",
                                                  [
                                                    "object",
                                                    {
                                                      "id_ref": "string"
                                                    }
                                                  ]
                                                ],
                                                "vlan_id": "number"
                                              }
                                            ]
                                          ],
                                          "policy_propagation_enabled": "string",
                                          "policy_sgt_tag": "number"
                                        }
                                      ]
                                    ],
                                    "external_connectivity_ip_pool": "string",
                                    "external_domain_routing_protocol": "string",
                                    "id": "string",
                                    "instance_id": "number",
                                    "instance_tenant_id": "string",
                                    "instance_version": "number",
                                    "internal_domain_protocol_number": "string",
                                    "memory": "number",
                                    "node_type": [
                                      "list",
                                      "string"
                                    ],
                                    "storage": "number"
                                  }
                                ]
                              ],
                              "display_name": "string",
                              "id": "string",
                              "instance_id": "number",
                              "instance_tenant_id": "string",
                              "instance_version": "number",
                              "is_seeded": "string",
                              "is_stale": "string",
                              "last_update_time": "number",
                              "managed_sites": [
                                "list",
                                "string"
                              ],
                              "name": "string",
                              "namespace": "string",
                              "network_device_id": "string",
                              "network_wide_settings": [
                                "list",
                                [
                                  "object",
                                  {
                                    "aaa": [
                                      "list",
                                      "string"
                                    ],
                                    "cmx": [
                                      "list",
                                      "string"
                                    ],
                                    "deploy_pending": "string",
                                    "dhcp": [
                                      "list",
                                      [
                                        "object",
                                        {
                                          "id": "string",
                                          "ip_address": [
                                            "list",
                                            [
                                              "object",
                                              {
                                                "address": "string",
                                                "address_type": "string",
                                                "id": "string",
                                                "padded_address": "string"
                                              }
                                            ]
                                          ]
                                        }
                                      ]
                                    ],
                                    "display_name": "string",
                                    "dns": [
                                      "list",
                                      [
                                        "object",
                                        {
                                          "domain_name": "string",
                                          "id": "string",
                                          "ip": [
                                            "list",
                                            [
                                              "object",
                                              {
                                                "address": "string",
                                                "address_type": "string",
                                                "id": "string",
                                                "padded_address": "string"
                                              }
                                            ]
                                          ]
                                        }
                                      ]
                                    ],
                                    "id": "string",
                                    "instance_id": "number",
                                    "instance_tenant_id": "string",
                                    "instance_version": "number",
                                    "ldap": [
                                      "list",
                                      "string"
                                    ],
                                    "native_vlan": [
                                      "list",
                                      "string"
                                    ],
                                    "netflow": [
                                      "list",
                                      "string"
                                    ],
                                    "ntp": [
                                      "list",
                                      "string"
                                    ],
                                    "snmp": [
                                      "list",
                                      "string"
                                    ],
                                    "syslogs": [
                                      "list",
                                      "string"
                                    ]
                                  }
                                ]
                              ],
                              "other_device": [
                                "list",
                                "string"
                              ],
                              "provisioning_state": "string",
                              "resource_version": "number",
                              "roles": [
                                "list",
                                "string"
                              ],
                              "save_wan_connectivity_details_only": "string",
                              "site_id": "string",
                              "target_id_list": [
                                "list",
                                "string"
                              ],
                              "transit_networks": [
                                "list",
                                [
                                  "object",
                                  {
                                    "id_ref": "string"
                                  }
                                ]
                              ],
                              "type": "string",
                              "virtual_network": [
                                "list",
                                "string"
                              ],
                              "wlan": [
                                "list",
                                "string"
                              ]
                            }
                          ]
                        ],
                        "status": "string"
                      }
                    ]
                  ]
                }
              ],

Expected behavior Creation of the resource also saves data returned from payload into state file. Data operations read data from API.

Screenshots

Environment (please complete the following information): Cisco DNA Center version and patch: 2.3.5.4 - 70852 Terraform version: 1.5.6 Cisco DNA Center provider version: 1.1.22-beta OS Version: Ubuntu

Additional context Add any other context about the problem here.

fmunozmiranda commented 1 year ago

@edudppaz problem is in our documentation, all response params are into a payload parameter. I have been fixing it. I will have you updated.

edudppaz commented 1 year ago

@edudppaz problem is in our documentation, all response params are into a payload parameter. I have been fixing it. I will have you updated.

Hi @fmunozmiranda , could you then inform me how to access the data? This is blocking other modules that read border data to provision other parts of the network.

fmunozmiranda commented 1 year ago

@edudppaz currently due documentation bug, data is not mapped, tommorow a new version with this fix will be released.

edudppaz commented 1 year ago

@edudppaz currently due documentation bug, data is not mapped, tommorow a new version with this fix will be released.

@fmunozmiranda oh, i thought you meant documentation as in docs / readme. Thanks! We will then test when the new version comes out.

fmunozmiranda commented 1 year ago

Hi @edudppaz , new version (v1.1.24-beta) was released, please try it again.

edudppaz commented 1 year ago

@fmunozmiranda this is working OK now, the data from the border is now present on the state file. Thanks!!