Skip to content

sdwan_attach_feature_device_template | detach operation failure #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rrahimm opened this issue Mar 25, 2025 · 2 comments
Open

sdwan_attach_feature_device_template | detach operation failure #417

rrahimm opened this issue Mar 25, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@rrahimm
Copy link

rrahimm commented Mar 25, 2025

when we use sdwan_attach_feature_device_template to detach a specific device from a device template, we see that all the devices attached with that Device Template is detached from the template rather than just the device we intended to detach.

For example, the following 2 devices are attached to device template DT-DC-C8000V-01

---
# SD-WAN Sites
sdwan:
  sites:
    - id: 100
      routers:
        - chassis_id: C8K-40C0CCFD-9EA8-2B2E-E73B-32C5924EC79B
          model: C8000V
          device_template: DT-DC-C8000V-01
          device_variables:
            site_id: 100
            system_ip: 10.0.0.1
            system_hostname: SD-DC-C8KV-01
            <truncated>
        - chassis_id: C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B
          model: C8000V
          device_template: DT-DC-C8000V-01
          device_variables:
            site_id: 100
            system_ip: 10.0.0.2
            system_hostname: SD-DC-C8KV-02
            <truncated>

vManage showing device attachment to template

Image

Now, we want to detach device C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B from Device Template DT-DC-C8000V-01

---
# SD-WAN Sites
sdwan:
  sites:
    - id: 100
      routers:
        - chassis_id: C8K-40C0CCFD-9EA8-2B2E-E73B-32C5924EC79B
          model: C8000V
          device_template: DT-DC-C8000V-01
          device_variables:
            site_id: 100
            system_ip: 10.0.0.1
            system_hostname: SD-DC-C8KV-01
            <truncated>

Now the Terraform Plan is also just confirming, that only one device will be detached from Device template

 # module.sdwan.sdwan_attach_feature_device_template.attach_feature_device_template["C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B"] will be destroyed
  # (because key ["C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B"] is not in for_each map)
  - resource "sdwan_attach_feature_device_template" "attach_feature_device_template" {
      - devices = [
          - {
              - id        = "C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B" -> null
              - variables = {
                  - "controller_groups"                                = "1,2"
                  - "global_cdp_enable"                                = "true"
            	  <truncated>
                } -> null
            },
        ] -> null
      - id      = "50b663e5-8669-4a95-99a6-13bfe47d7a55" -> null
      - version = 0 -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

However, we see that both the devices that were attached to the Device Template DT-DC-C8000V-01 were detached. You can see below, both devices switched mode to CLI

Image

On debugging the Terraform provider calls, we are able to confirm that the Provider did ask the API to detach both devices from the template rather than just one.

2025-03-25T15:44:18.452+0530 [DEBUG] provider.terraform-provider-sdwan_v0.5.3: 2025/03/25 15:44:18 [DEBUG] HTTP Request: POST, https://198.18.1.100/dataservice/template/config/device/mode/cli, {{"deviceType":"vedge","devices":[{"deviceId":"C8K-40C0CCFD-9EA8-2B2E-E73B-32C5924EC79B","deviceIP":"10.0.0.1"},{"deviceId":"C8K-E94D7B88-4B9E-3323-C6C3-F29079FAAC3B","deviceIP":"10.0.0.2"}]}}
2025-03-25T15:44:19.246+0530 [DEBUG] provider.terraform-provider-sdwan_v0.5.3: 2025/03/25 15:44:19 [DEBUG] HTTP Response: {"id":"device_config_mode_cli-3ecf44f7-a7e4-45ea-b7f0-5050a18c7f7f"}
2025-03-25T15:44:19.246+0530 [DEBUG] provider.terraform-provider-sdwan_v0.5.3: 2025/03/25 15:44:19 [DEBUG] Exit from Do method
111
@seconroy seconroy self-assigned this Mar 25, 2025
@seconroy seconroy added the bug Something isn't working label Apr 2, 2025
@seconroy
Copy link
Collaborator

seconroy commented Apr 4, 2025

Update: The initial issues has been identified where by modules has been developed so that one sdwan_attach_feature_device_template contains one device (Option 1) and provider was developed so that one sdwan_attach_feature_device_template would contain multiple devices (Option 2) resulting in the all devices being detached when using Option 1.

A second issue has also been identified when pushing an update using Option 2. When an update is pushed to a single device, all devices are currently updated. Both issues are currently being looked into.

Option 1

resource "sdwan_attach_feature_device_template" "example_1" {
  id = sdwan_feature_device_template.example.id
  devices = [
    {
      id = "C8K-C38D156C-34E4-909A-15BB-96D0E9D0E808"
      variables = {
        system_system_ip                                = "1.1.1.1"
      }
    }
  ]
}

resource "sdwan_attach_feature_device_template" "example_2" {
  id = sdwan_feature_device_template.example.id
  devices = [
    {
      id = "C8K-25679DF5-DE95-81BC-5D4A-56907294945B"
      variables = {
        system_system_ip                                = "1.1.1.3"
      }
    }
  ]
}  

Option 2

resource "sdwan_attach_feature_device_template" "example" {
  id = sdwan_feature_device_template.example.id
  devices = [
    {
      id = "C8K-C38D156C-34E4-909A-15BB-96D0E9D0E808"
      variables = {
        system_system_ip                                = "1.1.1.1"
      }
    },
    {
      id = "C8K-25679DF5-DE95-81BC-5D4A-56907294945B"
      variables = {
        system_system_ip                                = "1.1.1.3"
      }
    }
  ]
}  

@rrahimm
Copy link
Author

rrahimm commented Apr 4, 2025

thanks Sean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants