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

cligen parse abnormal #5

Closed
yshchm opened this issue Feb 8, 2018 · 6 comments
Closed

cligen parse abnormal #5

yshchm opened this issue Feb 8, 2018 · 6 comments

Comments

@yshchm
Copy link

yshchm commented Feb 8, 2018

Hi olofhagsand:

I used latest cligen code(2018-01-27 7925db3)with following cli file,

snmp set <$cfg_type%g:string choice:sysname> ,cb();     
                                                    
snmp <$test:string choice:hello>,cb();                  
snmp set <$priv_cfg_type%g:string choice:priv> ,cb();   
                                                    
snmp set <$access_cfg_type%g:string choice:access>,cb();
@yshchm
Copy link
Author

yshchm commented Feb 8, 2018

Hi olofhagsand:
Current abnormal result:

cli> snmp set priv
 CLI syntax error in: "snmp set priv": Unknown command   

@olofhagsand
Copy link
Member

Yes, this is a limitation. I will look into if possible to remedy.
As a workaround you can put the three choice options in a single clause:
<var:string choice:sysname|priv|access>

@yshchm
Copy link
Author

yshchm commented Feb 9, 2018

Thanks for your reply.
Yesterday's configuration was a simplified model,The current real configuration is as follows.

snmp set <$cfg_type%g:string choice:sysname|syscontact|syslocation|rocommunity|rwcommunity> <$val:string> ,cb("$cfg_type","$val");
snmp <$operation%g:string choice:start|restart|stop> ,cb("$operation");                  
snmp set <$priv_cfg_type%g:string choice:priv> <$type:string choice:des|aes> ,cb("$priv_cfg_type","$type"); 
snmp set <$access_cfg_type%g:string choice:access> <$type:string choice:noauth|auth|priv>,cb("$access_cfg_type","$type");

The cligen parser will become normal if I adjust the configuration to following.

snmp set <$cfg_type%g:string choice:sysname|syscontact|syslocation|rocommunity|rwcommunity> <$val:string> ,cb("$cfg_type","$val");
snmp set <$priv_cfg_type%g:string choice:priv> <$type:string choice:des|aes> ,cb("$priv_cfg_type","$type"); 
snmp set <$access_cfg_type%g:string choice:access> <$type:string choice:noauth|auth|priv>,cb("$access_cfg_type","$type");   	  	
snmp <$operation%g:string choice:start|restart|stop> ,cb("$operation");  

I also try the latest release version 3.5.0(2014-12-30 a4c7062),it parses the first configuration normally.

Looking forward to your update.

@olofhagsand
Copy link
Member

Hello,
I have looked into it. I dont think it worked in 3.5.0, are you sure? As far as I see, it does not work in 3.5.0 or 3.6.0 either. I dont think it ever worked.
CLIgen assumes some ordering of the commands, at least on the levels of similar variables (as in this case).
It is possible to change so that it can merge variables also not adjacent as in this example, but it needs some medium-scale rewrite.
For now, can you please work-around by sorting variables that need merging so that they are adjacent?
I will add this in the TODO.

olofhagsand added a commit that referenced this issue Feb 11, 2018
@olofhagsand
Copy link
Member

Looking deeper. Fixed by 0f49462
Thanks for detecting this. Please verify

@yshchm
Copy link
Author

yshchm commented Feb 14, 2018

Thank you for your patch.
I have verified that the problem has been fixed after patching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants