junoser 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a73208784003b23a9dc996cf06ef4941a3da1ad35143848885c3e37a0e921e84
4
- data.tar.gz: ae1ded9c7e208d3af98a96cf4c9fe5839b51d79447f1921fb36807f4202017ad
3
+ metadata.gz: bd8d0023004d5b1a354481038fd124a73b1aff42b66fd0582534dbed3587acfc
4
+ data.tar.gz: 26215df72ca310d36a6b57e5e288d145c5e575ced116633e023b0d895db4546f
5
5
  SHA512:
6
- metadata.gz: 8ac8d0ca12b3dada5bea555115c5ac172cc7dd3123c3fb5b85ab01e7f7e116daed5b2e9faebfc6237569719ad363c182522359a0cb1d1f1892f3bb85cfb5cc47
7
- data.tar.gz: c37c95e729cdbf60a517845c0561c80b5bbb6e43f5b1dfd0c6ed8a8f49e431028c12ffb6dd0b081e8ce15ce829af599e246635a60df8d7f528d567835271e154
6
+ metadata.gz: 4fb26b5d915d873942e4ae4fcff612f70664ed933353287597c74da9ecf42f68f7e6f55ce8472e64a73ae2598a77937beacfb1fc9b417b9247e4dfcbcf76904f
7
+ data.tar.gz: 534d3484149a158d384e2beaabd6a12c33cd16ef993d2ddfb90e61410b76a6dd3ef214e7894c9a2b2541effbe69f7e271b4cc7208d9bb22470efc5e16a912c99
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.7.1] - 2025-02-03
2
+
3
+ ### Added
4
+
5
+ * Newly supported syntax for vSRX
6
+ * "system services web-management http"
7
+
8
+
9
+ ## [0.7.0] - 2024-12-19
10
+
11
+ ### Added
12
+
13
+ * Recreate parser based on MX 22.4R3-S2.11 xsd
14
+ * Newly supported syntax
15
+ * "groups xxx when"
16
+ * "snmp stats-cache-lifetime xxx"
17
+
18
+
1
19
  ## [0.6.0] - 2024-09-15
2
20
 
3
21
  ### Added
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.6.0)
4
+ junoser (0.7.1)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile2 (2.8.7)
11
- nokogiri (1.16.7)
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.3)
15
+ power_assert (2.0.5)
16
16
  racc (1.8.1)
17
17
  rake (13.2.1)
18
- test-unit (3.6.2)
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.9
32
+ 2.6.2
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2024 Shintaro Kojima
3
+ Copyright (c) 2015-2025 Shintaro Kojima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -103,4 +103,4 @@ Or send a pull request to fix.
103
103
 
104
104
  ## Copyright and License
105
105
 
106
- Copyright (c) 2015-2024 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
106
+ Copyright (c) 2015-2025 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
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-21.2.xsd')
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')
@@ -25,6 +25,53 @@ 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
+ c(
33
+ this.configuration({ groups: false }),
34
+ "when" ( /* Specify additional conditions for groups */
35
+ c(
36
+ "chassis" arg /* Chassis id */,
37
+ "member" arg /* Member of virtual chassis */,
38
+ "model" arg /* Model name */,
39
+ "node" arg /* Node of cluster */,
40
+ "peers" arg /* Hosts on which this group should be effective */,
41
+ "routing-engine" arg /* Routing Engine */,
42
+ "time" ( /* Time at which group should be effective */
43
+ "to" arg /* End time([yyyy-mm-dd.]hh:mm) */,
44
+ arg
45
+ )
46
+ )
47
+ )
48
+ )
49
+ )
50
+ EOS
51
+
52
+ # set protocols mpls path
53
+ str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
54
+ "#{$1}#{$2}s(#{$2}ipaddr,"
55
+ end
56
+
57
+ # set protocols iccp peer xxx liveness-detection single-hop
58
+ str.gsub!(/(^rule\(:peer_group\) do.*?\n(\s*)"detection-time" \(.*?c\(\s*"threshold" arg .*?\)\s*\))/m) do
59
+ "#{$1},\n#{format('"single-hop"', $2)}"
60
+ end
61
+
62
+ # set forwarding-options dhcp-relay server-group
63
+ str.gsub!(/^(rule\(:(?:v6_)?server_group_type\) do)\n(.*?)\nend/m) do
64
+ "#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
65
+ end
66
+
67
+ # set interfaces xxx enable
68
+ str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
69
+ %[#{$1}#{$2}"enable",#{$2}]
70
+ end
71
+
72
+ str
73
+ end
74
+
28
75
  def process_line(str)
29
76
  str = remove_undefined_variables(str)
30
77
  str = process_common_syntax(str)
@@ -47,8 +94,8 @@ module Junoser
47
94
  end
48
95
 
49
96
  def process_common_syntax(str)
50
- # rule(:foo) do -> foo(...args) {
51
- str.gsub!(/^rule\(:(\S+)\) do/) { "#$1(...args) { return_next_line" }
97
+ # rule(:foo) do -> foo(opts) {
98
+ str.gsub!(/^rule\(:(\S+)\) do/) { "#$1(opts) { return_next_line" }
52
99
  # end -> }
53
100
  str.gsub!(/^(\s*)end$/) { "#$1}" }
54
101
 
@@ -123,12 +170,12 @@ module Junoser
123
170
  end
124
171
 
125
172
  def process_structural_syntax(str)
126
- # "foo" ( /* doc */ -> "foo | doc": (...args) => {
173
+ # "foo" ( /* doc */ -> "foo | doc": (opts) => {
127
174
  str.gsub!(%r|^(\s*)"(\S+)" \( /\* (.*) \*/|) { "#$1\"#$2 | #$3\": {" }
128
- # "foo" ( -> "foo": (...args) => {
175
+ # "foo" ( -> "foo": (opts) => {
129
176
  str.gsub!(%r|^(\s*)"(\S+)" \($|) { "#$1\"#$2\": {" }
130
177
 
131
- # "foo" arg ( /* doc */ -> "foo | doc": (...args) => {
178
+ # "foo" arg ( /* doc */ -> "foo | doc": (opts) => {
132
179
  str.gsub!(%r|^(\s*)"(\S+)" arg \( /\* (.*) \*/|) { "#$1\"#$2 | #$3\": {" }
133
180
 
134
181
  str
@@ -210,30 +257,6 @@ module Junoser
210
257
  str
211
258
  end
212
259
 
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
260
  def finalize(lines)
238
261
  lines = balance_parenthesis(lines)
239
262
  objectize_arg_of_s(lines)
@@ -266,6 +289,8 @@ module Junoser
266
289
 
267
290
  # "arg" -> "arg_1"
268
291
  lines.gsub('"arg":') { %["arg_#{sequence}":] }
292
+
293
+ conditional_groups(lines)
269
294
  end
270
295
 
271
296
  # } -> )
@@ -329,6 +354,17 @@ module Junoser
329
354
  lines
330
355
  end
331
356
 
357
+ def conditional_groups(lines)
358
+ # "null_13264": this.configuration(false),
359
+ # ->
360
+ # (opts === undefined || opts?.configuration !== false) && { "null_13264": this.configuration(false) },
361
+ #
362
+ # ref: process_lines()
363
+ lines.gsub(/("groups\(arg\) \| .*":) {/) {
364
+ "#{$1} opts?.groups !== false && {"
365
+ }
366
+ end
367
+
332
368
  def rule_header
333
369
  <<~EOS
334
370
  /* eslint-disable semi */