Skip to content

Enhance stdout logging to show API calls and response code for easy API debugging (DCNE-527) #378

@wilsonbc93

Description

@wilsonbc93

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

$ terraform version
Terraform v1.13.0
on darwin_amd64

  • provider registry.terraform.io/ciscodevnet/mso v1.5.2

MSO version

  • Version 4.4.3.1010

APIC version and APIC Platform for Site Level Resources

  • V 5.2(8i) on-prem

Affected Resource(s)

  • mso_v1.5.2

Terraform Configuration Files

terraform {
  required_providers {
    mso = {
      source = "CiscoDevNet/mso"
    }
  }
}

provider "mso" {
  username = <omit>
  password = <omit>
  url      = <omit>
  insecure = true
  platform = "nd"
}

data "mso_site" "site_1" {
  name = "Fabric-2"
}

data "mso_site" "site_2" {
  name = "Fabric-4"
}

resource "mso_tenant" "tenant_1" {
  name         = "Terraform"
  display_name = "Terraform"
  site_associations {
    site_id = data.mso_site.site_1.id
  }
  site_associations {
    site_id = data.mso_site.site_2.id
  }
}

resource "mso_schema" "schema_1" {
  name           = "Schema1"
  template {
    tenant_id    = mso_tenant.tenant_1.id
    name         = "Template1"
    display_name = "Template1"
  }
}

resource "mso_schema_site" "schema_site_1" {
  schema_id     = mso_schema.schema_1.id
  site_id       = data.mso_site.site_1.id
  template_name = tolist(mso_schema.schema_1.template)[0].name
}

resource "mso_schema_site" "schema_site_2" {
  schema_id           = mso_schema.schema_1.id
  site_id             = data.mso_site.site_2.id
  template_name       = tolist(mso_schema.schema_1.template)[0].name
}

resource "mso_schema_template_vrf" "vrf" {
  schema_id    = mso_schema.schema_1.id
  template     = tolist(mso_schema.schema_1.template)[0].name
  name         = "v1"
  display_name = "v1"
}

resource "mso_schema_template_bd" "bd" {
  schema_id         = mso_schema.schema_1.id
  template_name     = mso_schema_template_vrf.vrf.template
  name              = "bd1"
  display_name      = "bd1"
  vrf_name          = mso_schema_template_vrf.vrf.name
  vrf_schema_id     = mso_schema_template_vrf.vrf.schema_id
  vrf_template_name = mso_schema_template_vrf.vrf.template
}

resource "mso_schema_template_anp" "anp" {
  schema_id    = mso_schema.schema_1.id
  template     = tolist(mso_schema.schema_1.template)[0].name
  name         = "ap1"
  display_name = "ap1"
}

resource "mso_schema_template_anp_epg" "anp_epg" {
  schema_id     = mso_schema.schema_1.id
  template_name = mso_schema_template_anp.anp.template
  anp_name      = mso_schema_template_anp.anp.name
  name          = "epg1"
  display_name  = "epg1"
  bd_name       = mso_schema_template_bd.bd.name
  vrf_name      = mso_schema_template_vrf.vrf.name
}

resource "mso_schema_site_anp" "site_1_anp" {
  schema_id     = mso_schema.schema_1.id
  template_name = mso_schema_site.schema_site_1.template_name
  site_id       = data.mso_site.site_1.id
  anp_name      = mso_schema_template_anp.anp.name
}

resource "mso_schema_site_anp_epg" "site_1_anp_epg" {
  schema_id     = mso_schema.schema_1.id
  template_name = mso_schema_site_anp.site_1_anp.template_name
  site_id       = data.mso_site.site_1.id
  anp_name      = mso_schema_site_anp.site_1_anp.anp_name
  epg_name      = mso_schema_template_anp_epg.anp_epg.name
}

resource "mso_schema_site_anp_epg_static_port" "site_1_anp_epg_static_port" {
  schema_id            = mso_schema.schema_1.id
  site_id              = data.mso_site.site_1.id
  template_name        = mso_schema_site_anp.site_1_anp.template_name
  anp_name             = mso_schema_site_anp.site_1_anp.anp_name
  epg_name             = mso_schema_template_anp_epg.anp_epg.name
  path_type            = "port"
  deployment_immediacy = "immediate"
  pod                  = "pod-1"
  leaf                 = "101"
  path                 = "eth1/1"
  vlan                 = 200
  mode                 = "regular"
}

Debug Output

mso_tenant.tenant_1: Creating...
mso_tenant.tenant_1: Creation complete after 2s [id=68a7508b13c61a57b4661b14]
mso_schema.schema_1: Creating...
mso_schema.schema_1: Creation complete after 1s [id=68a7508c13c61a57b4661b15]
mso_schema_site.schema_site_2: Creating...
mso_schema_site.schema_site_2: Creation complete after 1s [id=689cb07f5201b78579de0e70]
mso_schema_site.schema_site_1: Creating...
mso_schema_site.schema_site_1: Creation complete after 0s [id=689cb0475201b78579de0e6f]
mso_schema_template_anp.anp: Creating...
mso_schema_template_anp.anp: Creation complete after 1s [id=ap1]
mso_schema_template_vrf.vrf: Creating...
mso_schema_template_vrf.vrf: Creation complete after 1s [id=v1]
mso_schema_site_anp.site_1_anp: Creating...
mso_schema_site_anp.site_1_anp: Creation complete after 0s [id=ap1]
mso_schema_template_bd.bd: Creating...
mso_schema_template_bd.bd: Creation complete after 1s [id=bd1]
mso_schema_template_anp_epg.anp_epg: Creating...
mso_schema_template_anp_epg.anp_epg: Creation complete after 1s [id=68a7508c13c61a57b4661b15/templates/Template1/anps/ap1/epgs/epg1]
mso_schema_site_anp_epg.site_1_anp_epg: Creating...
mso_schema_site_anp_epg.site_1_anp_epg: Creation complete after 0s [id=epg1]
mso_schema_site_anp_epg_static_port.site_1_anp_epg_static_port: Creating...
mso_schema_site_anp_epg_static_port.site_1_anp_epg_static_port: Creation complete after 1s [id=topology/pod-1/paths-101/pathep-[eth1/1]]

Apply complete! Resources: 11 added, 0 changed, 0 destroyed.

Panic Output

None.

Proposed Behavior

Add additional stdout log lines that show the API call being made as well as the response code. Simple issues like API errors can be quickly diagnosed without any additional troubleshooting knowledge.

Example:
mso_schema_template_anp.anp: Creating...
mso_schema_template_anp.anp: PATCH mso/api/v1/schemas/68a7508c13c61a57b4661b15?validate=false
mso_schema_template_anp.anp: Body: {[{"op":"add","path":"/templates/Template1/anps/-","value":{"description":"","displayName":"ap1","epgs":[],"name":"ap1"}}]}
mso_schema_template_anp.anp: Response 204 "OK"
mso_schema_template_anp.anp: Creation complete after 1s [id=ap1]
mso_schema_template_bd.bd: Creating...
mso_schema_template_bd.bd: PATCH mso/api/v1/schemas/68a74d9313c61a57b4661af6?validate=false
mso_schema_template_bd.bd: Body: {[{"op":"add","path":"/templates/Template1/bds/-","value":{"arpFlood":false,"description":"","dhcpLabels":null,"di
splayName":"bd1","intersiteBumTrafficAllow":false,"l2Stretch":false,"l2UnknownUnicast":"flood","l3MCast":false,"multiDstPktAct":"bd-flood","name":"bd1","optimizeWanBandwidth":false,"subnets":[],"unicastRouting":false,"unkMcastAct":"flood","v6unkMcastAct":"flood","vrfRef":{"schemaId":"68a74d9313c61a57b4661af6","templateName":"Template1","vrfName":"v1"}}}]}
mso_schema_template_bd.bd: Response 400: [ERROR] "BD: bd1 in Schema: Schema1, Template: Template1, ARP Flooding has to be enabled if L2 Stretch disabled and L2 Unknown Unicast is Flood"
mso_schema_template_bd.bd: Creation complete after 1s [id=bd1]

Actual Behavior

In order to debug API-related issues you must enable verbose logging and be able to parse through the outputs.

export TF_LOG=DEBUG
export TF_LOG_PATH=./terraform-debug.log

Steps to Reproduce

  1. terraform apply

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjira-syncSync this issue to Jira

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions