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 +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +95 -42
- data/Gemfile.lock +12 -10
- data/LICENSE.txt +1 -1
- data/README.md +47 -11
- data/Rakefile +12 -3
- data/example/get-schema.xml +19 -0
- data/example/junos-18.1R3-S9.rb +102366 -0
- data/example/mx-19.3R3-S1.3.rb +118283 -0
- data/example/vmx-17.2R1.13.rb +2287 -2272
- data/example/vsrx-18.3R1.9.rb +1305 -1305
- data/junoser.gemspec +1 -1
- data/lib/junoser/display/structure.rb +1 -1
- data/lib/junoser/js_ruler.rb +20 -21
- data/lib/junoser/parser.rb +40788 -22351
- data/lib/junoser/ruler.rb +137 -84
- data/lib/junoser/version.rb +1 -1
- data/lib/junoser/xsd/base.rb +9 -6
- data/lib/junoser/xsd/choice.rb +6 -2
- data/lib/junoser/xsd/complex_type.rb +3 -3
- data/lib/junoser/xsd/element.rb +7 -3
- data/lib/junoser/xsd/restriction.rb +2 -2
- data/lib/junoser/xsd/sequence.rb +11 -3
- data/lib/junoser/xsd/simple_content.rb +1 -1
- data/lib/junoser/xsd/simple_type.rb +2 -2
- data/lib/junoser/xsd/union.rb +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37eb9172418859fd2a4144cdd0d4b47c657162e02117cfb9fe73a33fe9ca0e2
|
4
|
+
data.tar.gz: 4791fbaf136985e1b16a4dba7daaf2fc2dbcee8ed85508d2e3c65b5b3f4575b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5961c24e760831bf52f6edb82c5972aefb023d99639091fb2c12d95f083ef57e9e2703fd441dbb0c1d5e44b5e386834679e910873e44825c9a7c103243fa2c6c
|
7
|
+
data.tar.gz: 9e41dcfb72bfe2f5b801506c50725a4a0da2f56a09a8ddeedb8cb7d4b8ae82864008c89cdf2da837ced1c83d39d2e7d53640bba5f7dcb459d434e0d173862659
|
data/.travis.yml
CHANGED
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
|
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
|
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
|
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
|
-
*
|
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
|
-
*
|
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.
|
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.
|
11
|
-
nokogiri (1.
|
12
|
-
mini_portile2 (~> 2.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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 (~>
|
28
|
+
rake (~> 13.0)
|
27
29
|
test-unit
|
28
30
|
|
29
31
|
BUNDLED WITH
|
30
|
-
2.
|
32
|
+
2.2.16
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -28,34 +28,70 @@ $ gem install junoser
|
|
28
28
|
|
29
29
|
### Usage
|
30
30
|
|
31
|
-
|
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
|
-
|
41
|
+
#### Syntax translation
|
42
|
+
|
43
|
+
##### Structured form into "display set"
|
44
44
|
|
45
45
|
```zsh
|
46
|
-
$
|
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
|
-
|
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)
|
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-
|
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/
|
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
|
|