Skip to content

Commit

Permalink
Added addrTCtrl to bgp_rt_summ_pol.go model
Browse files Browse the repository at this point in the history
  • Loading branch information
sajagana authored and lhercot committed Apr 11, 2023
1 parent a27a654 commit 2bc9f55
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
34 changes: 23 additions & 11 deletions client/bgpRtSummPol_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
46 changes: 17 additions & 29 deletions models/bgp_rt_summ_pol.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ 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
BgpRouteSummarizationAttributes
}

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 {
Expand All @@ -36,7 +38,6 @@ func NewBgpRouteSummarization(bgpRtSummPolRn, parentDn, description string, bgpR
ClassName: BgprtsummpolClassName,
Rn: bgpRtSummPolRn,
},

BgpRouteSummarizationAttributes: bgpRtSummPolattr,
}
}
Expand All @@ -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{
Expand All @@ -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)
}

Expand Down

0 comments on commit 2bc9f55

Please sign in to comment.