junoser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in junoser.gemspec
4
+ gemspec
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here