codeout / junoser

PEG parser for JUNOS configuration.
MIT License
69 stars 11 forks source link

groups in 'set' notation are not translated to 'structured' config #12

Closed MicLennartz closed 5 years ago

MicLennartz commented 5 years ago

I would like to use/support this project and came across a significant problem. Configurations in 'set' notations, using groups, are not properly translated to structured config:

echo "set groups VPN01894 snmp location 'room1'" | junoser -s
groups {
    VPN01894 snmp location 'room1';
}

Any help or hint around that would be very appreciated. //Michael

codeout commented 5 years ago

Thanks for your report. It's known behavior.

We need special treatment for groups statement, eg a recursive translation in each groups with assuming that hierarchy as the root, but it's not supported yet.

Let me take a look anyways.

codeout commented 5 years ago

Hi @MicLennartz,

I've released v0.3.6 with groups statement support, I hope it also works for you.

$ echo "set groups VPN01894 snmp location 'room1'" | junoser -s
groups VPN01894 {
    snmp {
        location 'room1';
    }
}

$ junoser -v
0.3.6
MicLennartz commented 5 years ago

Hi @codeout , the new version looks very promising. Even with very complex config with and without groups it seem to be working well.

The only issue I found is, that 'set apply-groups ..." is not parsed and raises an exemption. But I guess, this is easy to fix.

codeout commented 5 years ago

Thanks, I'm done fixing it. Could you double-check my code can parse your config before releasing the new version if you have time?

git clone https://github.com/codeout/junoser.git -b apply-groups
cd junoser

echo "set apply-groups foo" | ruby -I lib exe/junoser -s
# or
ruby -I lib exe/junoser -s your_config_file
MicLennartz commented 5 years ago

I've tested your new code and it seems like it can convert even very complex JunOS code now, in both directions. Good work!

codeout commented 5 years ago

Just released v0.3.7 with the new code 🚀 Thank you for your testing!