Skip to content
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

Attaching a network profile to a day0 template #155

Open
sudhanshujoshi23 opened this issue Dec 2, 2024 · 10 comments
Open

Attaching a network profile to a day0 template #155

sudhanshujoshi23 opened this issue Dec 2, 2024 · 10 comments

Comments

@sudhanshujoshi23
Copy link

sudhanshujoshi23 commented Dec 2, 2024

I am trying to attach a network profile to a day0 template using the below configuration, but I don't understand why it doesn't work. Can someone please let me know what I am missing here?

resource "catalystcenter_template" "base_template" {
  project_id       = "${catalystcenter_project.base_project.id}"
  name             = "C9200-C9300_Template"
  description      = "Jinja Template"
  device_types     = var.device_types
  language         = "JINJA"
  software_type    = "IOS-XE"
  software_variant = "XE"
  software_version = "16.12.1a"
  template_content = file("./modules/template/day0_template.j2")
  template_params = {{  some_params }}
  composite = false
}

resource "catalystcenter_network_profile" "network_profile" {
  name = "Network Profile for C9200-9300 switches"
  type = "switching"
  templates = [
    {
      type = "day0.templates"
      attributes = [
        {
          template_id = catalystcenter_template.base_template.id
        }
      ]
    }
  ]
}
@sudhanshujoshi23
Copy link
Author

For context, my terraform configuration is applied successfully without any errors, the template and network profiles are created. But the network profile isn't attached to the template.

@kuba-mazurkiewicz
Copy link
Collaborator

@sudhanshujoshi23 which DNAC version are you using?

I just creatd network profile and cli template and attach it as onboarding template to network_profile using following code:

terraform {
  required_providers {
    catalystcenter = {
      source  = "CiscoDevNet/catalystcenter"
      version = "0.1.16"
    }
  }
}

resource "catalystcenter_project" "example" {
  name        = "Test_Project_1"
  description = "My description"
}

resource "catalystcenter_template" "base_template" {
  project_id  = catalystcenter_project.example.id
  name        = "C9200-C9300_Template"
  description = "Jinja Template"
  device_types = [
    {
      product_family = "Switches and Hubs"
      product_series = "Cisco Catalyst 9300 Series Switches"
      product_type   = "Cisco Catalyst 9300 Switch"
    }
  ]
  language         = "JINJA"
  software_type    = "IOS-XE"
  software_variant = "XE"
  software_version = "16.12.1a"
  template_content = "hostname Test"
  composite        = false
}

resource "catalystcenter_network_profile" "network_profile" {
  name = "Network Profile for C9200-9300 switches"
  type = "switching"
  templates = [
    {
      type = "day0.templates"
      attributes = [
        {
          template_id = catalystcenter_template.base_template.id
        }
      ]
    }
  ]
}

and I can see template being attached to network profile:

Screenshot 2024-12-02 at 22 00 42

If terraform config was applied successfully without any errors, are you sure you cannot see template attached to network profile under Network Profiles -> Edit ?

@sudhanshujoshi23
Copy link
Author

The DNAC version I am using is Version 2.3.5.3-70194
The terraform provider version I am using is 0.1.15
And yes I am sure that I can't see the network profile being attached to the template. I tried the exact same code in the example you provided, but the network profile wasn't attached to the template after successful apply.

image
image

@kuba-mazurkiewicz
Copy link
Collaborator

Can you try upgrading to 2.3.7.X , provider was tested against 2.3.7 version of CC.

@sudhanshujoshi23
Copy link
Author

This will need some time...
Also, can you confirm if the templates needs to be committed before they can be attached to any network profile? If that's the case, can you point me to the documentation which I can use for committing the template?

Thanks!

@kuba-mazurkiewicz
Copy link
Collaborator

For commiting template you need to use resource: https://registry.terraform.io/providers/CiscoDevNet/catalystcenter/latest/docs/resources/template_version

and code can look like this:

resource "catalystcenter_template" "base_template" {
  project_id  = catalystcenter_project.example.id
  name        = "C9200-C9300_Template"
  description = "Jinja Template"
  device_types = [
    {
      product_family = "Switches and Hubs"
      product_series = "Cisco Catalyst 9300 Series Switches"
      product_type   = "Cisco Catalyst 9300 Switch"
    }
  ]
  language         = "JINJA"
  software_type    = "IOS-XE"
  software_variant = "XE"
  software_version = "16.12.1a"
  template_content = "hostname Test"
  composite        = false
}


resource "catalystcenter_template_version" "example" {
  template_id = catalystcenter_template.base_template.id
  comments    = "New Version"
}

@sudhanshujoshi23
Copy link
Author

Adding the version resource didn't help either. There were no errors during the terraform apply.
image

Also, if I just go and attach the network profile manually to this newly created template using the catalyst center web portal, it works. So I am not sure what's wrong with the terraform code.

@kuba-mazurkiewicz
Copy link
Collaborator

I don't think there is a problem with terraform code. This resource is using internal API endpoint: /api/v1/siteprofile, which might not work on your DNAC version. As i mentioned provider is tested against 2.3.7 DNAC version.

I would recommend to upgrade to 2.3.7.X and try again.

@sudhanshujoshi23
Copy link
Author

Okay, we will update you once we have updated our DNAC version.
In the meantime, can you point me to the API documentation of this endpoint? I am not able to find it anywhere.
/api/v1/siteprofile

@kuba-mazurkiewicz
Copy link
Collaborator

The endpoint /api/v1/siteprofile is part of the internal APIs. Internal APIs are not officially documented or supported for external developers. These APIs are primarily used by the DNA Center's front-end web application and internal processes. While they might be accessible through tools like browser developer tools (by inspecting requests from the DNAC UI) or reverse engineering, Cisco does not guarantee their stability or availability between releases.

Where to Find Documentation for Internal APIs
Cisco DNA Center Frontend Debugging:
Open the developer tools in your browser (F12 or equivalent).
Interact with the DNAC UI and observe the network requests being made. These will reveal internal API endpoints and their payloads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants