junoser 0.3.12 → 0.4.2

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: d2f7cf47c90df6c85894a4139d839ef0508328017b341f1b36a3d33af1c80636
4
- data.tar.gz: 052afe8daf0090bcc2345a92e1e6b32787a4feb7cfcd45906a58ab46fd7ac822
3
+ metadata.gz: f37eb9172418859fd2a4144cdd0d4b47c657162e02117cfb9fe73a33fe9ca0e2
4
+ data.tar.gz: 4791fbaf136985e1b16a4dba7daaf2fc2dbcee8ed85508d2e3c65b5b3f4575b9
5
5
  SHA512:
6
- metadata.gz: 9b19b660982613861c9747782ff5002c7dc21cab047081e421bf0b45a920b2f40d27125b72e951e780c15cbf8653c632cbee44323553d6b83ff3bbc5276c34bf
7
- data.tar.gz: b66c59b3d594714a9dada165a97930e326f82283a4a3a2c9270168197e0072ff09e5d44855582e96b5472e584311d76f4d14a53612d4464898f7dcfb1c9e8ead
6
+ metadata.gz: 5961c24e760831bf52f6edb82c5972aefb023d99639091fb2c12d95f083ef57e9e2703fd441dbb0c1d5e44b5e386834679e910873e44825c9a7c103243fa2c6c
7
+ data.tar.gz: 9e41dcfb72bfe2f5b801506c50725a4a0da2f56a09a8ddeedb8cb7d4b8ae82864008c89cdf2da837ced1c83d39d2e7d53640bba5f7dcb459d434e0d173862659
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.4
5
- - 2.5
6
4
  - 2.6
5
+ - 2.7
6
+ - 3.0
7
7
  - ruby-head
8
8
 
9
9
  before_install:
data/CHANGELOG.md CHANGED
@@ -1,9 +1,59 @@
1
+ ## [0.4.2] - 2021-08-30
2
+
3
+ ### Added
4
+
5
+ * Newly supported syntax
6
+ * "virtual-chassis vcp-snmp-statistics"
7
+ * "application_object"
8
+
9
+ ### Fixed
10
+
11
+ * Keywords "tls", "group", "dest-nat-rule-match", "src-nat-rule-match", and "static-nat-rule-match" might be marked as invalid in some hierarchies
12
+ * "applications application xxx term xxx"
13
+ * "security"
14
+
15
+
16
+ ## [0.4.1] - 2021-06-06
17
+
18
+ ### Added
19
+
20
+ * Newly supported syntax
21
+ * "apply-groups-except"
22
+
23
+ ### Fixed
24
+
25
+ * Keywords "scpf-link", "https", "inet6", "icmp6", "icmpv6", "ospf3", and "snmptrap" might be marked as invalid in some hierarchies
26
+ * "policy-options community xxx members"
27
+ * "policy-options route-distinguisher xxx members"
28
+ * "routing-options confederation members"
29
+
30
+
31
+ ## [0.4.0] - 2021-05-02
32
+
33
+ ### Added
34
+
35
+ * Recreate parser based on MX 19.3R3-S1.3 xsd
36
+
37
+
38
+ ## [0.3.13] - 2020-05-20
39
+
40
+ ### Fixed
41
+
42
+ * Accept quoted strings under
43
+ * "system login message"
44
+ * "policy-options prefix-list xxx apply-path"
45
+
46
+ * <xsd:documentation/> processing during "rake build:config"
47
+ * <xsd:sequence><xsd:choice maxOccurs="unbounded"></xsd:sequence> should be considered as a sequence
48
+
49
+
1
50
  ## [0.3.12] - 2020-02-06
2
51
 
3
52
  ### Fixed
4
53
 
5
54
  * "insert" statement whose last two tokens are keyword and argument, with the following single "before" (or "after") argument
6
- * eg) insert protocols bgp group foo export bar insert baz
55
+ * eg) insert protocols bgp group foo export bar before baz
56
+
7
57
 
8
58
  ## [0.3.11] - 2020-01-28
9
59
 
@@ -11,6 +61,7 @@
11
61
 
12
62
  * junoser-squash supports "activate" statement
13
63
 
64
+
14
65
  ## [0.3.10] - 2020-01-27
15
66
 
16
67
  ### Added
@@ -23,6 +74,7 @@
23
74
  * junoser-squash unexpectedly removed "deactivate" statements
24
75
  * "deactivate" to "inactive:" translation during "junoser -s"
25
76
 
77
+
26
78
  ## [0.3.9] - 2019-11-17
27
79
 
28
80
  ### Fixed
@@ -30,12 +82,13 @@
30
82
  * security policies
31
83
  * "junoser -s" and "junoser -d" unexpectedly raises errors
32
84
 
85
+
33
86
  ## [0.3.8] - 2019-11-04
34
87
 
35
88
  ### Added
36
89
 
37
90
  * Newly supported syntax
38
- * security (by porting the hierarchy from vSRX 18.3R1.9)
91
+ * "security" (by porting the hierarchy from vSRX 18.3R1.9)
39
92
 
40
93
 
41
94
  ## [0.3.7] - 2019-09-03
@@ -60,7 +113,7 @@
60
113
 
61
114
  ### Fixed
62
115
 
63
- * Accept quoted string for
116
+ * Accept quoted strings under
64
117
  * "as-path path"
65
118
 
66
119
 
@@ -69,16 +122,16 @@
69
122
  ### Added
70
123
 
71
124
  * Newly supported syntax
72
- * protocols bgp minimum-hold-time xxx
73
- * system dump-on-panic
74
- * chassis fpc x pic x port x number-of-sub-ports x
125
+ * "protocols bgp minimum-hold-time xxx"
126
+ * "system dump-on-panic"
127
+ * "chassis fpc x pic x port x number-of-sub-ports x"
75
128
 
76
129
 
77
130
  ## [0.3.3] - 2018-10-09
78
131
 
79
132
  ### Fixed
80
133
 
81
- * Accept quoted string for
134
+ * Accept quoted strings under
82
135
  * "snmp location"
83
136
  * "snmp contact"
84
137
 
@@ -121,7 +174,7 @@
121
174
  ### Added
122
175
 
123
176
  * Newly supported syntax
124
- * class-of-service shared-buffer
177
+ * "class-of-service shared-buffer"
125
178
 
126
179
 
127
180
  ## [0.2.11] - 2017-09-07
@@ -129,15 +182,15 @@
129
182
  ### Added
130
183
 
131
184
  * Newly supported syntax
132
- * forwarding-options analyzer
133
- * routing-options dynamic-tunnels <name> udp
185
+ * "forwarding-options analyzer"
186
+ * "routing-options dynamic-tunnels <name> udp"
134
187
 
135
188
 
136
189
  ## [0.2.10] - 2017-08-22
137
190
 
138
191
  ### Fixed
139
192
 
140
- * routing-options dynamic-tunnels
193
+ * "routing-options dynamic-tunnels"
141
194
 
142
195
 
143
196
  ## [0.2.9] - 2017-06-09
@@ -145,14 +198,14 @@
145
198
  ### Added
146
199
 
147
200
  * Newly supported syntax
148
- * protocols sflow
201
+ * "protocols sflow"
149
202
 
150
203
 
151
204
  ## [0.2.8] - 2017-05-17
152
205
 
153
206
  ### Fixed
154
207
 
155
- * chassis forwarding-options
208
+ * "chassis forwarding-options"
156
209
 
157
210
 
158
211
  ## [0.2.7] - 2017-05-01
@@ -160,9 +213,9 @@
160
213
  ### Added
161
214
 
162
215
  * Newly supported syntax
163
- * system processes app-engine-virtual-machine-management-service
164
- * system processes app-engine-management-service
165
- * chassis fpc ? pic ? tunnel-services
216
+ * "system processes app-engine-virtual-machine-management-service"
217
+ * "system processes app-engine-management-service"
218
+ * "chassis fpc ? pic ? tunnel-services"
166
219
 
167
220
 
168
221
  ## [0.2.6] - 2017-04-21
@@ -170,7 +223,7 @@
170
223
  ### Added
171
224
 
172
225
  * Newly supported syntax
173
- * chassis fpc ? pic ? port ? channel-speed ?
226
+ * "chassis fpc ? pic ? port ? channel-speed ?"
174
227
 
175
228
  ## [0.2.5] - 2017-04-18
176
229
 
@@ -184,7 +237,7 @@
184
237
  ### Added
185
238
 
186
239
  * Newly supported syntax
187
- * system processes app-engine-virtual-machine-management-service traceoptions
240
+ * "system processes app-engine-virtual-machine-management-service traceoptions"
188
241
  * Some platforms expect "system processes dhcp", not "system processes dhcp-service"
189
242
  * "storm-control" under family bridge
190
243
 
@@ -198,8 +251,8 @@
198
251
  ### Added
199
252
 
200
253
  * Newly supported syntax
201
- * chassis fpc N error
202
- * forwarding-options sampling family mpls
254
+ * "chassis fpc N error"
255
+ * "forwarding-options sampling family mpls"
203
256
 
204
257
 
205
258
  ## [0.2.2] - 2016-02-15
@@ -207,7 +260,7 @@
207
260
  ### Added
208
261
 
209
262
  * Newly supported syntax
210
- * system services ssh
263
+ * "system services ssh"
211
264
 
212
265
  ### Fixed
213
266
 
@@ -224,7 +277,7 @@
224
277
 
225
278
  ### Fixed
226
279
 
227
- * template-name
280
+ * "template-name"
228
281
 
229
282
 
230
283
  ## [0.2.0] - 2015-12-26
@@ -243,44 +296,44 @@
243
296
 
244
297
  ### Fixed
245
298
 
246
- * 802.3ad
247
- * ether-options
248
- * storm-control default
249
- * vrf-target
250
- * maximum-prefix teardown
251
- * traceoptions
252
- * system syslog archive
253
- * system login user
254
- * routing-options confederation
255
- * hold-time
256
- * protocols ospf area x.x.x.x stub default-metric x x
257
- * protocols rsvp interface xxx subscription x
258
- * traceoptions cspf-link
259
- * protocols mpls priority
260
- * protocols mpls label-switched-path xxx primary xxx bandwidth xxx
261
- * protocols xxx rib-group xxx xxx
262
- * protocols mpls path xxx xxx
299
+ * "802.3ad"
300
+ * "ether-options"
301
+ * "storm-control default"
302
+ * "vrf-target"
303
+ * "maximum-prefix teardown"
304
+ * "traceoptions"
305
+ * "system syslog archive"
306
+ * "system login user"
307
+ * "routing-options confederation"
308
+ * "hold-time"
309
+ * "protocols ospf area x.x.x.x stub default-metric x x"
310
+ * "protocols rsvp interface xxx subscription x"
311
+ * "traceoptions cspf-link"
312
+ * "protocols mpls priority"
313
+ * "protocols mpls label-switched-path xxx primary xxx bandwidth xxx"
314
+ * "protocols xxx rib-group xxx xxx"
315
+ * "protocols mpls path xxx xxx"
263
316
 
264
317
 
265
318
  ## [0.1.6] - 2015-10-31
266
319
 
267
320
  ### Fixed
268
321
 
269
- * route-filter statement should be translated into one-line
322
+ * "route-filter" statement should be translated into one-line
270
323
 
271
324
 
272
325
  ## [0.1.5] - 2015-09-11
273
326
 
274
327
  ### Fixed
275
328
 
276
- * mistakenly processed '{' and '}' in as-path string
329
+ * Mistakenly processed '{' and '}' in as-path string
277
330
 
278
331
 
279
332
  ## [0.1.4] - 2015-09-11
280
333
 
281
334
  ### Fixed
282
335
 
283
- * missing community operator in policy-statement didn't fail
336
+ * Missing community operator in policy-statement didn't fail
284
337
 
285
338
 
286
339
  ## [0.1.3] - 2015-07-26
data/Gemfile.lock CHANGED
@@ -1,19 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.3.12)
4
+ junoser (0.4.2)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile2 (2.4.0)
11
- nokogiri (1.10.4)
12
- mini_portile2 (~> 2.4.0)
13
- parslet (1.8.2)
14
- power_assert (1.1.5)
15
- rake (10.5.0)
16
- test-unit (3.3.3)
10
+ mini_portile2 (2.5.3)
11
+ nokogiri (1.11.7)
12
+ mini_portile2 (~> 2.5.0)
13
+ racc (~> 1.4)
14
+ parslet (2.0.0)
15
+ power_assert (2.0.0)
16
+ racc (1.5.2)
17
+ rake (13.0.3)
18
+ test-unit (3.4.4)
17
19
  power_assert
18
20
 
19
21
  PLATFORMS
@@ -23,8 +25,8 @@ DEPENDENCIES
23
25
  bundler (~> 2.0)
24
26
  junoser!
25
27
  nokogiri
26
- rake (~> 10.0)
28
+ rake (~> 13.0)
27
29
  test-unit
28
30
 
29
31
  BUNDLED WITH
30
- 2.1.2
32
+ 2.2.16
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Shintaro Kojima
3
+ Copyright (c) 2015-2021 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
@@ -28,34 +28,70 @@ $ gem install junoser
28
28
 
29
29
  ### Usage
30
30
 
31
- To verify configurations syntax:
31
+ #### Syntax validation
32
32
 
33
33
  ```zsh
34
34
  $ junoser -c config.txt
35
- ```
36
35
 
37
- or
36
+ # or
38
37
 
39
- ```zsh
40
38
  $ cat config.txt | junoser -c
41
39
  ```
42
40
 
43
- To translate configuration into "display set" form:
41
+ #### Syntax translation
42
+
43
+ ##### Structured form into "display set"
44
44
 
45
45
  ```zsh
46
- $ /exe/junoser -d config.txt
46
+ $ junoser -d config.txt
47
47
  set protocols bgp group ebgp-peers neighbor 192.0.2.2
48
- ```
49
48
 
50
- or
49
+ # or
51
50
 
52
- ```zsh
53
51
  $ cat config.txt | junoser -d
54
52
  set protocols bgp group ebgp-peers neighbor 192.0.2.2
55
53
  ```
56
54
 
57
- Use ```junoser -s``` to translate into structured form.
55
+ ##### "display set" into structured form
56
+
57
+ ```zsh
58
+ $ junoser -s config.txt
59
+
60
+ # or
61
+
62
+ $ cat config.txt | junoser -s
63
+ ```
64
+
65
+
66
+ ## Updating parser for new directives
67
+
68
+ From [Juniper
69
+ website](https://support.juniper.net/support/downloads/), you can
70
+ download the XSD schema for the version of JunOS you want to target:
58
71
 
72
+ - Junos XML API
73
+ - Select your version
74
+ - Application Tools
75
+ - XML Schema for Configurator Data
76
+
77
+ Alternatively, you can retrieve the schema with Netconf:
78
+
79
+ ```zsh
80
+ $ ssh -Csp 830 JUNOS netconf < example/get-schema.xml | sed -n '/^<xsd:schema/,/^<\/xsd:schema/p' > junos-XXX.xsd
81
+ ```
82
+
83
+ Put it in `tmp/`, update `xsd_path` in `Rakefile` and run:
84
+
85
+ ```zsh
86
+ $ bundle exec rake build:config build:rule
87
+ ```
88
+
89
+ Alternatively, you may look in `example/` for some prebuilt rules
90
+ file. If you want to use them, copy one to `tmp/rules.rb` and run:
91
+
92
+ ```zsh
93
+ $ bundle exec rake build:rule
94
+ ```
59
95
 
60
96
  ## Contributing
61
97
 
@@ -67,4 +103,4 @@ Or send a pull request to fix.
67
103
 
68
104
  ## Copyright and License
69
105
 
70
- Copyright (c) 2020 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
106
+ Copyright (c) 2015-2021 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
data/Rakefile CHANGED
@@ -4,10 +4,10 @@ require 'nokogiri'
4
4
  require 'pathname'
5
5
  require 'rake/testtask'
6
6
 
7
- xsd_path = File.join(__dir__, 'tmp/junos-system-17.2.xsd')
7
+ xsd_path = File.join(__dir__, 'tmp/junos-system-19.3.xsd')
8
8
  rule_path = File.join(__dir__, 'tmp/rule.rb')
9
9
  ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
10
- js_parser_path = File.join(__dir__, 'tmp/schema.js')
10
+ js_parser_path = File.join(__dir__, 'tmp/junos.js')
11
11
 
12
12
  def open_files(input, output, &block)
13
13
  i = open(input)
@@ -19,12 +19,22 @@ def open_files(input, output, &block)
19
19
  o.close
20
20
  end
21
21
 
22
+ def move_wildcards(element)
23
+ ['ipaddr', 'ipv6addr', 'ipprefix'].each do |pattern|
24
+ element.xpath(%[.//xsd:element[@type="#{pattern}"]/xsd:annotation/xsd:appinfo/flag[text()="nokeyword"]/../../..]).each do |wildcard|
25
+ parent = wildcard.parent
26
+ removed = wildcard.remove
27
+ parent << removed
28
+ end
29
+ end
30
+ end
22
31
 
23
32
  namespace :build do
24
33
  desc 'Build an intermediate config hierarchy'
25
34
  task :config do
26
35
  open_files(xsd_path, rule_path) do |input, output|
27
36
  Nokogiri::XML(input).root.remove_unused.xpath('/xsd:schema/*').each do |e|
37
+ move_wildcards e # Move wildcard elements to the end of siblings as they capture keywords unexpectedly
28
38
  output.puts e.to_config
29
39
  end
30
40
  end
@@ -56,7 +66,6 @@ task 'find-srx-methods' do
56
66
  end
57
67
  end
58
68
 
59
-
60
69
  Rake::TestTask.new do |t|
61
70
  t.libs << 'test'
62
71