Validation of yang bits type space-separated list value

This commit is contained in:
Olof hagsand 2018-06-10 10:41:06 +02:00
parent a576951e57
commit 5e587b3a01
3 changed files with 28 additions and 1 deletions

View file

@ -8,6 +8,7 @@
* Example extended with inclusion of iana-if-type RFC 7224 interface identities
* Applications which have not strictly enforced the identities may now have problems with validation and may need to be modified.
### Minor changes:
* Validation of yang bits type space-separated list value
* Added -U <user> command line to clixon_cli and clixon_netconf for NACM pseudo-user tests
* Added a generated CLI show command that works on the generated parse tree with auto completion.
* A typical call is: show @datamodel:example, cli_show_auto("candidate", "json");

View file

@ -809,6 +809,7 @@ from_client_debug(clicon_handle h,
* has the special value "*".
* @retval 0 No match
* @retval 1 Match
* XXX access_operations is bit-fields
*/
static int
nacm_match_access(char *access_operations,
@ -818,7 +819,7 @@ nacm_match_access(char *access_operations,
return 0;
if (strcmp(access_operations,"*")==0)
return 1;
if (strstr(mode, access_operations)!=NULL)
if (strstr(access_operations, mode)!=NULL)
return 1;
return 0;
}
@ -874,6 +875,7 @@ nacm_match_rule(clicon_handle h,
module_name = xml_find_body(xrule, "module-name");
rpc_name = xml_find_body(xrule, "rpc-name");
/* XXX access_operations can be a set of bits */
access_operations = xml_find_body(xrule, "access-operations");
action = xml_find_body(xrule, "action");
clicon_debug(1, "%s: %s %s %s %s", __FUNCTION__,

View file

@ -122,6 +122,17 @@ module example{
range "min..max";
}
}*/
typedef mybits {
description "Test adding several bits";
type bits {
bit create;
bit read;
bit write;
}
}
leaf mbits{
type mybits;
}
}
EOF
@ -177,6 +188,19 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" "<rpc><commit/></rpc>]]>]]>" "^<r
new "cli enum value"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set status down" 0 "^$"
new "cli bits value"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits create" 0 "^$"
#XXX No, cli cant assign two bit values
#new "cli bits two values"
#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set mbits \"create read\"" 0 "^$"
new "netconf bits two values"
expecteof "$clixon_netconf -qf $cfg -y $fyang" "<rpc><edit-config><target><candidate/></target><config><mbits>create read</mbits></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "cli bits validate"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 "^$"
new "Kill backend"
# Check if still alive
pid=`pgrep clixon_backend`