Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generated (u)?exampleoc and dependent tests. #704

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions demo/bgp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func CreateDemoBGPInstance() (*oc.NetworkInstance_Protocol_Bgp, error) {
// Initialize all containers underneath the newly created peer. This allows us
// to now specify containers in the hierarchy that we didn't yet initialize.
ygot.BuildEmptyTree(nPeer)
nPeer.Timers.HoldTime = ygot.Float64(30)
nPeer.Timers.HoldTime = ygot.Uint16(30)

// Elements of the schema that themselves are containers have a struct
// generated for them which can be set directly.
nPeer.Timers = &oc.NetworkInstance_Protocol_Bgp_Neighbor_Timers{
HoldTime: ygot.Float64(90.0),
KeepaliveInterval: ygot.Float64(30.0),
HoldTime: ygot.Uint16(90.0),
KeepaliveInterval: ygot.Uint16(30.0),
}

// An entry in a list can be directly defined as a map entry, with the multi-key
Expand All @@ -93,8 +93,8 @@ func CreateDemoBGPInstance() (*oc.NetworkInstance_Protocol_Bgp, error) {
NeighborAddress: ygot.String("192.0.2.1"),
Description: ygot.String("BT UK"),
Timers: &oc.NetworkInstance_Protocol_Bgp_Neighbor_Timers{
HoldTime: ygot.Float64(30.0),
KeepaliveInterval: ygot.Float64(10.0),
HoldTime: ygot.Uint16(30.0),
KeepaliveInterval: ygot.Uint16(10.0),
},
Transport: &oc.NetworkInstance_Protocol_Bgp_Neighbor_Transport{
PassiveMode: ygot.Bool(true),
Expand Down
8 changes: 4 additions & 4 deletions demo/bgp/testdata/bgp-ietf.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"timers": {
"config": {
"hold-time": "30",
"keepalive-interval": "10"
"hold-time": 30,
"keepalive-interval": 10
}
},
"transport": {
Expand All @@ -41,8 +41,8 @@
"neighbor-address": "2001:DB8::1",
"timers": {
"config": {
"hold-time": "90",
"keepalive-interval": "30"
"hold-time": 90,
"keepalive-interval": 30
}
}
}
Expand Down
85,042 changes: 42,722 additions & 42,320 deletions exampleoc/oc.go

Large diffs are not rendered by default.

4,265 changes: 2,444 additions & 1,821 deletions exampleoc/ocpath.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions exampleoc/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ go run ../generator/generator.go -path=public,deps -output_file=oc.go \
public/release/models/interfaces/openconfig-if-ethernet.yang \
public/release/models/interfaces/openconfig-if-ip-ext.yang \
public/release/models/relay-agent/openconfig-relay-agent.yang \
public/release/models/aft/openconfig-aft-network-instance.yang \
public/release/models/lldp/openconfig-lldp.yang
runsed -i 's/This package was generated by.*/NOTE WELL: This is an example code file that is distributed with ygot.\nIt should not be used within your application, as it WILL change,\nwithout warning. Rather, you should generate structs directly from\nOpenConfig models using the ygot package.\n\nThis package was generated by github.com\/openconfig\/ygot/g' oc.go
gofmt -w -s oc.go
Expand Down
10,695 changes: 5,997 additions & 4,698 deletions uexampleoc/oc.go

Large diffs are not rendered by default.

267 changes: 143 additions & 124 deletions ytypes/schema_tests/testdata/local-routing-example.json
Original file line number Diff line number Diff line change
@@ -1,129 +1,148 @@
{
"openconfig-local-routing:local-routes": {
"static-routes": {
"static": [
{
"prefix": "10.0.0.0/8",
"config": {
"prefix": "10.0.0.0/8"
},
"next-hops": {
"next-hop": [
{
"index": "**10.10.16.254**",
"openconfig-network-instance:network-instances": {
"network-instance": [
{
"config": {
"index": "**10.10.16.254**",
"next-hop": "10.10.16.254",
"metric": 200
"name": "DEFAULT"
},
"name": "DEFAULT",
"protocols": {
"protocol": [
{
"config": {
"identifier": "openconfig-policy-types:STATIC",
"name": "0"
},
"identifier": "openconfig-policy-types:STATIC",
"name": "0",
"static-routes": {
"static": [
{
"config": {
"prefix": "10.0.0.0/8"
},
"next-hops": {
"next-hop": [
{
"config": {
"index": "**10.10.16.254**",
"metric": 200,
"next-hop": "10.10.16.254"
},
"index": "**10.10.16.254**"
},
{
"config": {
"index": "**10.10.17.254**",
"metric": 200,
"next-hop": "10.10.17.254"
},
"index": "**10.10.17.254**"
},
{
"config": {
"index": "**10.10.18.254**",
"metric": 200,
"next-hop": "10.10.18.254"
},
"index": "**10.10.18.254**"
}
]
},
"prefix": "10.0.0.0/8"
},
{
"config": {
"prefix": "10.244.168.0/25",
"set-tag": 9999
},
"next-hops": {
"next-hop": [
{
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
},
"index": "**openconfig-local-routing:DROP**"
}
]
},
"prefix": "10.244.168.0/25"
},
{
"config": {
"prefix": "172.16.0.0/12"
},
"next-hops": {
"next-hop": [
{
"config": {
"index": "**10.10.16.254**",
"metric": 200,
"next-hop": "10.10.16.254"
},
"index": "**10.10.16.254**"
},
{
"config": {
"index": "**10.10.17.254**",
"metric": 200,
"next-hop": "10.10.17.254"
},
"index": "**10.10.17.254**"
},
{
"config": {
"index": "**10.10.18.254**",
"metric": 200,
"next-hop": "10.10.18.254"
},
"index": "**10.10.18.254**"
}
]
},
"prefix": "172.16.0.0/12"
},
{
"config": {
"prefix": "192.0.2.1/32"
},
"next-hops": {
"next-hop": [
{
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
},
"index": "**openconfig-local-routing:DROP**"
}
]
},
"prefix": "192.0.2.1/32"
},
{
"config": {
"prefix": "fc00::/128"
},
"next-hops": {
"next-hop": [
{
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
},
"index": "**openconfig-local-routing:DROP**"
}
]
},
"prefix": "fc00::/128"
}
]
}
}
]
}
},
{
"index": "**10.10.17.254**",
"config": {
"index": "**10.10.17.254**",
"next-hop": "10.10.17.254",
"metric": 200
}
},
{
"index": "**10.10.18.254**",
"config": {
"index": "**10.10.18.254**",
"next-hop": "10.10.18.254",
"metric": 200
}
}
]
}
},
{
"prefix": "10.244.168.0/25",
"config": {
"prefix": "10.244.168.0/25",
"set-tag": 9999
},
"next-hops": {
"next-hop": [
{
"index": "**openconfig-local-routing:DROP**",
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
}
}
]
}
},
{
"prefix": "172.16.0.0/12",
"config": {
"prefix": "172.16.0.0/12"
},
"next-hops": {
"next-hop": [
{
"index": "**10.10.16.254**",
"config": {
"index": "**10.10.16.254**",
"next-hop": "10.10.16.254",
"metric": 200
}
},
{
"index": "**10.10.17.254**",
"config": {
"index": "**10.10.17.254**",
"next-hop": "10.10.17.254",
"metric": 200
}
},
{
"index": "**10.10.18.254**",
"config": {
"index": "**10.10.18.254**",
"next-hop": "10.10.18.254",
"metric": 200
}
}
]
}
},
{
"prefix": "192.0.2.1/32",
"config": {
"prefix": "192.0.2.1/32"
},
"next-hops": {
"next-hop": [
{
"index": "**openconfig-local-routing:DROP**",
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
}
}
]
}
},
{
"prefix": "fc00::/128",
"config": {
"prefix": "fc00::/128"
},
"next-hops": {
"next-hop": [
{
"index": "**openconfig-local-routing:DROP**",
"config": {
"index": "**openconfig-local-routing:DROP**",
"next-hop": "openconfig-local-routing:DROP"
}
}
]
}
}
]
}
]
}
}
}

10 changes: 5 additions & 5 deletions ytypes/schema_tests/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ import (
// To debug a schema node subtree, any of the following can be used:
//
// 1. Print hierarchy without details (good for viewing large subtrees):
// fmt.Println(schemaTreeString(oc.SchemaTree["LocalRoutes_Static"], ""))
// fmt.Println(schemaTreeString(oc.SchemaTree["NetworkInstance_Protocol_Static"], ""))
//
// 2. Print in-memory structure representations. Replace is needed due to large
// default util.Indentations:
// fmt.Println(strings.Replace(pretty.Sprint(oc.SchemaTree["LocalRoutes_Static"].Dir["next-hops"].Dir["next-hop"].Dir["config"].Dir["next-hop"])[0:], " ", " ", -1))
// fmt.Println(strings.Replace(pretty.Sprint(oc.SchemaTree["NetworkInstance_Protocol_Static"].Dir["next-hops"].Dir["next-hop"].Dir["config"].Dir["next-hop"])[0:], " ", " ", -1))
//
// 3. Detailed representation in JSON format:
// j, _ := json.MarshalIndent(oc.SchemaTree["LocalRoutes_Static"].Dir["next-hops"].Dir["next-hop"].Dir["config"].Dir["next-hop"], "", " ")
// j, _ := json.MarshalIndent(oc.SchemaTree["NetworkInstance_Protocol_Static"].Dir["next-hops"].Dir["next-hop"].Dir["config"].Dir["next-hop"], "", " ")
// fmt.Println(string(j))
//
// 4. Combination of schema and data trees:
Expand Down Expand Up @@ -511,8 +511,8 @@ func TestValidateBGP(t *testing.T) {

func TestValidateLocalRoutes(t *testing.T) {
// This schema element contains a union of union.
lrs := &oc.LocalRoutes_Static{
NextHop: map[string]*oc.LocalRoutes_Static_NextHop{
lrs := &oc.NetworkInstance_Protocol_Static{
NextHop: map[string]*oc.NetworkInstance_Protocol_Static_NextHop{
"10.10.10.10": {
Index: ygot.String("10.10.10.10"),
NextHop: oc.UnionString("10.10.10.1"),
Expand Down