profile
viewpoint

progressnerd/dbg-pencilcode-site 1

An online IDE for kids: pencilcode.net.

esrauch/pencilcode-site-gdrive 0

An online IDE for kids: pencilcode.net.

progressnerd/friendlypix-ios 0

Friendly Pix iOS is a sample app demonstrating how to build an iOS app with the Firebase Platform.

progressnerd/ideviceinstaller 0

Manage apps of iOS devices

progressnerd/libimobiledevice 0

A cross-platform protocol library to communicate with iOS devices

progressnerd/libplist 0

A library to handle Apple Property List format in binary or XML

issue openedopenconfig/ygot

replacement of NewNode function in expermintal ygotutils

What is the replacement of this function call:

	rootNode, stat := ygotutils.NewNode(m.structRootType, &pb.Path{})

created time in 11 hours

issue commentopenconfig/ygot

list node contains more than max allowed elements

It's hard to analyze the generated code because the goyang schema is serialized here and you can't see the value of MaxElements for that Entry object. I'm really not seeing how goyang could've parsed "0" for max-elements when it's not set. If it's really not set (either directly or via a deviation), then it's probably a goyang bug somewhere, but then the problem is likely moot because I'll be fixing this bug here that you helped me find: https://github.com/openconfig/goyang/issues/154

adibrastegarnia

comment created time in 15 hours

issue commentopenconfig/ygot

list node contains more than max allowed elements

@wenovus

No in the yang file as I provided above, nothing is set. The error comes exactly from the util_scheme.

Here is the new model generated using new version of ygot

// Code generated by YGOT. DO NOT EDIT.
/*
Package ric_1_0_0 is a generated package which contains definitions
of structs which represent a YANG schema. The generated schema can be
compressed by a series of transformations (compression was false
in this case).

This package was generated by /Users/adibrastegarnia/go/pkg/mod/github.com/openconfig/ygot@v0.8.11/genutil/names.go
using the following YANG input files:
	- test1@2020-11-18.yang
	- xapp@2020-11-24.yang
Imported modules were sourced from:
	- yang/...
*/
package ric_1_0_0

import (
	"encoding/json"
	"fmt"
	"reflect"

	"github.com/openconfig/ygot/ygot"
	"github.com/openconfig/goyang/pkg/yang"
	"github.com/openconfig/ygot/ytypes"
)

// Binary is a type that is used for fields that have a YANG type of
// binary. It is used such that binary fields can be distinguished from
// leaf-lists of uint8s (which are mapped to []uint8, equivalent to
// []byte in reflection).
type Binary []byte

// YANGEmpty is a type that is used for fields that have a YANG type of
// empty. It is used such that empty fields can be distinguished from boolean fields
// in the generated code.
type YANGEmpty bool

var (
	SchemaTree map[string]*yang.Entry
)

func init() {
	var err error
	if SchemaTree, err = UnzipSchema(); err != nil {
		panic("schema error: " +  err.Error())
	}
}

// Schema returns the details of the generated schema.
func Schema() (*ytypes.Schema, error) {
	uzp, err := UnzipSchema()
	if err != nil {
		return nil, fmt.Errorf("cannot unzip schema, %v", err)
	}

	return &ytypes.Schema{
		Root: &Device{},
		SchemaTree: uzp,
		Unmarshal: Unmarshal,
	}, nil
}

// UnzipSchema unzips the zipped schema and returns a map of yang.Entry nodes,
// keyed by the name of the struct that the yang.Entry describes the schema for.
func UnzipSchema() (map[string]*yang.Entry, error) {
	var schemaTree map[string]*yang.Entry
	var err error
	if schemaTree, err = ygot.GzipToSchema(ySchema); err != nil {
		return nil, fmt.Errorf("could not unzip the schema; %v", err)
	}
	return schemaTree, nil
}

// Unmarshal unmarshals data, which must be RFC7951 JSON format, into
// destStruct, which must be non-nil and the correct GoStruct type. It returns
// an error if the destStruct is not found in the schema or the data cannot be
// unmarshaled. The supplied options (opts) are used to control the behaviour
// of the unmarshal function - for example, determining whether errors are
// thrown for unknown fields in the input JSON.
func Unmarshal(data []byte, destStruct ygot.GoStruct, opts ...ytypes.UnmarshalOpt) error {
	tn := reflect.TypeOf(destStruct).Elem().Name()
	schema, ok := SchemaTree[tn]
	if !ok {
		return fmt.Errorf("could not find schema for type %s", tn )
	}
	var jsonTree interface{}
	if err := json.Unmarshal([]byte(data), &jsonTree); err != nil {
		return err
	}
	return ytypes.Unmarshal(schema, destStruct, jsonTree, opts...)
}

// Device represents the /device YANG schema element.
type Device struct {
	Cont1A	*Test1_Cont1A	`path:"cont1a" module:"test1"`
	Nodes	*Xapp_Nodes	`path:"nodes" module:"xapp"`
}

// IsYANGGoStruct ensures that Device implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Device) IsYANGGoStruct() {}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Device) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Device"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Device) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Test1_Cont1A represents the /test1/cont1a YANG schema element.
type Test1_Cont1A struct {
	Leaf1A	*string	`path:"leaf1a" module:"test1"`
	Leaf2A	*string	`path:"leaf2a" module:"test1"`
}

// IsYANGGoStruct ensures that Test1_Cont1A implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Test1_Cont1A) IsYANGGoStruct() {}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Test1_Cont1A) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Test1_Cont1A"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Test1_Cont1A) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Xapp_Nodes represents the /xapp/nodes YANG schema element.
type Xapp_Nodes struct {
	Node	map[string]*Xapp_Nodes_Node	`path:"node" module:"xapp"`
}

// IsYANGGoStruct ensures that Xapp_Nodes implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Xapp_Nodes) IsYANGGoStruct() {}

// NewNode creates a new entry in the Node list of the
// Xapp_Nodes struct. The keys of the list are populated from the input
// arguments.
func (t *Xapp_Nodes) NewNode(Id string) (*Xapp_Nodes_Node, error){

	// Initialise the list within the receiver struct if it has not already been
	// created.
	if t.Node == nil {
		t.Node = make(map[string]*Xapp_Nodes_Node)
	}

	key := Id

	// Ensure that this key has not already been used in the
	// list. Keyed YANG lists do not allow duplicate keys to
	// be created.
	if _, ok := t.Node[key]; ok {
		return nil, fmt.Errorf("duplicate key %v for list Node", key)
	}

	t.Node[key] = &Xapp_Nodes_Node{
		Id: &Id,
	}

	return t.Node[key], nil
}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Xapp_Nodes) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Xapp_Nodes"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Xapp_Nodes) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Xapp_Nodes_Node represents the /xapp/nodes/node YANG schema element.
type Xapp_Nodes_Node struct {
	Id	*string	`path:"id" module:"xapp"`
	Ip	*string	`path:"ip" module:"xapp"`
	PlmnId	*string	`path:"plmn-id" module:"xapp"`
	Port	*uint16	`path:"port" module:"xapp"`
}

// IsYANGGoStruct ensures that Xapp_Nodes_Node implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Xapp_Nodes_Node) IsYANGGoStruct() {}

// ΛListKeyMap returns the keys of the Xapp_Nodes_Node struct, which is a YANG list entry.
func (t *Xapp_Nodes_Node) ΛListKeyMap() (map[string]interface{}, error) {
	if t.Id == nil {
		return nil, fmt.Errorf("nil value for key Id")
	}

	return map[string]interface{}{
		"id": *t.Id,
	}, nil
}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Xapp_Nodes_Node) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Xapp_Nodes_Node"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Xapp_Nodes_Node) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }



var (
	// ySchema is a byte slice contain a gzip compressed representation of the
	// YANG schema from which the Go code was generated. When uncompressed the
	// contents of the byte slice is a JSON document containing an object, keyed
	// on the name of the generated struct, and containing the JSON marshalled
	// contents of a goyang yang.Entry struct, which defines the schema for the
	// fields within the struct.
	ySchema = []byte{
		0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5a, 0x6b, 0x6f, 0xb3, 0x36,
		0x14, 0xfe, 0x9e, 0x5f, 0x81, 0x2c, 0xbd, 0x12, 0xf4, 0x85, 0x04, 0xd2, 0x90, 0x36, 0x7c, 0x89,
		0xb2, 0xb7, 0xab, 0x26, 0xf5, 0xb2, 0xa9, 0xab, 0xa6, 0x49, 0x84, 0x55, 0x5e, 0x70, 0x52, 0x6b,
		0x89, 0x41, 0xe0, 0x74, 0xad, 0x12, 0xfe, 0xfb, 0xc4, 0x25, 0x69, 0xb8, 0xdb, 0xac, 0xe9, 0x45,
		0xe2, 0x0b, 0xa5, 0x3e, 0x8f, 0xf1, 0xf1, 0x79, 0x1e, 0x7c, 0x4e, 0x0f, 0xdd, 0x74, 0x04, 0x41,
		0x10, 0xc0, 0x2d, 0x5c, 0x21, 0x60, 0x08, 0xc0, 0x46, 0x4f, 0x78, 0x86, 0x80, 0x1c, 0x8f, 0x5e,
		0x61, 0x62, 0x03, 0x43, 0xd0, 0x92, 0x5f, 0x7f, 0x38, 0x64, 0x8e, 0x17, 0xc0, 0x10, 0xd4, 0x64,
		0xe0, 0x02, 0x7b, 0xc0, 0x10, 0xe2, 0x47, 0x44, 0x03, 0x33, 0x87, 0x50, 0x0d, 0xa6, 0xc6, 0x52,
		0x8f, 0x4f, 0xec, 0x72, 0xda, 0x9a, 0x5e, 0x66, 0x3f, 0x9c, 0x5d, 0x6e, 0x6f, 0xf8, 0xcd, 0x43,
		0x73, 0xfc, 0x9c, 0x5b, 0x25, 0xb5, 0x12, 0xd5, 0x32, 0xab, 0x44, 0xd6, 0xdf, 0x9d, 0xb5, 0x37,
		0x43, 0x85, 0x33, 0x63, 0x4f, 0xd0, 0xcb, 0xbf, 0x8e, 0x17, 0x3a, 0x03, 0xdc, 0x78, 0x11, 0xb9,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, 0x7e, 0x10, 0xe8, 0x1c, 0xb8, 0x54, 0xe6, 0x0a,
		0xc0, 0xfe, 0x25, 0xfc, 0x07, 0xdd, 0x39, 0x4e, 0x3e, 0xf7, 0x64, 0xdd, 0x03, 0x87, 0xa6, 0x94,
		0x33, 0x17, 0xf1, 0x7f, 0xec, 0xc4, 0x0b, 0x76, 0x82, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x01,
		0x00, 0x00, 0xff, 0xff, 0x65, 0x0f, 0x50, 0xbf, 0xd0, 0x23, 0x00, 0x00,
	}
)


// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
}

adibrastegarnia

comment created time in 15 hours

issue commentopenconfig/ygot

list node contains more than max allowed elements

Thanks for providing the info. With those version, what I said can't be the reason for failure, but thanks for helping me discover a bug.

In your case, I'm quite confused. Does the model explicitly set max-elements 0 in the list? https://github.com/openconfig/ygot/blob/e3c44fa439262c24ff5d3dc62b662b10f49181c3/ytypes/util_schema.go#L123 There is no other way I can see that max is 0.

The gNMI CLI doesn't even use goyang, so I doubt it's the CLI. If you really wanted to know then you can revert to the version and debug from that line, but I'm glad it's working now.

adibrastegarnia

comment created time in 15 hours

issue commentopenconfig/ygot

list node contains more than max allowed elements

@wenovus After upgrading ygot to generate, it seems I don't see the error anymore but I am still wondering it is a model problem or CLI thing

adibrastegarnia

comment created time in 15 hours

created tagopenconfig/ygot

tagv0.8.12

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling

created time in 15 hours

release openconfig/ygot

v0.8.12

released time in 15 hours

delete branch openconfig/ygot

delete branch : diff-ignore-default-values

delete time in 15 hours

push eventopenconfig/ygot

Wen Bo Li

commit sha db9807134f5fc0d25017319da484506d195286ae

Ignore default data values in findSetLeaves (#476) * Ignore default data values in findSetLeaves

view details

push time in 15 hours

PR merged openconfig/ygot

Ignore default data values in findSetLeaves cla: yes

Add a check for the default value to the bail condition in findSetLeaves. Resolves #473

Currently, the default value of false for YANGEmpty is counted as set by findSetLeaves. This is clearly not what findSetLeaves intended, as the only form of a set YANGEmpty is true.

+16 -3

1 comment

3 changed files

wenovus

pr closed time in 15 hours

issue closedopenconfig/ygot

ygot.Diff generating gnmi update TypeVal as bool for leaf type yang.Empty

ygot v0.8.11

I have this yang defined

module dummy {
    yang-version "1";
    namespace "urn:dummy/dummy";
    prefix "dummy";
    grouping dummy-entry {
        list entries {
            key "name";
            leaf name {
                type string;
            }
            leaf city {
                type string;
            }
            leaf primary {
                type empty;
            }
        }
    }
    uses dummy-entry;
}

I created two Device{} structs with the following jsons

Object1:

{
    "entries":[
      {  
            "name": "samanta",
            "city": "xyz"
      }
    ]
}

Object2:

{
    "entries":[
      {  
            "name": "samanta",
            "city": "xyz"
      },
      {  
            "name": "soumik",
            "city": "abc"
      }
    ]
}
dummy1Data := &dummy.Device{}
dummy.Unmarshal("object1.json", dummy1Data)
dummy2Data := &dummy.Device{}
dummy.Unmarshal("object2.json", dummy2Data)

Now when I try to do a diff of dummy1Data and dummy2Data diffData, err = ygot.Diff(dummy2Data, dummy1Data)

I get the following gnmi.Notification object

update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "samanta"
      >
    >
    elem: <
      name: "primary"
    >
  >
  val: <
    bool_val: false
  >
>
update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "soumik"
      >
    >
    elem: <
      name: "city"
    >
  >
  val: <
    string_val: "abc"
  >
>
update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "soumik"
      >
    >
    elem: <
      name: "name"
    >
  >
  val: <
    string_val: "soumik"
  >
>
update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "soumik"
      >
    >
    elem: <
      name: "primary"
    >
  >
  val: <
    bool_val: false
  >
>
update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "samanta"
      >
    >
    elem: <
      name: "city"
    >
  >
  val: <
    string_val: "xyz"
  >
>
update: <
  path: <
    elem: <
      name: "entries"
      key: <
        key: "name"
        value: "samanta"
      >
    >
    elem: <
      name: "name"
    >
  >
  val: <
    string_val: "samanta"
  >
>

In the notification object, the yang.Empty path "primary" is set as value "bool". which is not conforming to the yang model. And as per https://tools.ietf.org/html/rfc7951#section-6.9 yang.Empty is actually a slice

closed time in 15 hours

soumiksamanta

issue commentopenconfig/ygot

list node contains more than max allowed elements

@wenovus Thanks for your response. Just to make sure we are on the same. For some reasons, we are using these versions for generating models:

        github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c
	github.com/openconfig/goyang v0.0.0-20200115183954-d0a48929f0ea
	github.com/openconfig/ygot v0.6.1-0.20200103195725-e3c44fa43926

Do you think the model itself is the source of the issue or CLI?

Here is the generated model if it helps

// Code generated by YGOT. DO NOT EDIT.
// Code generated by YGOT. DO NOT EDIT.
/*
Package ric_1_0_0 is a generated package which contains definitions
of structs which represent a YANG schema. The generated schema can be
compressed by a series of transformations (compression was false
in this case).

This package was generated by /Users/adibrastegarnia/go/pkg/mod/github.com/openconfig/ygot@v0.6.1-0.20200103195725-e3c44fa43926/genutil/names.go
using the following YANG input files:
	- test1@2020-11-18.yang
	- xapp@2020-11-24.yang
Imported modules were sourced from:
	- yang/...
*/
package ric_1_0_0

import (
	"encoding/json"
	"fmt"
	"reflect"

	"github.com/openconfig/ygot/ygot"
	"github.com/openconfig/goyang/pkg/yang"
	"github.com/openconfig/ygot/ytypes"
)

// Binary is a type that is used for fields that have a YANG type of
// binary. It is used such that binary fields can be distinguished from
// leaf-lists of uint8s (which are mapped to []uint8, equivalent to
// []byte in reflection).
type Binary []byte

// YANGEmpty is a type that is used for fields that have a YANG type of
// empty. It is used such that empty fields can be distinguished from boolean fields
// in the generated code.
type YANGEmpty bool

var (
	SchemaTree map[string]*yang.Entry
)

func init() {
	var err error
	if SchemaTree, err = UnzipSchema(); err != nil {
		panic("schema error: " +  err.Error())
	}
}

// Schema returns the details of the generated schema.
func Schema() (*ytypes.Schema, error) {
	uzp, err := UnzipSchema()
	if err != nil {
		return nil, fmt.Errorf("cannot unzip schema, %v", err)
	}

	return &ytypes.Schema{
		Root: &Device{},
		SchemaTree: uzp,
		Unmarshal: Unmarshal,
	}, nil
}

// UnzipSchema unzips the zipped schema and returns a map of yang.Entry nodes,
// keyed by the name of the struct that the yang.Entry describes the schema for.
func UnzipSchema() (map[string]*yang.Entry, error) {
	var schemaTree map[string]*yang.Entry
	var err error
	if schemaTree, err = ygot.GzipToSchema(ySchema); err != nil {
		return nil, fmt.Errorf("could not unzip the schema; %v", err)
	}
	return schemaTree, nil
}

// Unmarshal unmarshals data, which must be RFC7951 JSON format, into
// destStruct, which must be non-nil and the correct GoStruct type. It returns
// an error if the destStruct is not found in the schema or the data cannot be
// unmarshaled. The supplied options (opts) are used to control the behaviour
// of the unmarshal function - for example, determining whether errors are
// thrown for unknown fields in the input JSON.
func Unmarshal(data []byte, destStruct ygot.GoStruct, opts ...ytypes.UnmarshalOpt) error {
	tn := reflect.TypeOf(destStruct).Elem().Name()
	schema, ok := SchemaTree[tn]
	if !ok {
		return fmt.Errorf("could not find schema for type %s", tn )
	}
	var jsonTree interface{}
	if err := json.Unmarshal([]byte(data), &jsonTree); err != nil {
		return err
	}
	return ytypes.Unmarshal(schema, destStruct, jsonTree, opts...)
}

// Device represents the /device YANG schema element.
type Device struct {
	Cont1A	*Test1_Cont1A	`path:"cont1a" module:"test1"`
	Nodes	*Xapp_Nodes	`path:"nodes" module:"xapp"`
}

// IsYANGGoStruct ensures that Device implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Device) IsYANGGoStruct() {}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Device) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Device"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Device) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Test1_Cont1A represents the /test1/cont1a YANG schema element.
type Test1_Cont1A struct {
	Leaf1A	*string	`path:"leaf1a" module:"test1"`
	Leaf2A	*string	`path:"leaf2a" module:"test1"`
}

// IsYANGGoStruct ensures that Test1_Cont1A implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Test1_Cont1A) IsYANGGoStruct() {}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Test1_Cont1A) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Test1_Cont1A"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Test1_Cont1A) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Xapp_Nodes represents the /xapp/nodes YANG schema element.
type Xapp_Nodes struct {
	Node	map[string]*Xapp_Nodes_Node	`path:"node" module:"xapp"`
}

// IsYANGGoStruct ensures that Xapp_Nodes implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Xapp_Nodes) IsYANGGoStruct() {}

// NewNode creates a new entry in the Node list of the
// Xapp_Nodes struct. The keys of the list are populated from the input
// arguments.
func (t *Xapp_Nodes) NewNode(Id string) (*Xapp_Nodes_Node, error){

	// Initialise the list within the receiver struct if it has not already been
	// created.
	if t.Node == nil {
		t.Node = make(map[string]*Xapp_Nodes_Node)
	}

	key := Id

	// Ensure that this key has not already been used in the
	// list. Keyed YANG lists do not allow duplicate keys to
	// be created.
	if _, ok := t.Node[key]; ok {
		return nil, fmt.Errorf("duplicate key %v for list Node", key)
	}

	t.Node[key] = &Xapp_Nodes_Node{
		Id: &Id,
	}

	return t.Node[key], nil
}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Xapp_Nodes) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Xapp_Nodes"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Xapp_Nodes) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }


// Xapp_Nodes_Node represents the /xapp/nodes/node YANG schema element.
type Xapp_Nodes_Node struct {
	Id	*string	`path:"id" module:"xapp"`
	Ip	*string	`path:"ip" module:"xapp"`
	PlmnId	*string	`path:"plmn-id" module:"xapp"`
	Port	*uint16	`path:"port" module:"xapp"`
}

// IsYANGGoStruct ensures that Xapp_Nodes_Node implements the yang.GoStruct
// interface. This allows functions that need to handle this struct to
// identify it as being generated by ygen.
func (*Xapp_Nodes_Node) IsYANGGoStruct() {}

// ΛListKeyMap returns the keys of the Xapp_Nodes_Node struct, which is a YANG list entry.
func (t *Xapp_Nodes_Node) ΛListKeyMap() (map[string]interface{}, error) {
	if t.Id == nil {
		return nil, fmt.Errorf("nil value for key Id")
	}

	return map[string]interface{}{
		"id": *t.Id,
	}, nil
}

// Validate validates s against the YANG schema corresponding to its type.
func (t *Xapp_Nodes_Node) Validate(opts ...ygot.ValidationOption) error {
	if err := ytypes.Validate(SchemaTree["Xapp_Nodes_Node"], t, opts...); err != nil {
		return err
	}
	return nil
}

// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types
// that are included in the generated code.
func (t *Xapp_Nodes_Node) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes }



var (
	// ySchema is a byte slice contain a gzip compressed representation of the
	// YANG schema from which the Go code was generated. When uncompressed the
	// contents of the byte slice is a JSON document containing an object, keyed
	// on the name of the generated struct, and containing the JSON marshalled
	// contents of a goyang yang.Entry struct, which defines the schema for the
	// fields within the struct.
	ySchema = []byte{
		0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5a, 0x6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ff, 0xff, 0x01, 0x00, 0x00,
		0xff, 0xff, 0xcf, 0x20, 0xc6, 0x25, 0xc3, 0x23, 0x00, 0x00,
	}
)


// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that
// correspond with the leaf. The type is represented as a reflect.Type. The naming
// of the map ensures that there are no clashes with valid YANG identifiers.
var ΛEnumTypes = map[string][]reflect.Type{
}


adibrastegarnia

comment created time in 15 hours

issue commentopenconfig/ygot

list node contains more than max allowed elements

This is probably an unintentional bug somewhere in the CLI code due to a bad design when I was implementing the new max-element/min-element storage using uint64, where I missed the corner case that max-elements is >= 1, and 0 is an invalid element. I'll fix this so when people instantiate a new ListAttr goyang struct it doesn't mean a 0..0 range.

I'm guessing your specific issue came about because someone forgot to use NewDefaultListAttr, which correctly sets MaxElements to math.MaxUint64, and instead used ListAttr{}. I'll create a fix for the corner case in goyang, and once incorporated, I'm guessing that it will resolve the error.

adibrastegarnia

comment created time in 16 hours

create barnchopenconfig/ygot

branch : list-attr-new-constructor

created branch time in 16 hours

issue commentopenconfig/ygot

ygot.Diff generating gnmi update TypeVal as bool for leaf type yang.Empty

Thanks, added a similar test to the fix.

soumiksamanta

comment created time in 16 hours

push eventopenconfig/ygot

wenovus

commit sha a98f9cc55935058d4fb730e25ca92ab1a413eceb

remove extraneous code

view details

push time in 16 hours

push eventopenconfig/ygot

wenovus

commit sha eef71bf863d0df00e8c4f2f6a9c79018b69f6c96

fix test

view details

push time in 16 hours

push eventopenconfig/ygot

wenovus

commit sha 9f2e65a5e61c49195f3fae2949495c98b153dfa6

Add tests for ygot.Diff

view details

push time in 16 hours

pull request commentopenconfig/ygot

Ignore default data values in findSetLeaves

Coverage Status

Coverage increased (+0.0008%) to 90.617% when pulling 9819aa11fbd2bfe488e6798c09efec73d232d596 on diff-ignore-default-values into b0419a695df53df4cf269e6f848fcea9b697ccd5 on master.

wenovus

comment created time in 16 hours

PR opened openconfig/ygot

Ignore default data values in findSetLeaves

Resolves #473

Currently, the default value of false for YANGEmpty is counted as set by findSetLeaves. This is clearly not what findSetLeaves intended, as the only form of a set YANGEmpty is true.

+13 -1

0 comment

2 changed files

pr created time in 16 hours

create barnchopenconfig/ygot

branch : diff-ignore-default-values

created branch time in 17 hours

issue openedopenconfig/ygot

list node contains more than max allowed elements

I have a very simple model like this

grouping e2node-info {
    description
      "The top level container";
    leaf ip {
      type inet:ip-address;
      description
        "The IP address of the node";
    }
    leaf port {
      type inet:port-number;
      description
        "The port of the node";
    }
    leaf plmn-id {
      type string;
      description
        "PLMN id";
    }
    leaf id {
      type string;
      description
        "eNB id";
    }
  }

  container nodes {
    list node {
      key "id";
      uses e2node-info;
      description
        "e2 node";
    }
    description
      "The list of e2 nodes";
  }

but when I try to set a value using gnmi_cli like this

gnmi_cli -address localhost:5150 -set \
    -insecure \
    -proto "update: <path: <elem: <name: 'nodes'> elem: <name: 'node' key:<key:'id' value:'test2'>> elem: <name: 'plmn-id'>> val: <string_val: '123'>>" \
    -timeout 5s -alsologtostderr;;

I am getting the following error:

E1124 12:32:04.065760   17020 gnmi_cli.go:180] target returned RPC error for Set("update:{path:{elem:{name:\"nodes\"} elem:{name:\"node\" key:{key:\"id\" value:\"test2\"}} elem:{name:\"plmn-id\"}} val:{string_val:\"123\"}}") : rpc error: code = Internal desc = error in creating config struct from IETF JSON data: /device/nodes: /device/nodes/node: list node contains more than max allowed elements: 1 > 0

Any ideas why this should happen?

created time in 17 hours

issue commentopenconfig/ygot

ygot.Diff generating gnmi update TypeVal as bool for leaf type yang.Empty

diff --git a/ygot/render_test.go b/ygot/render_test.go
index 3e06ad7..52f0a18 100644
--- a/ygot/render_test.go
+++ b/ygot/render_test.go
@@ -918,8 +918,9 @@ func (*pathElemExample) IsYANGGoStruct() {}
 
 // pathElemExampleChild is an example struct that is used as a list child struct.
 type pathElemExampleChild struct {
-       Val        *string `path:"val|config/val"`
-       OtherField *uint8  `path:"other-field"`
+       Val        *string   `path:"val|config/val"`
+       OtherField *uint8    `path:"other-field"`
+       Empty      YANGEmpty `path:"empty-field"`
 }

Just added the above empty field to pathElemExampleChild, and the Diff tests failed

  1. "add an item to a list"
  2. "remove item from list"
soumiksamanta

comment created time in 18 hours

issue commentopenconfig/ygot

ygot.Diff generating gnmi update TypeVal as bool for leaf type yang.Empty

Reproduced, taking a look.

soumiksamanta

comment created time in 18 hours

pull request commentopenconfig/ygot

Remove yang.Entry Annotation valuePrefix

Coverage Status

Coverage decreased (-0.007%) to 90.609% when pulling e509cb40b6a05d124eca43262a7541b15834be42 on remove-value-prefix into b0419a695df53df4cf269e6f848fcea9b697ccd5 on master.

wenovus

comment created time in a day

push eventopenconfig/ygot

wenovus

commit sha e509cb40b6a05d124eca43262a7541b15834be42

Fix enum YANG tests

view details

push time in a day

PR opened openconfig/ygot

Reviewers
Remove yang.Entry Annotation valuePrefix

Resolves #471. For union enums, the current way to name them in the enums.proto generated file is to use the "valuePrefix" annotation instead of their assigned name from enumgen.go. This is inconsistent with the Go generated code, and I don't see the value of doing it -- there is no added readability benefit, and there is chance for a name conflict either.

The effect of this change is that the generated union enums in enums.proto now follow the generated name given by enumgen.go instead of the path of the union.

  • For typedef enums, this means the name is now deterministic, and not dependent on which was the first path where the typedef was encountered during traversal:
 // OpenconfigRibBgpTestUnionEnumEnum represents an enumerated type generated for the YANG enumerated type union.
 enum OpenconfigRibBgpTestUnionEnumEnum {
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_UNSET = 0;
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_ALPHA = 1 [(yext.yang_name) = "ALPHA"];
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_BRAVO = 2 [(yext.yang_name) = "BRAVO"];
+  OPENCONFIGRIBBGPTESTUNIONENUMENUM_UNSET = 0;
+  OPENCONFIGRIBBGPTESTUNIONENUMENUM_ALPHA = 1 [(yext.yang_name) = "ALPHA"];
+  OPENCONFIGRIBBGPTESTUNIONENUMENUM_BRAVO = 2 [(yext.yang_name) = "BRAVO"];
 }
 // OpenconfigRibBgpBgpRibAfiSafisAfiSafiStateFoo represents an enumerated type generated for the YANG enumerated type union.
 enum OpenconfigRibBgpBgpRibAfiSafisAfiSafiStateFoo {
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_UNSET = 0;
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_ALPHA = 1 [(yext.yang_name) = "ALPHA"];
-  OPENCONFIGRIBBGP_BGPRIB_AFISAFIS_AFISAFI_STATE_FOO_BRAVO = 2 [(yext.yang_name) = "BRAVO"];
+  OPENCONFIGRIBBGPBGPRIBAFISAFISAFISAFISTATEFOO_UNSET = 0;
+  OPENCONFIGRIBBGPBGPRIBAFISAFISAFISAFISTATEFOO_ALPHA = 1 [(yext.yang_name) = "ALPHA"];
+  OPENCONFIGRIBBGPBGPRIBAFISAFISAFISAFISTATEFOO_BRAVO = 2 [(yext.yang_name) = "BRAVO"];
 }

Aside1: If we're to fix the TODO referenced above, the proposal is to remove the unused local enum generated for typedef enums, and remove the unused global (i.e. enums.proto) enum generated for inlined enums.

Aside2: You might have noticed the "EnumEnum" stuttering above. The reason is because an "Enum" suffix is currently given to typedef union enums by enumgen.go. This is inconsistent with inlined union enums where a suffix is not applied. I would be happy to make this consistency change as well, but it would break current users who are using the "-typedef_enum_with_defmod" generation flag.

+1 -13

0 comment

2 changed files

pr created time in a day

create barnchopenconfig/ygot

branch : remove-value-prefix

created branch time in a day

PR closed PencilCode/pencilcode

Removed fs-ext dependency, so now everything builds and runs on vanilla Windows 10 (WSL not required)

Reasons:

1.fs-ext doesn't work on Windows and is no longer necessary (Node7 incorporated needed functionality.) 2. Mimetype detection incorrectly returned "coffeescript" for any file with more than one "."; fixed. 3. "build-debug" target added to grunt to simplify debugging ("uglify" makes this harder than necessary)

+12707 -490

0 comment

61 changed files

doctorjei

pr closed time in a day

more