From 2bc9f552f06e796d78f90c1a5f7103322e162613 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Tue, 11 Apr 2023 18:02:06 +0530 Subject: [PATCH] Added addrTCtrl to bgp_rt_summ_pol.go model --- client/bgpRtSummPol_service.go | 34 +++++++++++++++++-------- models/bgp_rt_summ_pol.go | 46 +++++++++++++--------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/client/bgpRtSummPol_service.go b/client/bgpRtSummPol_service.go index 90ca8fbd..601217b5 100644 --- a/client/bgpRtSummPol_service.go +++ b/client/bgpRtSummPol_service.go @@ -7,47 +7,59 @@ import ( ) func (sm *ServiceManager) CreateBgpRouteSummarization(name string, tenant string, description string, bgpRtSummPolattr models.BgpRouteSummarizationAttributes) (*models.BgpRouteSummarization, error) { - rn := fmt.Sprintf("bgprtsum-%s", name) - parentDn := fmt.Sprintf("uni/tn-%s", tenant) + + rn := fmt.Sprintf(models.RnBgpRtSummPol, name) + + parentDn := fmt.Sprintf(models.ParentDnBgpRtSummPol, tenant) bgpRtSummPol := models.NewBgpRouteSummarization(rn, parentDn, description, bgpRtSummPolattr) + err := sm.Save(bgpRtSummPol) return bgpRtSummPol, err } func (sm *ServiceManager) ReadBgpRouteSummarization(name string, tenant string) (*models.BgpRouteSummarization, error) { - dn := fmt.Sprintf("uni/tn-%s/bgprtsum-%s", tenant, name) + + rn := fmt.Sprintf(models.RnBgpRtSummPol, name) + + parentDn := fmt.Sprintf(models.ParentDnBgpRtSummPol, tenant) + dn := fmt.Sprintf("%s/%s", parentDn, rn) + cont, err := sm.Get(dn) if err != nil { return nil, err } - bgpRtSummPol := models.BgpRouteSummarizationFromContainer(cont) return bgpRtSummPol, nil } func (sm *ServiceManager) DeleteBgpRouteSummarization(name string, tenant string) error { - dn := fmt.Sprintf("uni/tn-%s/bgprtsum-%s", tenant, name) + + rn := fmt.Sprintf(models.RnBgpRtSummPol, name) + + parentDn := fmt.Sprintf(models.ParentDnBgpRtSummPol, tenant) + dn := fmt.Sprintf("%s/%s", parentDn, rn) + return sm.DeleteByDn(dn, models.BgprtsummpolClassName) } func (sm *ServiceManager) UpdateBgpRouteSummarization(name string, tenant string, description string, bgpRtSummPolattr models.BgpRouteSummarizationAttributes) (*models.BgpRouteSummarization, error) { - rn := fmt.Sprintf("bgprtsum-%s", name) - parentDn := fmt.Sprintf("uni/tn-%s", tenant) + + rn := fmt.Sprintf(models.RnBgpRtSummPol, name) + + parentDn := fmt.Sprintf(models.ParentDnBgpRtSummPol, tenant) bgpRtSummPol := models.NewBgpRouteSummarization(rn, parentDn, description, bgpRtSummPolattr) bgpRtSummPol.Status = "modified" err := sm.Save(bgpRtSummPol) return bgpRtSummPol, err - } func (sm *ServiceManager) ListBgpRouteSummarization(tenant string) ([]*models.BgpRouteSummarization, error) { - baseurlStr := "/api/node/class" - dnUrl := fmt.Sprintf("%s/uni/tn-%s/bgpRtSummPol.json", baseurlStr, tenant) + parentDn := fmt.Sprintf(models.ParentDnBgpRtSummPol, tenant) + dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, models.BgprtsummpolClassName) cont, err := sm.GetViaURL(dnUrl) list := models.BgpRouteSummarizationListFromContainer(cont) - return list, err } diff --git a/models/bgp_rt_summ_pol.go b/models/bgp_rt_summ_pol.go index 869e4027..6ca9f010 100644 --- a/models/bgp_rt_summ_pol.go +++ b/models/bgp_rt_summ_pol.go @@ -7,7 +7,12 @@ import ( "github.com/ciscoecosystem/aci-go-client/v2/container" ) -const BgprtsummpolClassName = "bgpRtSummPol" +const ( + RnBgpRtSummPol = "bgprtsum-%s" + DnBgpRtSummPol = "uni/tn-%s/bgprtsum-%s" + ParentDnBgpRtSummPol = "uni/tn-%s" + BgprtsummpolClassName = "bgpRtSummPol" +) type BgpRouteSummarization struct { BaseAttributes @@ -15,15 +20,12 @@ type BgpRouteSummarization struct { } type BgpRouteSummarizationAttributes struct { - Name string `json:",omitempty"` - + Name string `json:",omitempty"` Annotation string `json:",omitempty"` - - Attrmap string `json:",omitempty"` - - Ctrl string `json:",omitempty"` - - NameAlias string `json:",omitempty"` + Attrmap string `json:",omitempty"` + Ctrl string `json:",omitempty"` + NameAlias string `json:",omitempty"` + AddrTCtrl string `json:",omitempty"` } func NewBgpRouteSummarization(bgpRtSummPolRn, parentDn, description string, bgpRtSummPolattr BgpRouteSummarizationAttributes) *BgpRouteSummarization { @@ -36,7 +38,6 @@ func NewBgpRouteSummarization(bgpRtSummPolRn, parentDn, description string, bgpR ClassName: BgprtsummpolClassName, Rn: bgpRtSummPolRn, }, - BgpRouteSummarizationAttributes: bgpRtSummPolattr, } } @@ -48,20 +49,15 @@ func (bgpRtSummPol *BgpRouteSummarization) ToMap() (map[string]string, error) { } A(bgpRtSummPolMap, "name", bgpRtSummPol.Name) - A(bgpRtSummPolMap, "annotation", bgpRtSummPol.Annotation) - A(bgpRtSummPolMap, "attrmap", bgpRtSummPol.Attrmap) - A(bgpRtSummPolMap, "ctrl", bgpRtSummPol.Ctrl) - A(bgpRtSummPolMap, "nameAlias", bgpRtSummPol.NameAlias) - + A(bgpRtSummPolMap, "addrTCtrl", bgpRtSummPol.AddrTCtrl) return bgpRtSummPolMap, err } func BgpRouteSummarizationFromContainerList(cont *container.Container, index int) *BgpRouteSummarization { - BgpRouteSummarizationCont := cont.S("imdata").Index(index).S(BgprtsummpolClassName, "attributes") return &BgpRouteSummarization{ BaseAttributes{ @@ -71,34 +67,26 @@ func BgpRouteSummarizationFromContainerList(cont *container.Container, index int ClassName: BgprtsummpolClassName, Rn: G(BgpRouteSummarizationCont, "rn"), }, - BgpRouteSummarizationAttributes{ - - Name: G(BgpRouteSummarizationCont, "name"), - + Name: G(BgpRouteSummarizationCont, "name"), Annotation: G(BgpRouteSummarizationCont, "annotation"), - - Attrmap: G(BgpRouteSummarizationCont, "attrmap"), - - Ctrl: G(BgpRouteSummarizationCont, "ctrl"), - - NameAlias: G(BgpRouteSummarizationCont, "nameAlias"), + Attrmap: G(BgpRouteSummarizationCont, "attrmap"), + Ctrl: G(BgpRouteSummarizationCont, "ctrl"), + NameAlias: G(BgpRouteSummarizationCont, "nameAlias"), + AddrTCtrl: G(BgpRouteSummarizationCont, "addrTCtrl"), }, } } func BgpRouteSummarizationFromContainer(cont *container.Container) *BgpRouteSummarization { - return BgpRouteSummarizationFromContainerList(cont, 0) } func BgpRouteSummarizationListFromContainer(cont *container.Container) []*BgpRouteSummarization { length, _ := strconv.Atoi(G(cont, "totalCount")) - arr := make([]*BgpRouteSummarization, length) for i := 0; i < length; i++ { - arr[i] = BgpRouteSummarizationFromContainerList(cont, i) }