From 984a22f6d6bb260602321dc61005b235f6a1e2ca Mon Sep 17 00:00:00 2001 From: Lionel Hercot Date: Fri, 3 Feb 2023 10:21:09 +0100 Subject: [PATCH] [bugfix] Update aci-go-client to v2.7.3 to fix issue in aci_cloud_context_profile when optional parameters cloud_brownfield and access_policy_type are not provided. --- examples/cloud_context_profile/aws/main.tf | 10 ++ go.mod | 2 +- go.sum | 4 +- .../aci-go-client/v2/client/client.go | 29 ++-- .../v2/client/cloudCtxProfile_service.go | 141 ++++++++++-------- .../v2/client/infraAccBndlSubgrp_service.go | 64 ++++---- .../v2/client/l3extLIfP_service.go | 39 ++--- .../v2/client/service_manager.go | 4 +- .../aci-go-client/v2/models/l3ext_l_if_p.go | 7 +- vendor/modules.txt | 2 +- 10 files changed, 161 insertions(+), 141 deletions(-) diff --git a/examples/cloud_context_profile/aws/main.tf b/examples/cloud_context_profile/aws/main.tf index b5ce7ad9c..bb36e2910 100644 --- a/examples/cloud_context_profile/aws/main.tf +++ b/examples/cloud_context_profile/aws/main.tf @@ -34,4 +34,14 @@ resource "aci_cloud_context_profile" "ctx1" { relation_cloud_rs_to_ctx = aci_vrf.vrf.id cloud_brownfield = "vpc-00a844d6354c53502" access_policy_type = "read-only" +} + +resource "aci_cloud_context_profile" "ctx2" { + name = "cloud_context_profile_2" + description = "normal vpc in aws" + tenant_dn = aci_tenant.terraform_tenant.id + primary_cidr = "10.2.1.0/24" + region = "us-west-1" + cloud_vendor = "aws" + relation_cloud_rs_to_ctx = aci_vrf.vrf.id } \ No newline at end of file diff --git a/go.mod b/go.mod index 673d355dc..5e19957fc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-aci go 1.18 require ( - github.com/ciscoecosystem/aci-go-client/v2 v2.7.1 + github.com/ciscoecosystem/aci-go-client/v2 v2.7.3 github.com/ghodss/yaml v1.0.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 ) diff --git a/go.sum b/go.sum index 069032faa..dbe7400ce 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/ciscoecosystem/aci-go-client/v2 v2.7.1 h1:a4xJet/HYrjQZeTt7NSF1z+3lQnx2QJF3gjx2HjN5Wg= -github.com/ciscoecosystem/aci-go-client/v2 v2.7.1/go.mod h1:ZeJuaKr9gTRn5B1CwA3sVSVqnRjVMEcBc8LUX222wf0= +github.com/ciscoecosystem/aci-go-client/v2 v2.7.3 h1:6CTJ4jYflTVLMmrcbeWarUjvDW4OqdWCDrnIwZQQeEs= +github.com/ciscoecosystem/aci-go-client/v2 v2.7.3/go.mod h1:ZeJuaKr9gTRn5B1CwA3sVSVqnRjVMEcBc8LUX222wf0= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/client.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/client.go index c92fff717..e59eb5630 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/client.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/client.go @@ -316,9 +316,9 @@ func (c *Client) useInsecureHTTPClient(insecure bool) *http.Transport { } // Takes raw payload and does the http request -// Used for login request -// passwords with special chars have issues when using container -// for encoding/decoding +// - Used for login request +// - Passwords with special chars have issues when using container +// - For encoding/decoding func (c *Client) MakeRestRequestRaw(method string, rpath string, payload []byte, authenticated bool) (*http.Request, error) { pathURL, err := url.Parse(rpath) @@ -429,6 +429,11 @@ func (c *Client) MakeRestRequest(method string, rpath string, body *container.Co // Authenticate is used to func (c *Client) Authenticate() error { + // Setting skipLoggingPayloadState to preserve state during call of the method + skipLoggingPayloadState := c.skipLoggingPayload + + log.Printf("[DEBUG] Begining Authentication method") + method := "POST" path := "/api/aaaLogin.json" authenticated := false @@ -444,6 +449,7 @@ func (c *Client) Authenticate() error { authenticated = true } + // Setting skipLoggingPayload true so authentication details are not shown in logs c.skipLoggingPayload = true req, err := c.MakeRestRequestRaw(method, path, body, authenticated) @@ -452,7 +458,9 @@ func (c *Client) Authenticate() error { } obj, _, err := c.Do(req) - c.skipLoggingPayload = false + + c.skipLoggingPayload = skipLoggingPayloadState + if err != nil { log.Printf("[DEBUG] Authentication ERROR: %s", err) return err @@ -680,11 +688,13 @@ func (c *Client) backoff(attempts int) bool { // // Error // // // @@ -700,7 +710,6 @@ func (c *Client) backoff(attempts int) bool { // Sample return error: // An error occurred. Sorry, the page you are looking for is currently unavailable. If you are the system administrator of this // resource then you should check the error log for details. Faithfully yours, nginx. -// func (c *Client) checkHtmlResp(body string) error { reader := strings.NewReader(body) tokenizer := html.NewTokenizer(reader) diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/cloudCtxProfile_service.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/cloudCtxProfile_service.go index c3cfbcafb..12881acb2 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/cloudCtxProfile_service.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/cloudCtxProfile_service.go @@ -13,90 +13,103 @@ func (sm *ServiceManager) CreateCloudContextProfile(name string, tenant string, parentDn := tenant cloudCtxProfile := models.NewCloudContextProfile(rn, parentDn, description, cloudCtxProfileattr) jsonPayload, _, err := sm.PrepareModel(cloudCtxProfile) + jsonPayload.Array(cloudCtxProfile.ClassName, "children") - cidrJSON := []byte(fmt.Sprintf(` - { - "cloudCidr": { - "attributes": { - "addr": "%s", - "primary": "yes", - "status": "created,modified" + if primaryCidr != "" { + cidrJSON := []byte(fmt.Sprintf(` + { + "cloudCidr": { + "attributes": { + "addr": "%s", + "primary": "yes", + "status": "created,modified" + } } } + `, primaryCidr)) + cidrCon, err := container.ParseJSON(cidrJSON) + if err != nil { + return nil, err + } + jsonPayload.ArrayAppend(cidrCon.Data(), cloudCtxProfile.ClassName, "children") } - `, primaryCidr)) - regionAttach := []byte(fmt.Sprintf(` - { - "cloudRsCtxProfileToRegion": { - "attributes": { - "status": "created,modified", - "tDn": "uni/clouddomp/provp-%s/region-%s" + if vendor != "" && region != "" { + regionAttach := []byte(fmt.Sprintf(` + { + "cloudRsCtxProfileToRegion": { + "attributes": { + "status": "created,modified", + "tDn": "uni/clouddomp/provp-%s/region-%s" + } } } + `, vendor, region)) + regionCon, err := container.ParseJSON(regionAttach) + if err != nil { + return nil, err + } + jsonPayload.ArrayAppend(regionCon.Data(), cloudCtxProfile.ClassName, "children") } - `, vendor, region)) - ctxAttach := []byte(fmt.Sprintf(` - { - "cloudRsToCtx": { - "attributes": { - "tnFvCtxName": "%s" + if vrf != "" { + vrfAttach := []byte(fmt.Sprintf(` + { + "cloudRsToCtx": { + "attributes": { + "tnFvCtxName": "%s" + } } } - } - `, vrf)) - - brownFieldAttach := []byte(fmt.Sprintf(` - { - "cloudBrownfield": { - "attributes": {}, - "children": [ - { - "cloudIDMapping": { - "attributes": { - "cloudProviderId": "%s" + `, vrf)) + vrfCon, err := container.ParseJSON(vrfAttach) + if err != nil { + return nil, err + } + jsonPayload.ArrayAppend(vrfCon.Data(), cloudCtxProfile.ClassName, "children") + } + + if cloudBrownfield != "" { + brownFieldAttach := []byte(fmt.Sprintf(` + { + "cloudBrownfield": { + "attributes": {}, + "children": [ + { + "cloudIDMapping": { + "attributes": { + "cloudProviderId": "%s" + } } } - } - ] + ] + } + } + `, cloudBrownfield)) + brownFieldCon, err := container.ParseJSON(brownFieldAttach) + if err != nil { + return nil, err } + jsonPayload.ArrayAppend(brownFieldCon.Data(), cloudCtxProfile.ClassName, "children") } - `, cloudBrownfield)) - accessPolicyAttach := []byte(fmt.Sprintf(` - { - "cloudRsCtxProfileToAccessPolicy": { - "attributes": { - "tDn": "uni/tn-infra/accesspolicy-%s" + if accessPolicy != "" { + accessPolicyAttach := []byte(fmt.Sprintf(` + { + "cloudRsCtxProfileToAccessPolicy": { + "attributes": { + "tDn": "uni/tn-infra/accesspolicy-%s" + } } } + `, accessPolicy)) + accessPolicyCon, err := container.ParseJSON(accessPolicyAttach) + if err != nil { + return nil, err + } + jsonPayload.ArrayAppend(accessPolicyCon.Data(), cloudCtxProfile.ClassName, "children") } - `, accessPolicy)) - - cidrCon, err := container.ParseJSON(cidrJSON) - regionCon, err := container.ParseJSON(regionAttach) - vrfCon, err := container.ParseJSON(ctxAttach) - brownFieldCon, err := container.ParseJSON(brownFieldAttach) - accessPolicyCon, err := container.ParseJSON(accessPolicyAttach) - - if err != nil { - return nil, err - } - if err != nil { - - } - - log.Printf("\n\n\n[DEBUG]nknk %v", vrfCon.Data()) - jsonPayload.Array(cloudCtxProfile.ClassName, "children") - jsonPayload.ArrayAppend(vrfCon.Data(), cloudCtxProfile.ClassName, "children") - - jsonPayload.ArrayAppend(cidrCon.Data(), cloudCtxProfile.ClassName, "children") - jsonPayload.ArrayAppend(regionCon.Data(), cloudCtxProfile.ClassName, "children") - jsonPayload.ArrayAppend(brownFieldCon.Data(), cloudCtxProfile.ClassName, "children") - jsonPayload.ArrayAppend(accessPolicyCon.Data(), cloudCtxProfile.ClassName, "children") - log.Printf("\n\n\n\n[DEBUG]nkdemo%s\n\n\n\n", jsonPayload.String()) jsonPayload.Set(name, cloudCtxProfile.ClassName, "attributes", "name") if cloudCtxProfile.VpcGroup != "" { jsonPayload.Set(cloudCtxProfile.VpcGroup, cloudCtxProfile.ClassName, "attributes", "vpcGroup") diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/infraAccBndlSubgrp_service.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/infraAccBndlSubgrp_service.go index b2f837b33..7dd3fb1cf 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/infraAccBndlSubgrp_service.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/infraAccBndlSubgrp_service.go @@ -1,27 +1,22 @@ package client - - import ( - "fmt" - "github.com/ciscoecosystem/aci-go-client/v2/models" "github.com/ciscoecosystem/aci-go-client/v2/container" - + "github.com/ciscoecosystem/aci-go-client/v2/models" ) - -func (sm *ServiceManager) CreateOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string, description string, infraAccBndlSubgrpAttr models.OverridePCVPCPolicyGroupAttributes) (*models.OverridePCVPCPolicyGroup, error) { - rn := fmt.Sprintf(models.RninfraAccBndlSubgrp , name) - parentDn := fmt.Sprintf(models.ParentDninfraAccBndlSubgrp, leaf_access_bundle_policy_group ) +func (sm *ServiceManager) CreateOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string, description string, infraAccBndlSubgrpAttr models.OverridePCVPCPolicyGroupAttributes) (*models.OverridePCVPCPolicyGroup, error) { + rn := fmt.Sprintf(models.RninfraAccBndlSubgrp, name) + parentDn := fmt.Sprintf(models.ParentDninfraAccBndlSubgrp, leaf_access_bundle_policy_group) infraAccBndlSubgrp := models.NewOverridePCVPCPolicyGroup(rn, parentDn, description, infraAccBndlSubgrpAttr) err := sm.Save(infraAccBndlSubgrp) return infraAccBndlSubgrp, err } -func (sm *ServiceManager) ReadOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string, ) (*models.OverridePCVPCPolicyGroup, error) { - dn := fmt.Sprintf(models.DninfraAccBndlSubgrp, leaf_access_bundle_policy_group,name) +func (sm *ServiceManager) ReadOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string) (*models.OverridePCVPCPolicyGroup, error) { + dn := fmt.Sprintf(models.DninfraAccBndlSubgrp, leaf_access_bundle_policy_group, name) cont, err := sm.Get(dn) if err != nil { @@ -32,23 +27,23 @@ func (sm *ServiceManager) ReadOverridePCVPCPolicyGroup(name string, leaf_access_ return infraAccBndlSubgrp, nil } -func (sm *ServiceManager) DeleteOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string, ) error { - dn := fmt.Sprintf(models.DninfraAccBndlSubgrp, leaf_access_bundle_policy_group,name) +func (sm *ServiceManager) DeleteOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string) error { + dn := fmt.Sprintf(models.DninfraAccBndlSubgrp, leaf_access_bundle_policy_group, name) return sm.DeleteByDn(dn, models.InfraaccbndlsubgrpClassName) } func (sm *ServiceManager) UpdateOverridePCVPCPolicyGroup(name string, leaf_access_bundle_policy_group string, description string, infraAccBndlSubgrpAttr models.OverridePCVPCPolicyGroupAttributes) (*models.OverridePCVPCPolicyGroup, error) { - rn := fmt.Sprintf(models.RninfraAccBndlSubgrp , name) - parentDn := fmt.Sprintf(models.ParentDninfraAccBndlSubgrp, leaf_access_bundle_policy_group ) + rn := fmt.Sprintf(models.RninfraAccBndlSubgrp, name) + parentDn := fmt.Sprintf(models.ParentDninfraAccBndlSubgrp, leaf_access_bundle_policy_group) infraAccBndlSubgrp := models.NewOverridePCVPCPolicyGroup(rn, parentDn, description, infraAccBndlSubgrpAttr) - infraAccBndlSubgrp.Status = "modified" + infraAccBndlSubgrp.Status = "modified" err := sm.Save(infraAccBndlSubgrp) return infraAccBndlSubgrp, err } -func (sm *ServiceManager) ListOverridePCVPCPolicyGroup(leaf_access_bundle_policy_group string ) ([]*models.OverridePCVPCPolicyGroup, error) { - dnUrl := fmt.Sprintf("%s/uni/infra/funcprof/accbundle-%s/infraAccBndlSubgrp.json", models.BaseurlStr, leaf_access_bundle_policy_group ) - cont, err := sm.GetViaURL(dnUrl) +func (sm *ServiceManager) ListOverridePCVPCPolicyGroup(leaf_access_bundle_policy_group string) ([]*models.OverridePCVPCPolicyGroup, error) { + dnUrl := fmt.Sprintf("%s/uni/infra/funcprof/accbundle-%s/infraAccBndlSubgrp.json", models.BaseurlStr, leaf_access_bundle_policy_group) + cont, err := sm.GetViaURL(dnUrl) list := models.OverridePCVPCPolicyGroupListFromContainer(cont) return list, err } @@ -65,7 +60,6 @@ func (sm *ServiceManager) CreateRelationinfraRsLacpIfPol(parentDn, annotation, t } }`, "infraRsLacpIfPol", dn, annotation, tnLacpIfPolName)) - jsonPayload, err := container.ParseJSON(containerJSON) if err != nil { return err @@ -82,17 +76,17 @@ func (sm *ServiceManager) CreateRelationinfraRsLacpIfPol(parentDn, annotation, t return nil } -func (sm *ServiceManager) DeleteRelationinfraRsLacpIfPol(parentDn string) error{ +func (sm *ServiceManager) DeleteRelationinfraRsLacpIfPol(parentDn string) error { dn := fmt.Sprintf("%s/rslacpIfPol", parentDn) - return sm.DeleteByDn(dn , "infraRsLacpIfPol") + return sm.DeleteByDn(dn, "infraRsLacpIfPol") } -func (sm *ServiceManager) ReadRelationinfraRsLacpIfPol(parentDn string) (interface{},error) { - dnUrl := fmt.Sprintf("%s/%s/%s.json",models.BaseurlStr,parentDn,"infraRsLacpIfPol") +func (sm *ServiceManager) ReadRelationinfraRsLacpIfPol(parentDn string) (interface{}, error) { + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "infraRsLacpIfPol") cont, err := sm.GetViaURL(dnUrl) - contList := models.ListFromContainer(cont,"infraRsLacpIfPol") - - if len(contList) > 0 { + contList := models.ListFromContainer(cont, "infraRsLacpIfPol") + + if len(contList) > 0 { dat := models.G(contList[0], "tnLacpIfPolName") return dat, err } else { @@ -112,7 +106,6 @@ func (sm *ServiceManager) CreateRelationinfraRsLacpInterfacePol(parentDn, annota } }`, "infraRsLacpInterfacePol", dn, annotation, tnLacpIfPolName)) - jsonPayload, err := container.ParseJSON(containerJSON) if err != nil { return err @@ -129,21 +122,20 @@ func (sm *ServiceManager) CreateRelationinfraRsLacpInterfacePol(parentDn, annota return nil } -func (sm *ServiceManager) DeleteRelationinfraRsLacpInterfacePol(parentDn string) error{ +func (sm *ServiceManager) DeleteRelationinfraRsLacpInterfacePol(parentDn string) error { dn := fmt.Sprintf("%s/rslacpInterfacePol", parentDn) - return sm.DeleteByDn(dn , "infraRsLacpInterfacePol") + return sm.DeleteByDn(dn, "infraRsLacpInterfacePol") } -func (sm *ServiceManager) ReadRelationinfraRsLacpInterfacePol(parentDn string) (interface{},error) { - dnUrl := fmt.Sprintf("%s/%s/%s.json",models.BaseurlStr,parentDn,"infraRsLacpInterfacePol") +func (sm *ServiceManager) ReadRelationinfraRsLacpInterfacePol(parentDn string) (interface{}, error) { + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "infraRsLacpInterfacePol") cont, err := sm.GetViaURL(dnUrl) - contList := models.ListFromContainer(cont,"infraRsLacpInterfacePol") - - if len(contList) > 0 { + contList := models.ListFromContainer(cont, "infraRsLacpInterfacePol") + + if len(contList) > 0 { dat := models.G(contList[0], "tnLacpIfPolName") return dat, err } else { return nil, err } } - diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/l3extLIfP_service.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/l3extLIfP_service.go index f21a94778..422a6dcbd 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/l3extLIfP_service.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/l3extLIfP_service.go @@ -9,15 +9,15 @@ import ( ) func (sm *ServiceManager) CreateLogicalInterfaceProfile(name string, logical_node_profile string, l3_outside string, tenant string, description string, l3extLIfPattr models.LogicalInterfaceProfileAttributes) (*models.LogicalInterfaceProfile, error) { - rn := fmt.Sprintf("lifp-%s", name) - parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s", tenant, l3_outside, logical_node_profile) + rn := fmt.Sprintf(models.Rnl3extlifp, name) + parentDn := fmt.Sprintf(models.ParentDnl3extlifp, tenant, l3_outside, logical_node_profile) l3extLIfP := models.NewLogicalInterfaceProfile(rn, parentDn, description, l3extLIfPattr) err := sm.Save(l3extLIfP) return l3extLIfP, err } func (sm *ServiceManager) ReadLogicalInterfaceProfile(name string, logical_node_profile string, l3_outside string, tenant string) (*models.LogicalInterfaceProfile, error) { - dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s", tenant, l3_outside, logical_node_profile, name) + dn := fmt.Sprintf(models.Dnl3extlifp, tenant, l3_outside, logical_node_profile, name) cont, err := sm.Get(dn) if err != nil { return nil, err @@ -28,13 +28,13 @@ func (sm *ServiceManager) ReadLogicalInterfaceProfile(name string, logical_node_ } func (sm *ServiceManager) DeleteLogicalInterfaceProfile(name string, logical_node_profile string, l3_outside string, tenant string) error { - dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s", tenant, l3_outside, logical_node_profile, name) + dn := fmt.Sprintf(models.Dnl3extlifp, tenant, l3_outside, logical_node_profile, name) return sm.DeleteByDn(dn, models.L3extlifpClassName) } func (sm *ServiceManager) UpdateLogicalInterfaceProfile(name string, logical_node_profile string, l3_outside string, tenant string, description string, l3extLIfPattr models.LogicalInterfaceProfileAttributes) (*models.LogicalInterfaceProfile, error) { - rn := fmt.Sprintf("lifp-%s", name) - parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s", tenant, l3_outside, logical_node_profile) + rn := fmt.Sprintf(models.Rnl3extlifp, name) + parentDn := fmt.Sprintf(models.ParentDnl3extlifp, tenant, l3_outside, logical_node_profile) l3extLIfP := models.NewLogicalInterfaceProfile(rn, parentDn, description, l3extLIfPattr) l3extLIfP.Status = "modified" @@ -44,9 +44,7 @@ func (sm *ServiceManager) UpdateLogicalInterfaceProfile(name string, logical_nod } func (sm *ServiceManager) ListLogicalInterfaceProfile(logical_node_profile string, l3_outside string, tenant string) ([]*models.LogicalInterfaceProfile, error) { - - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/uni/tn-%s/out-%s/lnodep-%s/l3extLIfP.json", baseurlStr, tenant, l3_outside, logical_node_profile) + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, fmt.Sprintf(models.ParentDnl3extlifp, tenant, l3_outside, logical_node_profile), models.L3extlifpClassName) cont, err := sm.GetViaURL(dnUrl) list := models.LogicalInterfaceProfileListFromContainer(cont) @@ -88,8 +86,7 @@ func (sm *ServiceManager) DeleteRelationl3extRsLIfPToNetflowMonitorPolFromLogica } func (sm *ServiceManager) ReadRelationl3extRsLIfPToNetflowMonitorPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsLIfPToNetflowMonitorPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsLIfPToNetflowMonitorPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsLIfPToNetflowMonitorPol") @@ -98,7 +95,7 @@ func (sm *ServiceManager) ReadRelationl3extRsLIfPToNetflowMonitorPolFromLogicalI for _, contItem := range contList { paramMap := make(map[string]string) - paramMap["tnNetflowMonitorPolName"] = models.G(contItem, "tDn") + paramMap["tDn"] = models.G(contItem, "tDn") paramMap["fltType"] = models.G(contItem, "fltType") st = append(st, paramMap) @@ -142,8 +139,7 @@ func (sm *ServiceManager) DeleteRelationl3extRsPathL3OutAttFromLogicalInterfaceP } func (sm *ServiceManager) ReadRelationl3extRsPathL3OutAttFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsPathL3OutAtt") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, models.L3extrspathl3outattClassName) cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsPathL3OutAtt") @@ -188,8 +184,7 @@ func (sm *ServiceManager) CreateRelationl3extRsEgressQosDppPolFromLogicalInterfa } func (sm *ServiceManager) ReadRelationl3extRsEgressQosDppPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsEgressQosDppPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsEgressQosDppPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsEgressQosDppPol") @@ -232,8 +227,7 @@ func (sm *ServiceManager) CreateRelationl3extRsIngressQosDppPolFromLogicalInterf } func (sm *ServiceManager) ReadRelationl3extRsIngressQosDppPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsIngressQosDppPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsIngressQosDppPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsIngressQosDppPol") @@ -276,8 +270,7 @@ func (sm *ServiceManager) CreateRelationl3extRsLIfPCustQosPolFromLogicalInterfac } func (sm *ServiceManager) ReadRelationl3extRsLIfPCustQosPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsLIfPCustQosPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsLIfPCustQosPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsLIfPCustQosPol") @@ -320,8 +313,7 @@ func (sm *ServiceManager) CreateRelationl3extRsArpIfPolFromLogicalInterfaceProfi } func (sm *ServiceManager) ReadRelationl3extRsArpIfPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsArpIfPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsArpIfPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsArpIfPol") @@ -364,8 +356,7 @@ func (sm *ServiceManager) CreateRelationl3extRsNdIfPolFromLogicalInterfaceProfil } func (sm *ServiceManager) ReadRelationl3extRsNdIfPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "l3extRsNdIfPol") + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "l3extRsNdIfPol") cont, err := sm.GetViaURL(dnUrl) contList := models.ListFromContainer(cont, "l3extRsNdIfPol") diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/service_manager.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/service_manager.go index 1e92309d2..f15240161 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/service_manager.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/client/service_manager.go @@ -104,9 +104,9 @@ func CheckForErrors(cont *container.Container, method string, skipLoggingPayload } return nil } else { - if models.StripQuotes(imdata.Path("error.attributes.text").String()) == "" && errorCode == "403" { + if (models.StripQuotes(imdata.Path("error.attributes.text").String()) == "" && errorCode == "403") || (errorCode == "401") { if !skipLoggingPayload { - log.Printf("[DEBUG] Exit from authentication error 403 %v", cont) + log.Printf("[DEBUG] Exit from authentication error %s %v", errorCode, cont) } return errors.New("Unable to authenticate. Please check your credentials") } diff --git a/vendor/github.com/ciscoecosystem/aci-go-client/v2/models/l3ext_l_if_p.go b/vendor/github.com/ciscoecosystem/aci-go-client/v2/models/l3ext_l_if_p.go index 57a5963a2..4816df9f8 100644 --- a/vendor/github.com/ciscoecosystem/aci-go-client/v2/models/l3ext_l_if_p.go +++ b/vendor/github.com/ciscoecosystem/aci-go-client/v2/models/l3ext_l_if_p.go @@ -7,7 +7,12 @@ import ( "github.com/ciscoecosystem/aci-go-client/v2/container" ) -const L3extlifpClassName = "l3extLIfP" +const ( + Dnl3extlifp = "uni/tn-%s/out-%s/lnodep-%s/lifp-%s" + Rnl3extlifp = "lifp--%s" + ParentDnl3extlifp = "uni/tn-%s/out-%s/lnodep-%s" + L3extlifpClassName = "l3extLIfP" +) type LogicalInterfaceProfile struct { BaseAttributes diff --git a/vendor/modules.txt b/vendor/modules.txt index 7a5f872f0..79819d59c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/apparentlymart/go-cidr/cidr # github.com/apparentlymart/go-textseg/v13 v13.0.0 ## explicit; go 1.16 github.com/apparentlymart/go-textseg/v13/textseg -# github.com/ciscoecosystem/aci-go-client/v2 v2.7.1 +# github.com/ciscoecosystem/aci-go-client/v2 v2.7.3 ## explicit; go 1.12 github.com/ciscoecosystem/aci-go-client/v2/client github.com/ciscoecosystem/aci-go-client/v2/container