junoser 0.4.6 → 0.5.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 +19 -0
- data/Gemfile.lock +5 -5
- data/Rakefile +1 -1
- data/commitlint.config.js +1 -0
- data/example/mx-21.2R3-S2.9.rb +127432 -0
- data/example/vsrx-18.3R1.9.rb +380 -30
- data/lib/junoser/js_ruler.rb +27 -2
- data/lib/junoser/parser.rb +38212 -29081
- data/lib/junoser/ruler.rb +12 -6
- data/lib/junoser/version.rb +1 -1
- metadata +3 -2
data/lib/junoser/js_ruler.rb
CHANGED
@@ -16,8 +16,9 @@ module Junoser
|
|
16
16
|
|
17
17
|
def rule
|
18
18
|
str = @rule.read
|
19
|
+
str = process_lines(str)
|
19
20
|
str = str.split(/\n/).map {|l|
|
20
|
-
|
21
|
+
process_line(l) unless l =~ /^ *#/ # Skip additional comment lines
|
21
22
|
}.compact.join("\n")
|
22
23
|
finalize(str)
|
23
24
|
end
|
@@ -161,9 +162,12 @@ module Junoser
|
|
161
162
|
end
|
162
163
|
|
163
164
|
def process_reserved_word(str)
|
164
|
-
# ieee-802.3ad
|
165
|
+
# ieee-802.3ad -> 802.3ad
|
165
166
|
str.gsub! 'ieee-802.3ad', '802.3ad'
|
166
167
|
|
168
|
+
# end-range -> to
|
169
|
+
str.gsub! '"end-range"', '"to"'
|
170
|
+
|
167
171
|
# "policy | Define a policy context from this zone" -> "from-zone | Define a policy context from this zone"
|
168
172
|
str.gsub! 'policy | Define a policy context from this zone', 'from-zone | Define a policy context from this zone'
|
169
173
|
# "to-zone-name | Destination zone" -> "to-zone | Destination zone"
|
@@ -171,6 +175,18 @@ module Junoser
|
|
171
175
|
# "system-name | System name override" -> "name | System name override"
|
172
176
|
str.gsub! 'system-name | System name override', 'name | System name override'
|
173
177
|
|
178
|
+
# "set class-of-service interfaces all unit"
|
179
|
+
str.gsub! '"unit(*)"', '"unit(*|arg)"'
|
180
|
+
# "classifiers xxx"
|
181
|
+
str.gsub! '["default"]', '["default", "arg"]'
|
182
|
+
|
183
|
+
# keywords "dest-nat-rule-match", "src-nat-rule-match", "static-nat-rule-match" are wrong
|
184
|
+
str.gsub!(/"(dest|src|static)-nat-rule-match/) { '"match' }
|
185
|
+
|
186
|
+
# faster interface speed support
|
187
|
+
str.gsub! '"40g", "oc3"', '"40g", "100g", "200g", "400g", "800g", "oc3"'
|
188
|
+
str.gsub! '"100G"', '"100G", "200G", "400G", "800G"'
|
189
|
+
|
174
190
|
fix_route_filter(str)
|
175
191
|
|
176
192
|
str
|
@@ -192,6 +208,15 @@ module Junoser
|
|
192
208
|
str
|
193
209
|
end
|
194
210
|
|
211
|
+
def process_lines(str)
|
212
|
+
# "set protocols mpls path"
|
213
|
+
str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
|
214
|
+
"#{$1}#{$2}s(#{$2}ipaddr,"
|
215
|
+
end
|
216
|
+
|
217
|
+
str
|
218
|
+
end
|
219
|
+
|
195
220
|
def finalize(lines)
|
196
221
|
lines = balance_parenthesis(lines)
|
197
222
|
objectize_arg_of_s(lines)
|