codeout / junoser

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

Unknown statement error #13

Closed bougyman closed 4 years ago

bougyman commented 4 years ago

When trying -d:

 % junoser -d config.txt
Traceback (most recent call last):
        7: from /home/tvanderpoel/.rbenv/versions/2.6.3/bin/junoser:23:in `<main>'
        6: from /home/tvanderpoel/.rbenv/versions/2.6.3/bin/junoser:23:in `load'
        5: from /home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/exe/junoser:46:in `<top (required)>'
        4: from /home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/lib/junoser/cli.rb:21:in `display_set'
        3: from /home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/lib/junoser/display/set.rb:14:in `transform'
        2: from /home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/lib/junoser/display/set.rb:39:in `process'
        1: from /home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/lib/junoser/display/set.rb:39:in `each'
/home/tvanderpoel/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/junoser-0.3.8/lib/junoser/display/set.rb:52:in `block in process': ERROR: unknown statement:  set services nat rule natPF-inside-out-1 term natPF-10001 from source-prefix-list MTA (RuntimeError)
codeout commented 4 years ago

junoser -s translates display-set form into a hierarchical form:

junoser $ junoser -s config.txt
services {
    nat {
        rule natPF-inside-out-1 {
            term natPF-10001 {
                from {
                    source-prefix-list MTA;
                }
            }
        }
    }
}

-d translates reversely:

junoser $ junoser -s config.txt | junoser -d
set services nat rule natPF-inside-out-1 term natPF-10001 from source-prefix-list MTA

I'll implement an appropriate error message shown in that case anyway. Thanks!

bougyman commented 4 years ago

Thanks!