Skip to content

Commit

Permalink
Changes to bgpPeerP_service.go and bgp_peer_p.go (adminSt and bgpPeer…
Browse files Browse the repository at this point in the history
…Profile relationship) (#142)
  • Loading branch information
shrsr authored Oct 21, 2021
1 parent d182eed commit 41750c1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
51 changes: 51 additions & 0 deletions client/bgpPeerP_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,54 @@ func (sm *ServiceManager) ReadRelationbgpRsPeerPfxPolFromBgpPeerConnectivityProf
}

}

func (sm *ServiceManager) CreateRelationbgpRsPeerToProfile(parentDn, annotation, direction string, tDn string) error {
dn := fmt.Sprintf("%s/rspeerToProfile-[%s]-%s", parentDn, tDn, direction)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "%s",
"tDn": "%s",
"direction": "%s"
}
}
}`, "bgpRsPeerToProfile", dn, annotation, tDn, direction))

jsonPayload, err := container.ParseJSON(containerJSON)
if err != nil {
return err
}

req, err := sm.client.MakeRestRequest("POST", fmt.Sprintf("%s.json", sm.MOURL), jsonPayload, true)
if err != nil {
return err
}
cont, _, err := sm.client.Do(req)
if err != nil {
return err
}
fmt.Printf("%+v", cont)
return nil
}

func (sm *ServiceManager) DeleteRelationbgpRsPeerToProfile(parentDn, tDn, direction string) error {
dn := fmt.Sprintf("%s/rspeerToProfile-[%s]-%s", parentDn, tDn, direction)
return sm.DeleteByDn(dn, "bgpRsPeerToProfile")
}

func (sm *ServiceManager) ReadRelationbgpRsPeerToProfile(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "bgpRsPeerToProfile")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "bgpRsPeerToProfile")

st := make([]map[string]string, 0)
for _, contItem := range contList {
paramMap := make(map[string]string)
paramMap["tDn"] = models.G(contItem, "tDn")
paramMap["direction"] = models.G(contItem, "direction")

st = append(st, paramMap)
}
return st, err
}
6 changes: 6 additions & 0 deletions models/bgp_peer_p.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type BgpPeerConnectivityProfileAttributes struct {
Ttl string `json:",omitempty"`

Weight string `json:",omitempty"`

AdminSt string `json:",omitempty"`
}

func NewBgpPeerConnectivityProfile(bgpPeerPRn, parentDn, description string, bgpPeerPattr BgpPeerConnectivityProfileAttributes) *BgpPeerConnectivityProfile {
Expand Down Expand Up @@ -81,6 +83,8 @@ func (bgpPeerP *BgpPeerConnectivityProfile) ToMap() (map[string]string, error) {

A(bgpPeerPMap, "weight", bgpPeerP.Weight)

A(bgpPeerPMap, "adminSt", bgpPeerP.AdminSt)

return bgpPeerPMap, err
}

Expand Down Expand Up @@ -119,6 +123,8 @@ func BgpPeerConnectivityProfileFromContainerList(cont *container.Container, inde
Ttl: G(BgpPeerConnectivityProfileCont, "ttl"),

Weight: G(BgpPeerConnectivityProfileCont, "weight"),

AdminSt: G(BgpPeerConnectivityProfileCont, "adminSt"),
},
}
}
Expand Down

0 comments on commit 41750c1

Please sign in to comment.