junoser 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +6 -6
- data/Rakefile +1 -1
- data/lib/junoser/js_ruler.rb +44 -24
- data/lib/junoser/parser.rb +14294 -8372
- data/lib/junoser/ruler.rb +23 -1
- data/lib/junoser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d373ec94d7ebe3053b4f01d01d54beb15b49af4e2e8fbab4b29f9641632b5715
|
4
|
+
data.tar.gz: 046c510a4c5072759810abd68c8df4ce25c7cab976806182cdf0020dbd5b3f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8acdf3b078ddc961ba28f3be6f9c2b3870b2f3ee85a81b7bec28fee09a390709e0783e520c67ef3b30fe87b15a317d7dcb879bdadd3d3b3d3d101a3fdb05c32
|
7
|
+
data.tar.gz: 9f4ff9fda7f65b1a318dcd43858874e7823e0008028071a0a2b20c951cdbdf04b6665e521044a572fd46f34626a345d543f2df9366524f55d07cf99dbfb55064
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
junoser (0.
|
4
|
+
junoser (0.7.0)
|
5
5
|
parslet
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
mini_portile2 (2.8.
|
11
|
-
nokogiri (1.
|
10
|
+
mini_portile2 (2.8.8)
|
11
|
+
nokogiri (1.17.2)
|
12
12
|
mini_portile2 (~> 2.8.2)
|
13
13
|
racc (~> 1.4)
|
14
14
|
parslet (2.0.0)
|
15
|
-
power_assert (2.0.
|
15
|
+
power_assert (2.0.4)
|
16
16
|
racc (1.8.1)
|
17
17
|
rake (13.2.1)
|
18
|
-
test-unit (3.6.
|
18
|
+
test-unit (3.6.7)
|
19
19
|
power_assert
|
20
20
|
|
21
21
|
PLATFORMS
|
@@ -29,4 +29,4 @@ DEPENDENCIES
|
|
29
29
|
test-unit
|
30
30
|
|
31
31
|
BUNDLED WITH
|
32
|
-
2.5.
|
32
|
+
2.5.16
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'nokogiri'
|
|
4
4
|
require 'pathname'
|
5
5
|
require 'rake/testtask'
|
6
6
|
|
7
|
-
xsd_path = File.join(__dir__, 'tmp/junos-system-
|
7
|
+
xsd_path = File.join(__dir__, 'tmp/junos-system-22.4.xsd')
|
8
8
|
rule_path = File.join(__dir__, 'tmp/rule.rb')
|
9
9
|
ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
|
10
10
|
js_parser_path = File.join(__dir__, 'tmp/junos.js')
|
data/lib/junoser/js_ruler.rb
CHANGED
@@ -25,6 +25,50 @@ module Junoser
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
def process_lines(str)
|
29
|
+
# set groups
|
30
|
+
str.gsub! /"groups" \(.*\s*s\(\s*any\s*\)\s*\)/, <<-EOS.strip
|
31
|
+
"groups" arg ( /* Configuration groups */
|
32
|
+
"when" ( /* Specify additional conditions for groups */
|
33
|
+
c(
|
34
|
+
"chassis" arg /* Chassis id */,
|
35
|
+
"member" arg /* Member of virtual chassis */,
|
36
|
+
"model" arg /* Model name */,
|
37
|
+
"node" arg /* Node of cluster */,
|
38
|
+
"peers" arg /* Hosts on which this group should be effective */,
|
39
|
+
"routing-engine" arg /* Routing Engine */,
|
40
|
+
"time" ( /* Time at which group should be effective */
|
41
|
+
"to" arg /* End time([yyyy-mm-dd.]hh:mm) */,
|
42
|
+
arg
|
43
|
+
)
|
44
|
+
)
|
45
|
+
)
|
46
|
+
)
|
47
|
+
EOS
|
48
|
+
|
49
|
+
# set protocols mpls path
|
50
|
+
str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
|
51
|
+
"#{$1}#{$2}s(#{$2}ipaddr,"
|
52
|
+
end
|
53
|
+
|
54
|
+
# set protocols iccp peer xxx liveness-detection single-hop
|
55
|
+
str.gsub!(/(^rule\(:peer_group\) do.*?\n(\s*)"detection-time" \(.*?c\(\s*"threshold" arg .*?\)\s*\))/m) do
|
56
|
+
"#{$1},\n#{format('"single-hop"', $2)}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# set forwarding-options dhcp-relay server-group
|
60
|
+
str.gsub!(/^(rule\(:(?:v6_)?server_group_type\) do)\n(.*?)\nend/m) do
|
61
|
+
"#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
|
62
|
+
end
|
63
|
+
|
64
|
+
# set interfaces xxx enable
|
65
|
+
str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
|
66
|
+
%[#{$1}#{$2}"enable",#{$2}]
|
67
|
+
end
|
68
|
+
|
69
|
+
str
|
70
|
+
end
|
71
|
+
|
28
72
|
def process_line(str)
|
29
73
|
str = remove_undefined_variables(str)
|
30
74
|
str = process_common_syntax(str)
|
@@ -210,30 +254,6 @@ module Junoser
|
|
210
254
|
str
|
211
255
|
end
|
212
256
|
|
213
|
-
def process_lines(str)
|
214
|
-
# set protocols mpls path
|
215
|
-
str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
|
216
|
-
"#{$1}#{$2}s(#{$2}ipaddr,"
|
217
|
-
end
|
218
|
-
|
219
|
-
# set protocols iccp peer xxx liveness-detection single-hop
|
220
|
-
str.gsub!(/(^rule\(:peer_group\) do.*?\n(\s*)"detection-time" \(.*?c\(\s*"threshold" arg .*?\)\s*\))/m) do
|
221
|
-
"#{$1},\n#{format('"single-hop"', $2)}"
|
222
|
-
end
|
223
|
-
|
224
|
-
# set forwarding-options dhcp-relay server-group
|
225
|
-
str.gsub!(/^(rule\(:(?:v6_)?server_group_type\) do)\n(.*?)\nend/m) do
|
226
|
-
"#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
|
227
|
-
end
|
228
|
-
|
229
|
-
# set interfaces xxx enable
|
230
|
-
str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
|
231
|
-
%[#{$1}#{$2}"enable",#{$2}]
|
232
|
-
end
|
233
|
-
|
234
|
-
str
|
235
|
-
end
|
236
|
-
|
237
257
|
def finalize(lines)
|
238
258
|
lines = balance_parenthesis(lines)
|
239
259
|
objectize_arg_of_s(lines)
|