openconfig / ondatra

54 stars 37 forks source link

support needed to get RouteAnyPrefix() leaf and AsPath() leaves for BGP Rib #67

Closed cprabha closed 1 year ago

cprabha commented 1 year ago

Hi,

I have to get AsPath for all the prefixes in rib . Below is not supported, please could you check, I have highglighed unsupported leaf in bold.

rib := at.NetworkInstance(ap.Name()).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, fmt.Sprintf("bgp-%s", ap.Name())).Bgp().Rib() prefixPath := rib.AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast(). Neighbor(setup.DUTIPList[ap.ID()].String()).AdjRibInPre().RouteAnyPrefix(0).Prefix() pref := gnmi.Get(t, dut, prefixPath.State()) asPath := gnmi.Get(t, dut, rib.AttrSetAny().AsPath().State())

Thanks, Prabha

greg-dennis commented 1 year ago

@cprabha, what do you mean by RouteAnyPrefix(0).Prefix()? The Route list has three keys: path-id, endpoint, and color. Is the 0 meant to be a path-id and you want to a wildcard for the endpoint and color? If so, that would be available as AdjRibInPre().RouteAny().WithPathId(0).Prefix()

Also, you won't see AsPath() because it is an enclosing container for the as-segment list, and ygnmi always elides enclosing container for lists. If you want all the segments of the as-path use AttrSetAny().AsSegmentAny()

cprabha commented 1 year ago

Thanks Greg, It worked fine with AdjRibInPre().RouteAny().WithPathId(0).Prefix() and AttrSetAny().AsSegmentAny().

cprabha commented 1 year ago

@greg-dennis , asPath := gnmi.GetAll(t, ate, rib.AttrSetAny().AsSegmentAny().State()) ==> this is returning pointer instead of value . Can you please check ?

Output

asPath []github.com/openconfig/ondatra/gnmi/oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet_AsSegment len: 200, cap: 200, [{Index: 0, Member: []uint32 len: 5, cap: 8, [64500,64500,64500,64500,64502], Type: RibBgp_AsPathSegmentType_AS_SEQ (1)},{Index: 0, Member: ... [0..99]: [0]: github.com/openconfig/ondatra/gnmi/oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet_AsSegment {Index: 0, Member: []uint32 len: 5, cap: 8, [64500,64500,64500,64500,64502], Type: RibBgp_AsPathSegmentType_AS_SEQ (1)} [1]: github.com/openconfig/ondatra/gnmi/oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet_AsSegment {Index: *0, Member: []uint32 len: 5, cap: 8, [64500,64500,64500,64500,64502], Type: RibBgp_AsPathSegmentType_AS_SEQ (1)}

Thanks, Prabha

greg-dennis commented 1 year ago

@cprabha, GetAll is returning a list of all the segments, which should be expected. Does that make sense?

cprabha commented 1 year ago

got it, Thanks Greg.