codeout / junoser

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

"log-out-on-disconnect" makes NoMethodError #1

Closed ghost closed 9 years ago

ghost commented 9 years ago

our EX4300 has below config.

set system ports console log-out-on-disconnect

this error is occur. maybe log-out-on-disconnect is not defined at vsrx.

$ junoser -s configfile
/Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/lib/junoser/transformer.rb:38:in `block in <class:Transformer>': undefined method `gsub' for "log-out-on-disconnect"@25:Parslet::Slice (NoMethodError)
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:216:in `instance_eval'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:216:in `call_on_match'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:234:in `block in transform_elt'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:231:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:231:in `transform_elt'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:184:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:246:in `block in recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `inject'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:187:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `block in recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `map'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:189:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:246:in `block in recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `inject'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:187:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `block in recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `map'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:189:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:246:in `block in recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `inject'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:187:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `block in recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `map'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:253:in `recurse_array'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:189:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:246:in `block in recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `inject'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:245:in `recurse_hash'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/parslet-1.7.0/lib/parslet/transform.rb:187:in `apply'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/lib/junoser/display/structure.rb:20:in `block in transform'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/lib/junoser/display/structure.rb:19:in `each'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/lib/junoser/display/structure.rb:19:in `transform'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/lib/junoser/cli.rb:28:in `struct'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/junoser-0.1.2/exe/junoser:47:in `<top (required)>'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/bin/junoser:23:in `load'
    from /Users/junpei.yoshino/.rbenv/versions/2.1.3/bin/junoser:23:in `<main>'
codeout commented 9 years ago

This is fixed in b6fe86a0990d9f5f25f895da2a44ffd8c26fdd87. Thanks for reporting.

codeout commented 9 years ago

OMG, it's still broken:

$ bundle exec junoser -s configfile
system {
    ports {
        console {
            log-out-on-disconnect;
        }
    }
}

should be

system {
    ports {
        console log-out-on-disconnect;
    }
}
codeout commented 9 years ago

I decided two lines configuration is acceptable.

        console {
            log-out-on-disconnect;
        }

After a quick investigation,

set system ports console log-out-on-disconnect generates:

system {
    ports {
        # one line
        console log-out-on-disconnect;
    }
}

in JUNOS system, but set system ports console log-out-on-disconnect insecure generates:

system {
    ports {
        console {
          # two lines
          log-out-on-disconnect;
          insecure;
        }
    }
}

I'd think that It's too hard to completely emulate this behavior without introducing messy code.

Also, please note that both types of configuration are valid in syntax.