junoser 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +37 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/vsrx-12.1.x47.rb +38421 -0
- data/exe/junoser +51 -0
- data/junoser.gemspec +27 -0
- data/lib/junoser/cli.rb +55 -0
- data/lib/junoser/development.rb +2 -0
- data/lib/junoser/display/base.rb +40 -0
- data/lib/junoser/display/config_store.rb +52 -0
- data/lib/junoser/display/set.rb +82 -0
- data/lib/junoser/display/structure.rb +29 -0
- data/lib/junoser/display.rb +16 -0
- data/lib/junoser/parser.rb +38453 -0
- data/lib/junoser/ruler.rb +173 -0
- data/lib/junoser/transformer.rb +41 -0
- data/lib/junoser/version.rb +3 -0
- data/lib/junoser/xsd/base.rb +54 -0
- data/lib/junoser/xsd/choice.rb +33 -0
- data/lib/junoser/xsd/complex_type.rb +74 -0
- data/lib/junoser/xsd/element.rb +100 -0
- data/lib/junoser/xsd/enumeration.rb +30 -0
- data/lib/junoser/xsd/parsable.rb +33 -0
- data/lib/junoser/xsd/restriction.rb +34 -0
- data/lib/junoser/xsd/sequence.rb +39 -0
- data/lib/junoser/xsd/simple_content.rb +31 -0
- data/lib/junoser.rb +3 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04241a9dee01f2996227ba94241a5d072b5c8968
|
4
|
+
data.tar.gz: a1c7851253a38cb45aec788d987a166cf64c0c90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9145301bba9640fc462b7ee7136af70730f77f7cd8b056b468b5ad66eef1e841b67b05ba170e5b27c3b41008859f1c8bc04f1c815a4d2e7cb9f12cd19c18ce72
|
7
|
+
data.tar.gz: dab4dc7ce5b7d618c4555425215c4e3c2120db84958b36d9d64669e8f2ba64a510df2bf7de620c5b926c9c70ed897b61828658c76f8a576f8b7fd6ee8f78877d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Shintaro Kojima
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Junoser
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
Junoser is a JUNOS configuration PEG parser which can be automatically generated from Juniper's netconf.xsd. (XML Schema Definition for NETCONF)
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
* Configuration Validation
|
10
|
+
* Structured "show configuration" format
|
11
|
+
* One-liner "| display set" format
|
12
|
+
|
13
|
+
* Configuration Translation
|
14
|
+
* Inter-translation between structured form and display-set form
|
15
|
+
|
16
|
+
**NOTE**
|
17
|
+
|
18
|
+
Inter-translation from display-set form into structured form is experimental feature in this release.
|
19
|
+
|
20
|
+
|
21
|
+
## Getting Started
|
22
|
+
|
23
|
+
```zsh
|
24
|
+
$ gem install junoser
|
25
|
+
```
|
26
|
+
|
27
|
+
### Usage
|
28
|
+
|
29
|
+
To verify configurations syntax:
|
30
|
+
|
31
|
+
```zsh
|
32
|
+
$ junoser -c config.txt
|
33
|
+
$ cat config.txt | junoser -c
|
34
|
+
```
|
35
|
+
|
36
|
+
or
|
37
|
+
|
38
|
+
```zsh
|
39
|
+
$ cat config.txt | junoser -c
|
40
|
+
```
|
41
|
+
|
42
|
+
To translate configuration into "display set" form:
|
43
|
+
|
44
|
+
```zsh
|
45
|
+
$ /exe/junoser -d config.txt
|
46
|
+
set protocols bgp group ebgp-peers neighbor 192.0.2.2
|
47
|
+
```
|
48
|
+
|
49
|
+
or
|
50
|
+
|
51
|
+
```zsh
|
52
|
+
$ cat config.txt | junoser -d
|
53
|
+
set protocols bgp group ebgp-peers neighbor 192.0.2.2
|
54
|
+
```
|
55
|
+
|
56
|
+
Use ```junoser -s``` to translate into structured form.
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Please report issues or enhancement requests to [GitHub issues](https://github.com/codeout/junoser/issues).
|
62
|
+
For questions or feedbacks write to my twitter @codeout.
|
63
|
+
|
64
|
+
Or send a pull request to fix.
|
65
|
+
|
66
|
+
|
67
|
+
## Copyright and License
|
68
|
+
|
69
|
+
Copyright (c) 2015 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'junoser/development'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
xsd_path = File.expand_path('../tmp/junos-system.xsd', Pathname.new(__FILE__).realpath)
|
7
|
+
rule_path = File.expand_path('../tmp/rule.rb', Pathname.new(__FILE__).realpath)
|
8
|
+
parser_path = File.expand_path('../lib/junoser/parser.rb', Pathname.new(__FILE__).realpath)
|
9
|
+
|
10
|
+
def open_files(input, output, &block)
|
11
|
+
i = open(input)
|
12
|
+
o = open(output, 'w')
|
13
|
+
|
14
|
+
yield i, o
|
15
|
+
|
16
|
+
i.close
|
17
|
+
o.close
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
namespace :build do
|
22
|
+
desc 'Build an intermediate config hierarchy'
|
23
|
+
task(:config) do
|
24
|
+
open_files(xsd_path, rule_path) do |input, output|
|
25
|
+
Nokogiri::XML(input).root.remove_unused.xpath('/xsd:schema/*').each do |e|
|
26
|
+
output.puts e.to_config
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Build the parser'
|
32
|
+
task(:rule) do
|
33
|
+
open_files(rule_path, parser_path) do |input, output|
|
34
|
+
output.puts Junoser::Ruler.new(input).to_rule
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "junoser"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|