Skip to content

Commit e9501f8

Browse files
authored
Fix BGP demo. (#616)
* Update generated packages. * Update demo/bgp to use network-instance paths. * (M) demo/bgp/main.go - Use /network-instances/network-instance/protocols/protocol/bgp rather than /bgp which has been deprecated. * (M) demo/bgp/testdata/bgp-ietf.json - Use openconfig-network-instance rather than openconfig-bgp as a prefix since BGP is now instantiated in the network-instance module. * Update generated protobufs; remove references to /bgp. * (M): demo/protobuf_getting_started/ribproto/openconfig/enums/enums.pb.go * (M): demo/protobuf_getting_started/ribproto/openconfig/openconfig.pb.go * (M): demo/protobuf_getting_started/ribproto/openconfig/openconfig_rib_bgp/openconfig_rib_bgp.pb.go * (M): integration_tests/annotations/apb/annotation.pb.go * (M): integration_tests/annotations/proto2apb/proto2apb.pb.go * (M): proto/yext/yext.pb.go * (M): proto/ywrapper/ywrapper.pb.go - Regenerate protobufs using later version of protoc. * (M): ytypes/schema_tests/testdata/basic-extra.json * (M): ytypes/schema_tests/testdata/basic.json * (M): ytypes/schema_tests/testdata/bgp-example-opstate-with-shadow.json * (M): ytypes/schema_tests/testdata/bgp-example-opstate.json * (M): ytypes/schema_tests/testdata/bgp-example.json * (M): ytypes/schema_tests/validate_test.go - Remove references to /bgp in integration tests. * Remove unused code, update imports.
1 parent 57d8e7c commit e9501f8

File tree

22 files changed

+99940
-247346
lines changed

22 files changed

+99940
-247346
lines changed

demo/bgp/main.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func main() {
3030
if err != nil {
3131
log.Exitf("Error in OpenConfig BGP demo: %v", err)
3232
}
33+
3334
json, err := EmitBGPJSON(bgp)
3435
if err != nil {
3536
log.Exitf("Error outputting JSON: %v", err)
@@ -44,16 +45,17 @@ func main() {
4445
}
4546

4647
// CreateDemoBGPInstance creates a demo OpenConfig BGP instance using the legacy
47-
// BGP path at /bgp. It is specifically created as a separate function in order
48+
// BGP path at /network-instances/network-instance/protocols/protocol/bgp.
49+
// It is specifically created as a separate function in order
4850
// to be used as a regression test for the chain of Go struct
4951
// generation from the OpenConfig YANG schema. Returns the GoStruct that is constructed
5052
// rather than the JSON so that different rendering methods can be used.
51-
func CreateDemoBGPInstance() (*oc.Bgp, error) {
53+
func CreateDemoBGPInstance() (*oc.NetworkInstance_Protocol_Bgp, error) {
5254
// Initialise the OpenConfig BGP model at /bgp (pre-network instance). The
5355
// struct is named according to the path of the entity ignoring any "stuttering"
5456
// or "config" and "state" within the path.
55-
bgp := &oc.Bgp{
56-
Global: &oc.Bgp_Global{
57+
bgp := &oc.NetworkInstance_Protocol_Bgp{
58+
Global: &oc.NetworkInstance_Protocol_Bgp_Global{
5759
As: ygot.Uint32(15169),
5860
RouterId: ygot.String("192.0.2.42"),
5961
},
@@ -79,36 +81,36 @@ func CreateDemoBGPInstance() (*oc.Bgp, error) {
7981

8082
// Elements of the schema that themselves are containers have a struct
8183
// generated for them which can be set directly.
82-
nPeer.Timers = &oc.Bgp_Neighbor_Timers{
84+
nPeer.Timers = &oc.NetworkInstance_Protocol_Bgp_Neighbor_Timers{
8385
HoldTime: ygot.Float64(90.0),
8486
KeepaliveInterval: ygot.Float64(30.0),
8587
}
8688

8789
// An entry in a list can be directly defined as a map entry, with the multi-key
8890
// level struct specified directly.
89-
bgp.Neighbor["192.0.2.1"] = &oc.Bgp_Neighbor{
91+
bgp.Neighbor["192.0.2.1"] = &oc.NetworkInstance_Protocol_Bgp_Neighbor{
9092
PeerAs: ygot.Uint32(2856),
9193
NeighborAddress: ygot.String("192.0.2.1"),
9294
Description: ygot.String("BT UK"),
93-
Timers: &oc.Bgp_Neighbor_Timers{
95+
Timers: &oc.NetworkInstance_Protocol_Bgp_Neighbor_Timers{
9496
HoldTime: ygot.Float64(30.0),
9597
KeepaliveInterval: ygot.Float64(10.0),
9698
},
97-
Transport: &oc.Bgp_Neighbor_Transport{
99+
Transport: &oc.NetworkInstance_Protocol_Bgp_Neighbor_Transport{
98100
PassiveMode: ygot.Bool(true),
99101
},
100102
}
101103

102104
// Set the peer as a route reflector client using the String union helper typedef.
103-
bgp.Neighbor["192.0.2.1"].RouteReflector = &oc.Bgp_Neighbor_RouteReflector{
105+
bgp.Neighbor["192.0.2.1"].RouteReflector = &oc.NetworkInstance_Protocol_Bgp_Neighbor_RouteReflector{
104106
RouteReflectorClusterId: oc.UnionString("10.0.1.2"),
105107
}
106108

107109
return bgp, nil
108110
}
109111

110112
// EmitBGPJSON outputs JSON using the ygot.EmitJSON function.
111-
func EmitBGPJSON(bgp *oc.Bgp) (string, error) {
113+
func EmitBGPJSON(bgp *oc.NetworkInstance_Protocol_Bgp) (string, error) {
112114
// Outputting JSON is simply a case of calling the output library's EmitJSON
113115
// function.
114116
json, err := ygot.EmitJSON(bgp, nil)
@@ -119,7 +121,7 @@ func EmitBGPJSON(bgp *oc.Bgp) (string, error) {
119121
}
120122

121123
// EmitRFC7951JSON outputs RFC7951-compliant JSON using the ygot.EmitJSON function.
122-
func EmitRFC7951JSON(bgp *oc.Bgp) (string, error) {
124+
func EmitRFC7951JSON(bgp *oc.NetworkInstance_Protocol_Bgp) (string, error) {
123125
json, err := ygot.EmitJSON(bgp, &ygot.EmitJSONConfig{
124126
Format: ygot.RFC7951,
125127
RFC7951Config: &ygot.RFC7951JSONConfig{

demo/bgp/testdata/bgp-ietf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"openconfig-bgp:global": {
2+
"openconfig-network-instance:global": {
33
"config": {
44
"as": 15169,
55
"router-id": "192.0.2.42"
66
}
77
},
8-
"openconfig-bgp:neighbors": {
8+
"openconfig-network-instance:neighbors": {
99
"neighbor": [
1010
{
1111
"config": {

demo/protobuf_getting_started/ribproto/openconfig/enums/enums.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/protobuf_getting_started/ribproto/openconfig/openconfig.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/protobuf_getting_started/ribproto/openconfig/openconfig_rib_bgp/openconfig_rib_bgp.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)