From 41750c18bd1f9bd710cfca3b488536268188a545 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Thu, 21 Oct 2021 09:49:04 -0700 Subject: [PATCH] Changes to bgpPeerP_service.go and bgp_peer_p.go (adminSt and bgpPeerProfile relationship) (#142) --- client/bgpPeerP_service.go | 51 ++++++++++++++++++++++++++++++++++++++ models/bgp_peer_p.go | 6 +++++ 2 files changed, 57 insertions(+) diff --git a/client/bgpPeerP_service.go b/client/bgpPeerP_service.go index 22a9c26a..6009e32f 100644 --- a/client/bgpPeerP_service.go +++ b/client/bgpPeerP_service.go @@ -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 +} diff --git a/models/bgp_peer_p.go b/models/bgp_peer_p.go index d2472735..9640f408 100644 --- a/models/bgp_peer_p.go +++ b/models/bgp_peer_p.go @@ -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 { @@ -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 } @@ -119,6 +123,8 @@ func BgpPeerConnectivityProfileFromContainerList(cont *container.Container, inde Ttl: G(BgpPeerConnectivityProfileCont, "ttl"), Weight: G(BgpPeerConnectivityProfileCont, "weight"), + + AdminSt: G(BgpPeerConnectivityProfileCont, "adminSt"), }, } }