Coder Social home page Coder Social logo

freeconf / yang Goto Github PK

View Code? Open in Web Editor NEW
38.0 5.0 13.0 2.31 MB

Standards-based management for Golang microservices

License: Apache License 2.0

Go 95.16% Yacc 3.78% HTML 0.69% Lex 0.27% Makefile 0.11%
restconf yang metrics golang go management devops snmp microservice infrastructure

yang's Introduction

FreeCONF

Add support or configuration, metrics, alerts and management functions to your application!

In this repository

  • IETF YANG RFC7950 file parser which can be used to parse YANG files into complete AST without the loss of data including YANG language extensions. See compliance for all supporting RFCs.
  • Core logic to build a management API in Go. You would need to include either FreeCONF's RESTCONF or FreeCONF's gNMI projects to make management API available over a network interface.
  • Management API documentation generator from YANG files

Requirements

Requires Go version 1.20 or greater.

Getting the source

go get -u github.com/freeconf/yang

Resources

yang's People

Contributors

davidmat50 avatar dhubler avatar elvas avatar hrogge avatar kirhchoff avatar oligon-fvs avatar wertasy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yang's Issues

Option to know whether ordered-by is set or not in the yang.

odered-by statements can be present in list and leaf-list.
As of now, i have the option to get the ordered-by value.
But we dont have the option to know whether the ordered-by was present in the list/leaf-list of the loaded yang or not.
Is there any possibility to expose a method IsOrderedBySet() for list and leaf-list?

"Import" of a module is not proper when "include" being done.

After #50 , the normal import of another yang module to a yang module works, but
the importing of the an external module fails when the import is done on a module which was being included. The loading of the yang itself fails

Example below:
loading error was : "module not found imp"

module_core yang:

module module_core {
	
	namespace "urn:params:module_core";
	prefix module_core;
	yang-version 1.1;
	
	include submodule_1;

}	

submodule_1 yang

submodule submodule_1 {

	yang-version 1.1;

	belongs-to "module_core" {
		prefix "module_core";
	}

	import module_for_import {
		prefix imp;
	}

	description
	  "Submodule with container";

	container root-from-submodule1 {
		leaf leaf-A {
			type string;
			default "Success1";
		}
		leaf leaf-B {
			type imp:new-type-from-module;
		}
	}
}	

module_for_import yang:

module module_for_import {

	namespace "urn:params:module_for_import";
	prefix imp;
	yang-version 1.1;

	typedef new-type-from-module {
		description
		  "New type definition";
		type uint16 {
			range "10 .. 2000";
		}
		default 100;
		units parrots;
	}
}

The error is :
module not found imp

Resolving of the "uses" is incorrect when nested "uses" is used in the yang

Problem observed:
when a 'grouping' has "uses" and when that same grouping was attached to a module using another 'uses', then we observe that the incorrect grouping gets attached to the module.

Example yang files used are shown below:
Test-common-module.yang

module Test-common-module {
	yang-version "1.1";
	prefix common1;
	namespace urn:x;

	description
	  "Common types";

	grouping limit {
		leaf rate {
			type uint64;
		}
	}

	grouping profile {
		leaf peak-rate {
			type uint32;
		}

		container profile-limit {
			uses common1:limit;
		}
	}
}

Test-policy.yang:

module Test-policy {
	yang-version 1.1;
	prefix policy;
	namespace urn:x;

	import Test-common-module {
		prefix common1;
	}

	container policy {
		description
		  "Policy rules";
		list rules {
			key "id";
			unique "name";

			leaf id {
				type string{
					length "5..36";
				}
			}

			leaf name {
				type string {
					length "5..255";
				}
			}

			container a-profile {
				uses common1:profile;
				leaf traffic-type {
					type string;
				}
			}
		}
	}
}

Now when we load the Test-policy module, the loading is successs, but while resolving the "uses common1:limit" in Test-common-module, the datadefinitions for "grouping profile" gets attached instead of attaching datadefinitions for "grouping limit" .

This is resulting in "grouping profile " getting attached unlimited times recursilvely .Due to this while iterating through the datadefinitions of "a-profile" , it results in unlimited iterations counts of 'peak-rate' and 'profile-limit' recursively

Please fix.

Please note: such issues are not seen when only one direct "uses" is resolved. mainly seen when nested "uses" is present in yang.

Single quotes from "when" and "must" expression is missing after yang parsing and loading.

If a when expression is ending with single quotes ' , then the .When().Expression() method is not returning the complete when condition including the single qutoes.
eg: If the when expression is "class != 'wheel'", then the Expression() method just returns "class != 'wheel" - the single quotes after wheel is missing.

Yang file used to test:

module basic_when {

	namespace "urn:params:basic_when";
	prefix basic_when;

	container root-container {
		leaf leaf-root {
			type enumeration {
				enum "one";
				enum "two";
				enum "three";
			}
		}
		container container-condition {
			leaf leaf-nested {
				type boolean;
			}
		}
		leaf leaf-root-when {
			when "../leaf-root = 'one'";
			type int8;
		}
		leaf-list leaf-list-root-when {
			when "../leaf-root = 'two'";
			type int8;
		}
		container container-leafs {
			leaf leaf-nested-when {
				when "../../container-condition/leaf-nested = 'true'";
				type int8;
			}
			leaf-list leaf-list-nested-when {
				when "../../container-condition/leaf-nested = 'false'";
				type int8;
			}
		}
		container container-when {
			when "../leaf-root = 'two'";
			leaf leaf-A {
				type string;
			}
		}
		list list-when {
			when "../leaf-root = 'three'";
			leaf leaf-B {
				type string;
			}
		}
	}
}

The same issue exists for must expression also.

Yang loading fails when range added for decimal64 type.

when range is added for decimal64 type without spaces before the two dots, then the yang loading fails. But as per the RFC 7950, ranges can exist without spaces before/after the two dots.

range "-9999.9999..9999.9999"; -> Yang loading failed.
range "-9999.9999 .. 9999.9999"; -> yang loading passed.

The failed yang file:

module decimalTypeTest {
	namespace urn:x;
	prefix x;
	revision 2023-01-01;
	leaf leaf-d {
		description
		  "Leaf-d with decimal64";
		type decimal64 {
			fraction-digits 4;
			range "-9999.9999..9999.9999";
		}
	}
}

The succesfully loaded yang:

module decimalTypeTest {
	namespace urn:x;
	prefix x;
	revision 2023-01-01;
	leaf leaf-d {
		description
		  "Leaf-d with decimal64";
		type decimal64 {
			fraction-digits 4;
			range "-9999.9999 .. 9999.9999";
		}
	}
}

API: RPC resources located under /restconf/data rather than /restconf/operation

Please correct me if I'm wrong, but the RESTCONF specification seems to require RPC sections of the yang model be accessible under POST {+restconf}/operations/<operation> (see section-3.6).

However in the car example (https://github.com/freeconf/examples/tree/master/car) RPC's are accessed under restconf/data. An example of this being starting the car, which is done using curl -XPOST http://localhost:8080/restconf/data/car:start.

Is there a reason FreeCONF does this? If so is there anywhere I can query what operations are supported and what arguments each argument take?

Adding a custom object type into yang

Is there a good place to look when I want to hook a custom type into the yang code? I have quite a bit of datastructures that use netip.Addr and netip.Prefix, both can be easily converted from/to string.

I saw the most recent commit 2aee1f9 , but af68a4c looks also to be interesting/important.

yang loading failing for 'anydata' statement, if any of its susbstatments coexist with 'descrition' substatement

Refer to below exmaple:
If only 'description' susbstatment present under anydata, yang loading is succesfull
if only 'when' substatment is present under anydata, yang loading is succesful.
if both 'description' and 'when' substatements are present under anydata, then yang loading is failing.
No other substatements are being able to be co-exist alomg with 'description'

module anydataTest {
	namespace urn:x;
	prefix x;
	revision 2023-01-01;
	leaf leaf-node {
		type string;
	}
	container Test {
		anydata dump {
			when "../../leaf-node";               
			description "Dump data";  
		}
	}
}

Yang loading fails if 'default' substatement is present under 'choice' statement

Yang loading fails if 'default' substatement is present under 'choice' statement.

https://www.rfc-editor.org/rfc/rfc7950#section-7.9.3
As per RFC 7950, default statement should be supported for choice

Yang model used for testing is below.

module choice-default-test {
	namespace urn:x;
	prefix x;
	container transfer {
		choice how {
			default interval;
			case interval {
				leaf interval {
					type uint16;
				}
			}
			case daily {
				leaf daily {
					type empty;
				}
			}
			case manual {
				leaf manual {
					type empty;
				}
			}
		}
	}
}

Support for metadata handling?

Hi, it is a little bit difficult to find out what RFCs and features freeconf does support or not.

Does it support metadata (rfc7952) and/or XML (RFC 8040) encoding?

Multiple 'default' subsatements for leaf-list

As per RFC7950 , a leaf-list can have more than one (0..n) 'default' substatements
( if 'min-elements' with values 1 or more is not present in the leaf-list)

The freeconf/yang library provides a method Default() for leaf, leaflist etc..
But as lieaf-list can have (0..n) deafults, is there any possibility of providing an additional method to get mutiple default values for leaf-list case??
something like -> func (m *LeafList) Defaults() []interface{} ??????

freeconf/yang library crashing while loading a yang file with leafref value as an invalid path.

There was an invalid path used for leafref. Then the freeconf/yang library crashed.
It should be better to retun an error in such cases.

goroutine 1 [running]:
github.com/freeconf/yang/meta.Find({0x1108010, 0xc0004a35e0}, {0xc000278c95, 0x4})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/find.go:33 +0x328
github.com/freeconf/yang/meta.Find({0x1108010, 0xc0004a35e0}, {0xc000278c95, 0x1c})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/find.go:13 +0x113
github.com/freeconf/yang/meta.(*compiler).compileType(0xc0004a3500?, 0xc0000763c0, {0x26a274955d8?, 0xc0004a35e0})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:264 +0x20d       
github.com/freeconf/yang/meta.(*compiler).compile(0xc0004d25a0?, {0x1066220?, 0xc0004a35e0?})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:79 +0x15f        
github.com/freeconf/yang/meta.(*compiler).compile(0x1108eb0?, {0x106a8a0?, 0xc0004d25a0?})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:132 +0x585       
github.com/freeconf/yang/meta.(*compiler).compile(0xc0001b4510?, {0x106abc0?, 0xc000002000?})
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:132 +0x585       
github.com/freeconf/yang/meta.(*compiler).module(0x10?, 0xc000002000)
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:52 +0x206        
github.com/freeconf/yang/meta.Compile(0xc000002000)
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/meta/compile.go:21 +0x4a
github.com/freeconf/yang/parser.LoadModuleWithOptions(0xc0004c58c0, {0xc0000161e0, 0x14}, {{0x0?, 0x0?}, {0x0?, 0xc00051dc60?}})  
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/parser/loader.go:72 +0x1fd       
github.com/freeconf/yang/parser.LoadModule(...)
		C:/Users/dama0416/go/pkg/mod/github.com/freeconf/[email protected]/parser/loader.go:16
e2eso-json-schema-generator/generator/yangparser.(*YangParser).ParseAndGenerateJsonSchema(0xc00051dcc0)
		C:/MYDATA/ESO/WORK/e2eso-json-schema-generator/e2eso-json-schema-generator/generator/yangparser/parser.go:34 +0x5f        
e2eso-json-schema-generator/generator/yangparser.ConvertYangFilesToJsonSchema({0x1108a78, 0xc0001b4390}, {0xc0000a01fa?, 0x1104880?}, {0xc0000161e0, 0x14}, {0xc00051de08, 0x2}, 0x8?)
		C:/MYDATA/ESO/WORK/e2eso-json-schema-generator/e2eso-json-schema-generator/generator/yangparser/parser.go:282 +0xde       
main.main()
		C:/MYDATA/ESO/WORK/e2eso-json-schema-generator/e2eso-json-schema-generator/main.go:92 +0x686

File used:

module leafref-invalid-path {
	namespace urn:x;
	prefix x;
	revision 2023-01-01;

	container logical-switch {
		description
		  "Logical switch parameters";

		leaf server {
			type leafref {
				path "abcd/../../syslog-servers/id";
			}
			description
			  "The reference to SDX - SYSLOG server";
		}
		
	}

	list syslog-servers {
		key "id";

		leaf id {
			type uint32;
			description
			  "The unique ID of SYSLOG server.";
		}

		leaf name {
			type string;
			description
			  "The unique name of SYSLOG server.";
		}

		leaf transport-protocol {
			type enumeration {
				enum "udp";
				enum "tcp";
			}
			default "udp";

			description
			  "Transport protocol type used for connection towards SYSLOG server.";
		}

		leaf port {
			type uint16;
			default 514;

			description
			  "Port used for connection towards SYSLOG server.";
		}
		description
		  "Syslog servers that can be referenced for the syslog configuration under switch templates.";
	}
}

Docs - show which items are part of a choice

If we use a choice between N items, all N items show as children but it's unclear they are grouped together in a "only one of" situation. This applies for all doc forms : html/markdown/diagrams.

YANG 1.1 - support optional "case" statements

really useful feature of 1.1 is to not require case when there's only one item in it

Example:

 choice x {
  case y1 {
    leaf z1..
  }
  case y2 {
    leaf z2..
  }
}

can be just:

 choice x {
    leaf z1..
    leaf z2..
}

'uses' substatement under augment does not replace the grouping as expected.

In normal cases, if 'uses" is used , the entire data definitions inside the grouping referred by the referred 'uses' keyword is being replaced in the data tree.
'Augment' also replaces the augmented data plus any additional data nodes kept under augment.

But if 'uses' is used under augment, then the data refreed by the grouping is not seen as additional data under augment.
AS per RFC 7950, 'uses' should be supported as a substatment for 'augment'

Example file:

module aug-with-uses-basic {
	yang-version "1.1";
	revision 2020-02-04 {
		description
		  "initial draft";
	}

	leaf test {
		type int8;
	}

	container system {
		leaf host-name {
		   type string;
		   description
			 "Hostname for this system.";
		}

		leaf-list domain-search {
		   type string;
		   description
			 "List of domain names to search.";
		}

		container login {
			leaf message {
			type string;
			 description
			   "Message given at start of login session.";
			}
			
			list user {
				key "name";
				leaf name {
					type string;
				}
				leaf full-name {
					type string;
				}
				leaf class {
					type string;
				}
			}
		}
	}

	grouping target {
	   leaf port {
		 type port-number;
		  description "Target port number.";
	   }
	 }

	typedef port-number {
		type uint16 {
		range "0..65535";
		}
	}
  

	augment /system/login/user {
	   uses target;
	 }
}

Tail-f’s ConfD

Do you have support for Tail-f’s ConfD management agent software framework ?

loading fails if double quotes used after identity-base and identityref-base

In the exmaple given in RFC 7950 sections https://www.rfc-editor.org/rfc/rfc7950.html#section-7.18.3 and https://www.rfc-editor.org/rfc/rfc7950.html#section-9.10.5 , double quotes were after the base statement.
But if i try the same, the yang loading fails. However, if we remove the double quotes, the yang file laoding is succsessful.
Please check and make it to be in sync with RFC.

Exmaple file:

identity1.yang

module identity1 {
   yang-version 1.1;
   namespace "urn:example:my-crypto";
   prefix mc;

   import example-crypto-base {
     prefix "crypto";
   }

   identity aes {
     base "crypto:crypto-alg";
   }

   leaf crypto {
     type identityref {
       base "crypto:crypto-alg";
     }
   }
 }

example-crypto-base.yang

module example-crypto-base {
	   yang-version 1.1;
	   namespace "urn:example:crypto-base";
	   prefix "crypto";

	   identity crypto-alg {
		 description
		   "Base identity from which all crypto algorithms
			are derived.";
	   }

	   identity symmetric-key {
		 description
		   "Base identity used to identify symmetric-key crypto
			algorithms.";
		 }

	   identity public-key {
		 description
		   "Base identity used to identify public-key crypto
			algorithms.";
		 }
	 }

Module description is not as expected if submodules are included.

If we include submodules into the main yang module, the main module description fecthed using Description() method is returning the description of the last included submodule. I was expecting the description of the main module itself as returned value.

Example:
Main module (module_core.yang):

module module_core {

	namespace "urn:params:module_core";
	prefix module_core;
	yang-version 1.1;

	include submodule_1;
	include submodule_2;
	description
	  "This is main module core";

	container testing {
		description
		  "testing container in main module";
		leaf cont1 {
			type string;
		}
		leaf cont2 {
			type int32;
		}
	}
}		

Submodule 1 submodule_1.yang:

submodule submodule_1 {

	yang-version 1.1;

	belongs-to "module_core" {
		prefix "module_core";
	}
	description
	  "Submodule-1 with list";

	list root-list-submodule1 {
		leaf leaf-A {
			type string;
			default "Success";
		}
		leaf leaf-B {
			type new-type-submodule2;
		}
		uses the_only_group;
	}

	grouping the_only_group {
		leaf leaf-from-group {
			type new-type-submodule2;
		}
		leaf-list leaf-list-from-group {
			type string;
			default "ok";
		}
	}
}		

submodule 2 submodule_2.yang:

submodule submodule_2 {

	yang-version 1.1;

	belongs-to "module_core" {
		prefix "module_core";
	}
	description
	  "Submodule-2 with typedef";

	typedef new-type-submodule2 {
		description
		  "New type definition";
		type uint16 {
			range "10 .. 2000";
		}
		default 100;
		units parrots;
	}
}		

In the above example, after loading module_core, i was expecting module.Description() to return "This is main module core" , but instead , it is returning "Submodule-2 with typedef"

Issue in referencing definitions from the same module when using submodules.

Prior to #50, the yang files mentioned below were getting loaded succesfuly without any errors. But after #50, the following error is thrown.

module_core/submodule_1/root-list-submodule1/leaf-B - typedef new-type-submodule2 not found

As per RFC7950 section , When an external module referece from an imported module is used, then we must use prefix followed by ":" , BUT If there are references to definitions in the same local module or submodules , then it is not mandatory that we use prefix followed by ": " to refer to local referecnes within the module of submodule. We MAY or MAY NOT use ":" . So, in case of included submodules, we should support referencing in both ways by a) by using ";" and b) without using ":'

image

Previous to #50, we were able to load below yang files succesfully. Is it possible to maintain the same behaviour now too?

module_core.yang

module module_core {
	
	namespace "urn:netcracker:params:module_core";
	prefix module_core;
	yang-version 1.1;
	description "This is main Module";
	
	include submodule_1;
	include submodule_2;

}		

submodule1.yang

submodule submodule_1 {
	
	yang-version 1.1;
	description "Submodule-1 with list";
	belongs-to "module_core" {
		prefix "module_core";
	}
	
	list root-list-submodule1 {
		leaf leaf-A {
			type string;
			default "Success";
		}
		leaf leaf-B {
			type new-type-submodule2;
		}
		uses the_only_group; 
	}
	
	grouping the_only_group {
		leaf leaf-from-group {
			type new-type-submodule2;
		}
		leaf-list leaf-list-from-group {
			type string;
			default "ok";
		}
	}
}		

submodule2.yang

submodule submodule_2 {
	
	yang-version 1.1;
	description "Submodule-2 with typedef";
	belongs-to "module_core" {
		prefix "module_core";
	}

	typedef new-type-submodule2 {
		description "New type definition";
		type uint16 {
			range "10 .. 2000";
		}
		default 100;
		units parrots;
	}
}

Yang loading fails if 'mandatory' substatement is present under 'choice' statement

Yang loading fails if 'mandatory' substatement is present under 'choice' statement.

https://www.rfc-editor.org/rfc/rfc7950#section-7.9.4
As per RFC 7950, mandatory statement should be supported for choice

Yang model used for testing is below.

module choice-mandatory-test {
namespace urn:x;
prefix x;
container transfer {
    choice how {
        mandatory true;
        case interval {
            leaf interval {
                type uint16;
            }
        }
        case daily {
            leaf daily {
                type empty;
            }
        }
        case manual {
            leaf manual {
                type empty;
            }
        }
    }
}

Renaming of struct fields doesn't apply during replace operation?

I noticed that a PUT (replace) operation doesn't run through the reflect.Child() code when looking for the relevant data for the JsonContainerReader.

The relevant code is json_rdr.go fqkGet() line 105/108, which does only test "name" and "mod.Ident():name"... Is there something that I am missing from the big picture as a reason why we don't end back in the reflect-code, where we call GetFieldName()?

Error while building yang/nodeutil

I just get the latest restconf and freeconf and I get an error while building yang/nodeutil.

/go/pkg/mod/github.com/freeconf/[email protected]/nodeutil/reflect.go:470:14: childVal.SetZero undefined (type reflect.Value has no field or method SetZero)

NodeRequest should have Delete boolean

When calling EndEdit, the NodeRequest struct has a New boolean, but not Delete boolean. There are 3 states: New, Update and Delete. I cannot distinguish between Update and Delete,

As a workaround, I can set a flag when getting the Delete function call

Augmented data is missing in data definition

After the fix #55 , it looks like augmented data is missing in the data definitions of the module.

Example,
aug-main.yang

module aug-main {
	yang-version "1.1";
	namespace "urn:params:custom";
	prefix custom;

	import aug-common {
		prefix common;
		revision-date 2020-02-04;
	}

	description
	  "Augment tes main file";

	revision 2020-02-04 {
		description
		  "initial draft";s
	}

	leaf test {
		type int8;
	}

	augment "/common:interfaces/common:ifEntry" {
		when "common:ifIndex = 1";
		leaf ds0ChannelNumber {
			type uint8;
		}
	}
}

aug-common.yang

module aug-common {
	yang-version "1.1";
	namespace "urn:params:common";
	prefix common;

	description
	  "Augment common test file";
	revision 2020-02-04 {
		description
		  "initial draft";
	}

	container interfaces {
		list ifEntry {
			key "ifIndex";
			
			leaf ifIndex {
				type uint32;
			}
			leaf ifDescr {
				type string;
			}
			leaf ifMtu {
				type int32;
			}
		}
		container something {
			leaf a1 {
				type int8;
			}
		}
	}
}

In the above exmaple, i was expecting the data definition in module structure would be having ifEntry, which is the augmented data, but it was missing

Config set to false, but does not take complete effect

As per https://www.rfc-editor.org/rfc/rfc7950.html#section-7.21.1
If a node has "config" set to "false", no node underneath it can have
"config" set to "true".

Currently
Config() method is returning true if no config is mentioned for the data node - This is OK.
Config() method is returning false for the node if any of parent/grand parents is marked with config as "false" - This is OK.
Config() method is returning true if a node is marked config=true and any of its parent or grand parent nodes is marked false. - This is not OK.

As per RFC, If a node has "config" set to "false", no node underneath it can have config set to true. In such cases i feel the yang loader should throw error as it is invalid yang.

eg files:

module container-config {
	namespace urn:x;
	prefix x;
	revision 2020-01-01;
	leaf dummy {
		type uint16;
	}
	container car {
		description "This is the description of container";
		config false;
		leaf name {
			type string;
			mandatory true;
		}
		leaf year {
			type string;
			mandatory true;
		}
		leaf color {
			type string;
		}
		list engine {
			config true;
			leaf horse-power {
				type uint16;
			}
			leaf-list seat-type {
				type string;
			}
		}
	}
}

In this exmaple car's config was false. but engin's config was marked as "true" which is against the rules. But yang loading was succesful and config() method for engine returned true.

Issue in fetching 'unique' for list

Yang file with a 'list' statement and 'unique' susbstatement was laoded succesfully. But the method to fetch the unique() info was NOT returning any valid values.

func (m *List) Unique() [][]string

Tested yang: listUniqueTest

module listUniqueTest {
	namespace urn:x;
	prefix x;
	revision 2023-01-01;
	list user {
		//key "name employee-id";
		unique "employee-id full-name";
		leaf name {
			type string;
		}
		leaf employee-id {
			type uint32;
		}
		leaf full-name {
			type string;
		}
		leaf class {
			type string;
			mandatory true;
		}
		description "Employee Information";
	}
}

case substatemnt not supported for augment

Two isses seen

  1. Not able to add augment's target location as a choice.
  2. Not able to add case substatment under augment- But RFC950 supports it.

exmple files:

file used to load: aug-common-includes.yang

module aug-common-includes {
	yang-version "1.1";
	namespace "urn:params:common";
	
	include aug-common-sub;
	include aug-main-sub;
}

aug-main-sub.yang

submodule aug-main-sub {
	yang-version "1.1"; 
	namespace "urn:params:custom";

	belongs-to "common-includes" {
		prefix "common-includes";
	}
	prefix custom;

	leaf test {
		type int8;
	}

	augment "/modification/mod-info/mod-choice" {
		case null-handle {
			leaf null-handle {
			   type empty;
			   description
				  "null-handle";
			}
		 }
	}
}

aug-common-sub.yang

submodule aug-common-sub {
	yang-version "1.1";
	namespace "urn:params:common";
	prefix common;


	belongs-to "common-includes" {
		prefix "common-includes";
	}

	container modification {
		container mod-info {
			leaf a1 {
				type int8;
			}

			choice mod-choice {
				description "mod-choice";
				case wildcard {
					leaf wildcard {
						type empty;
						description
							"wildcard";
					}
				}

				case stream-handle {
					leaf stream-handle {
						type empty;
						description
							"stream-handle";
					}
				}
			}
		}
	}
}

JSON namespace-qualified names not supported

Hi, I'm experimenting with these nice libraries by writing a prototype restconf server for some custom yang models.

It works fine except when my querie contains namespace prefixes. Looking at the yang library, it seems that namespaces are not supported... Except for a compatibility mode used in the JSON writer but not when parsing JSON body queries.

Is this correct or am I missing something somewhere?

Thx

make Delete handing easier

currently you have to implement OnEvent and catch DELETE. In addition, you have to make a redundant switch case for container/list name. Instead, if ContainerRequest and ListRequest had Delete flag, it would be a lot easier to implement

Locking data structures for read access

How is the "standard" way to lock data structures for read access. As far as I can see we have BeginEdit() and EndEdit() to lock a write access, but this doesn't help with reading.

An alternative would be a transfer of all restconf operations to a go-routine of the users choice.

Trouble with UnionList format

I have a slice of IP addresses in one of my yang models, based on the IETF IP definition (which is a union of an IPv4 and an IPv6 pattern). Could it be that the UnionList handling is missing in the node/value.go NewNode() function?

Yang loading is failing if default substatement is added for leaf of type enum where enum name starts as a number.

Not able to add default substatment in leaf if the enum looks like below.
(please note the enum name startes with number)

leaf mybytes {
    type enumeration {
        enum 4k;
        enum 8k {
            value 8192;
        }
        enum 12k {
            value 12288;
        }
        enum 16k {
            value 16384;
        }
    }
    default 16k;
 }

But the yang loading is working fine(below) when default substatment is added with similar enum where enum name does not start as number digits.

leaf myenum {
    type enumeration {
        enum zero;
        enum one;
        enum two {
            value 2;
        }
        enum seven {
            value 7;
        }
        enum eight {
            value 8;
        }
    }
    default seven;
}

Yang used for testing:

module enum-default-test {
namespace urn:x;
prefix x;
leaf myenum {
    type enumeration {
        enum zero;
        enum one;
        enum two {
            value 2;
        }
        enum seven {
            value 7;
        }
        enum eight {
            value 8;
        }
    }
    default seven;
}
leaf mybytes {
    type enumeration {
        enum 4k;
        enum 8k {
            value 8192;
        }
        enum 12k {
            value 12288;
        }
        enum 16k {
            value 16384;
        }
    }
    default 16k;
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.