oxidized 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Dockerfile +1 -1
- data/Gemfile.lock +8 -6
- data/README.md +143 -79
- data/Rakefile +4 -4
- data/bin/oxidized +2 -1
- data/extra/rest_client.rb +25 -3
- data/lib/oxidized/input/cli.rb +3 -0
- data/lib/oxidized/input/ssh.rb +20 -11
- data/lib/oxidized/input/tftp.rb +41 -0
- data/lib/oxidized/model/acos.rb +16 -0
- data/lib/oxidized/model/alvarion +13 -0
- data/lib/oxidized/model/asa.rb +3 -0
- data/lib/oxidized/model/catos.rb +9 -2
- data/lib/oxidized/model/cumulus.rb +10 -4
- data/lib/oxidized/model/datacom.rb +6 -1
- data/lib/oxidized/model/pfsense.rb +18 -0
- data/lib/oxidized/model/routeros.rb +2 -1
- data/lib/oxidized/model/saos.rb +4 -2
- data/lib/oxidized/model/timos.rb +64 -7
- data/lib/oxidized/node.rb +35 -17
- data/lib/oxidized/output/file.rb +8 -6
- data/lib/oxidized/source/csv.rb +5 -3
- data/lib/oxidized/source/http.rb +4 -2
- data/lib/oxidized/source/source.rb +12 -0
- data/lib/oxidized/source/sql.rb +3 -1
- data/lib/oxidized/version.rb +1 -1
- data/lib/oxidized.rb +1 -1
- data/oxidized.gemspec +1 -1
- metadata +9 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4293285f8095f28f9f3d38dc2d606a03a58d163b
|
|
4
|
+
data.tar.gz: f108592ebdce488d10f06d7ee0e5545e3e117e32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aed22b16c6223c5b27a6b68476e25aea4154fcafd104a8567f7f19c4de38c8dddcd3fe18e1fd0950bc6e01e927d6af2fed514dd8f966eb33670f2a3517c6285f
|
|
7
|
+
data.tar.gz: 62a21f8caa39a27c853d2d56b3b96d35f6320db5cf6743ea76dd0cb7c6562729a0b96b5cc9b83524ad6edaac960dfb07ab88c7bffa526b459248603ba0e71bfa
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# 0 17.3
|
|
2
|
+
- FEATURE: "nil", "false" and "true" in source (e.g. router.db) are interpeted as nil, false, true. Empty is now always considered empty string, instead of in some cases nil and some cases empty string.
|
|
3
|
+
- FEATURE: support tftp as input model (@MajesticFalcon)
|
|
4
|
+
- FEATURE: add alvarion model (@MajesticFalcon)
|
|
5
|
+
- FEATURE: detect if ssh wants password terminal/CLI prompt or not
|
|
6
|
+
- FEATURE: node (group, model, username, password) resolution refactoring, supports wider range of use-cases
|
|
7
|
+
- BUGFIX: fetch for file output (@danilopopeye)
|
|
8
|
+
- BUGFIX: net-ssh version specification
|
|
9
|
+
- BUGFIX: routeros, catos, pfsense
|
|
10
|
+
|
|
11
|
+
# 0.16.3
|
|
12
|
+
- FEATURE: pfsense support (by @stokbaek)
|
|
13
|
+
- BUGFIX: cumulus prompt not working with default switch configs (by @nertwork)
|
|
14
|
+
- BUGFIX: disconnect ssh when prompt wasn't found (by @andir)
|
|
15
|
+
- BUGFIX: saos, asa, acos, timos updates, cumulus
|
|
16
|
+
|
|
1
17
|
# 0.16.2
|
|
2
18
|
- BUGFIX: when not using git (by @danilopopeye)
|
|
3
19
|
- BUGFIX: screenos update
|
data/Dockerfile
CHANGED
|
@@ -3,7 +3,7 @@ MAINTAINER Samer Abdel-Hafez <sam@arahant.net>
|
|
|
3
3
|
|
|
4
4
|
RUN add-apt-repository ppa:brightbox/ruby-ng && \
|
|
5
5
|
apt-get update && \
|
|
6
|
-
apt-get install -y ruby2.
|
|
6
|
+
apt-get install -y ruby2.3 ruby2.3-dev libsqlite3-dev libssl-dev pkg-config make cmake
|
|
7
7
|
|
|
8
8
|
RUN gem install oxidized oxidized-web --no-ri --no-rdoc
|
|
9
9
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
oxidized (0.
|
|
4
|
+
oxidized (0.17.0)
|
|
5
5
|
asetus (~> 0.1)
|
|
6
|
-
net-ssh (
|
|
6
|
+
net-ssh (~> 3.0.2)
|
|
7
|
+
net-telnet
|
|
7
8
|
rugged (~> 0.21, >= 0.21.4)
|
|
8
9
|
slop (~> 3.5)
|
|
9
10
|
|
|
@@ -14,16 +15,17 @@ GEM
|
|
|
14
15
|
coderay (1.1.0)
|
|
15
16
|
metaclass (0.0.4)
|
|
16
17
|
method_source (0.8.2)
|
|
17
|
-
minitest (5.
|
|
18
|
+
minitest (5.9.0)
|
|
18
19
|
mocha (1.1.0)
|
|
19
20
|
metaclass (~> 0.0.1)
|
|
20
21
|
net-ssh (3.0.2)
|
|
22
|
+
net-telnet (0.1.1)
|
|
21
23
|
pry (0.10.3)
|
|
22
24
|
coderay (~> 1.1.0)
|
|
23
25
|
method_source (~> 0.8.1)
|
|
24
26
|
slop (~> 3.4)
|
|
25
|
-
rake (10.
|
|
26
|
-
rugged (0.
|
|
27
|
+
rake (10.5.0)
|
|
28
|
+
rugged (0.23.3)
|
|
27
29
|
slop (3.6.0)
|
|
28
30
|
|
|
29
31
|
PLATFORMS
|
|
@@ -38,4 +40,4 @@ DEPENDENCIES
|
|
|
38
40
|
rake (~> 10.0)
|
|
39
41
|
|
|
40
42
|
BUNDLED WITH
|
|
41
|
-
1.
|
|
43
|
+
1.11.2
|
data/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
# Oxidized [](https://travis-ci.org/Shopify/oxidized)
|
|
2
|
-
|
|
3
|
-
[](http://badge.fury.io/rb/oxidized)
|
|
1
|
+
# Oxidized [](https://travis-ci.org/Shopify/oxidized) [](http://badge.fury.io/rb/oxidized) [](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
4
2
|
|
|
5
3
|
Oxidized is a network device configuration backup tool. It's a RANCID replacement!
|
|
6
4
|
|
|
@@ -29,13 +27,16 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
|
|
|
29
27
|
* [Privileged mode](#privileged-mode)
|
|
30
28
|
* [Disabling SSH exec channels](#disabling-ssh-exec-channels)
|
|
31
29
|
* [Source: CSV](#source-csv)
|
|
32
|
-
* [Source:
|
|
30
|
+
* [Source: SQL](#source-sql)
|
|
31
|
+
* [Source: SQLite](#source-sqlite)
|
|
32
|
+
* [Source: Mysql](#source-mysql)
|
|
33
33
|
* [Source: HTTP](#source-http)
|
|
34
34
|
* [Output: GIT](#output-git)
|
|
35
35
|
* [Output: HTTP](#output-http)
|
|
36
36
|
* [Output: File](#output-file)
|
|
37
37
|
* [Output types](#output-types)
|
|
38
38
|
* [Advanced Configuration](#advanced-configuration)
|
|
39
|
+
* [Advanced Group Configuration](#advanced-group-configuration)
|
|
39
40
|
7. [Ruby API](#ruby-api)
|
|
40
41
|
* [Input](#input)
|
|
41
42
|
* [Output](#output)
|
|
@@ -43,97 +44,103 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
|
|
|
43
44
|
* [Model](#model)
|
|
44
45
|
|
|
45
46
|
# Supported OS types
|
|
47
|
+
* Vendor
|
|
48
|
+
* OS - model_name
|
|
46
49
|
|
|
47
50
|
* A10 Networks
|
|
48
|
-
* ACOS
|
|
51
|
+
* ACOS - acos
|
|
49
52
|
* Alcatel-Lucent
|
|
50
|
-
* AOS
|
|
51
|
-
* AOS7
|
|
52
|
-
* ISAM
|
|
53
|
-
* TiMOS
|
|
53
|
+
* AOS - aos
|
|
54
|
+
* AOS7 - aos7
|
|
55
|
+
* ISAM - isam
|
|
54
56
|
* Wireless
|
|
57
|
+
* Alvarion
|
|
58
|
+
* BreezeACCESS - alvarion
|
|
55
59
|
* Arista
|
|
56
|
-
* EOS
|
|
60
|
+
* EOS - eos
|
|
57
61
|
* Arris
|
|
58
|
-
* C4CMTS
|
|
62
|
+
* C4CMTS - c4cmts
|
|
59
63
|
* Aruba
|
|
60
|
-
* AOSW
|
|
64
|
+
* AOSW - aosw
|
|
61
65
|
* Brocade
|
|
62
|
-
* FabricOS
|
|
63
|
-
* Ironware
|
|
64
|
-
* NOS (Network Operating System)
|
|
65
|
-
* Vyatta
|
|
66
|
-
* 6910
|
|
66
|
+
* FabricOS - fabricos
|
|
67
|
+
* Ironware - ironware
|
|
68
|
+
* NOS (Network Operating System) - nos
|
|
69
|
+
* Vyatta - vyatta
|
|
70
|
+
* 6910 - br6910
|
|
67
71
|
* Check Point
|
|
68
|
-
* GaiaOS
|
|
72
|
+
* GaiaOS - gaiaos
|
|
69
73
|
* Ciena
|
|
70
|
-
* SOAS
|
|
74
|
+
* SOAS - saos
|
|
71
75
|
* Cisco
|
|
72
|
-
* AireOS
|
|
73
|
-
* ASA
|
|
74
|
-
* CatOS
|
|
75
|
-
* IOS
|
|
76
|
-
* IOSXR
|
|
77
|
-
* NXOS
|
|
78
|
-
* SMB (Nikola series)
|
|
76
|
+
* AireOS - aireos
|
|
77
|
+
* ASA - asa
|
|
78
|
+
* CatOS - catos
|
|
79
|
+
* IOS - ios
|
|
80
|
+
* IOSXR - iosxr
|
|
81
|
+
* NXOS - nxos
|
|
82
|
+
* SMB (Nikola series)
|
|
79
83
|
* Citrix
|
|
80
|
-
* NetScaler (Virtual Applicance)
|
|
84
|
+
* NetScaler (Virtual Applicance) - netscaler
|
|
81
85
|
* Coriant (former Tellabs)
|
|
82
|
-
* TMOS (8800)
|
|
83
|
-
* 8600
|
|
86
|
+
* TMOS (8800) - tmos
|
|
87
|
+
* 8600 -
|
|
84
88
|
* Cumulus
|
|
85
89
|
* Linux
|
|
86
90
|
* DataCom
|
|
87
91
|
* DmSwitch 3000
|
|
88
92
|
* DELL
|
|
89
|
-
* PowerConnect
|
|
90
|
-
* AOSW
|
|
93
|
+
* PowerConnect - powerconnect
|
|
94
|
+
* AOSW - aosw
|
|
91
95
|
* Ericsson/Redback
|
|
92
|
-
* IPOS (former SEOS)
|
|
96
|
+
* IPOS (former SEOS) - ipos
|
|
93
97
|
* Extreme Networks
|
|
94
|
-
* XOS
|
|
98
|
+
* XOS - xos
|
|
95
99
|
* WM
|
|
96
100
|
* F5
|
|
97
101
|
* TMOS
|
|
98
102
|
* Force10
|
|
99
|
-
* DNOS
|
|
100
|
-
* FTOS
|
|
103
|
+
* DNOS - dnos
|
|
104
|
+
* FTOS - ftos
|
|
101
105
|
* FortiGate
|
|
102
|
-
* FortiOS
|
|
106
|
+
* FortiOS - fortios
|
|
103
107
|
* HP
|
|
104
|
-
* Comware (HP A-series, H3C, 3Com)
|
|
105
|
-
* Procurve
|
|
108
|
+
* Comware (HP A-series, H3C, 3Com) - comware
|
|
109
|
+
* Procurve - procurve
|
|
106
110
|
* Huawei
|
|
107
111
|
* VRP
|
|
108
112
|
* Juniper
|
|
109
113
|
* JunOS
|
|
110
114
|
* ScreenOS (Netscreen)
|
|
111
115
|
* Mellanox
|
|
112
|
-
* MLNX-OS
|
|
116
|
+
* MLNX-OS - mlnxos
|
|
113
117
|
* Mikrotik
|
|
114
|
-
* RouterOS
|
|
118
|
+
* RouterOS - routeros
|
|
115
119
|
* Motorola
|
|
116
120
|
* RFS
|
|
117
121
|
* MRV
|
|
118
|
-
* MasterOS
|
|
122
|
+
* MasterOS - masteros
|
|
119
123
|
* Netonix
|
|
120
|
-
* WISP Switch (As Netonix)
|
|
124
|
+
* WISP Switch (As Netonix) - netonix
|
|
125
|
+
* Nokia (formerly TiMetra, Alcatel, Alcatel-Lucent)
|
|
126
|
+
* SR OS (TiMOS) - timos
|
|
121
127
|
* Opengear
|
|
122
|
-
* Opengear
|
|
128
|
+
* Opengear - opengear
|
|
123
129
|
* Palo Alto
|
|
124
|
-
* PANOS
|
|
130
|
+
* PANOS - panos
|
|
131
|
+
* pfSense - pfsense
|
|
125
132
|
* Quanta
|
|
126
|
-
* Quanta / VxWorks 6.6 (1.1.0.8)
|
|
133
|
+
* Quanta / VxWorks 6.6 (1.1.0.8) - quantaos
|
|
127
134
|
* Supermicro
|
|
128
|
-
* Supermicro
|
|
135
|
+
* Supermicro - supermicro
|
|
129
136
|
* Ubiquiti
|
|
130
|
-
* AirOS
|
|
131
|
-
* Edgeos
|
|
132
|
-
* EdgeSwitch
|
|
137
|
+
* AirOS - airos
|
|
138
|
+
* Edgeos - edgeos
|
|
139
|
+
* EdgeSwitch - edgeswitch
|
|
133
140
|
* Watchguard
|
|
134
|
-
* Fireware OS
|
|
141
|
+
* Fireware OS - firewareos
|
|
135
142
|
* Zyxel
|
|
136
|
-
* ZyNOS
|
|
143
|
+
* ZyNOS - zynos
|
|
137
144
|
|
|
138
145
|
|
|
139
146
|
# Installation
|
|
@@ -147,7 +154,7 @@ gem install oxidized-script oxidized-web # if you don't install oxidized-web, ma
|
|
|
147
154
|
```
|
|
148
155
|
|
|
149
156
|
## CentOS, Oracle Linux, Red Hat Linux
|
|
150
|
-
On CentOS 6 / RHEL 6, install Ruby 1.9.3
|
|
157
|
+
On CentOS 6 / RHEL 6, install Ruby greater than 1.9.3 (for Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM"), then install Oxidized dependencies
|
|
151
158
|
```shell
|
|
152
159
|
yum install cmake sqlite-devel openssl-devel libssh2-devel
|
|
153
160
|
```
|
|
@@ -254,46 +261,54 @@ rvm use --default 2.1.2
|
|
|
254
261
|
```
|
|
255
262
|
|
|
256
263
|
# Running with Docker
|
|
257
|
-
|
|
264
|
+
|
|
265
|
+
clone git repo:
|
|
258
266
|
|
|
259
267
|
```
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
2. build container locally:
|
|
268
|
+
git clone https://github.com/ytti/oxidized
|
|
263
269
|
```
|
|
264
|
-
|
|
270
|
+
|
|
271
|
+
build container locally:
|
|
272
|
+
|
|
265
273
|
```
|
|
266
|
-
|
|
274
|
+
docker build -q -t oxidized/oxidized:latest oxidized/
|
|
267
275
|
```
|
|
268
|
-
|
|
276
|
+
|
|
277
|
+
create config directory in main system:
|
|
278
|
+
|
|
269
279
|
```
|
|
270
|
-
|
|
280
|
+
mkdir /etc/oxidized
|
|
271
281
|
```
|
|
272
|
-
|
|
282
|
+
|
|
283
|
+
run container the first time:
|
|
284
|
+
_Note: this step in only needed for creating Oxidized's configuration file and can be skipped if you already have it
|
|
285
|
+
|
|
273
286
|
```
|
|
274
|
-
|
|
287
|
+
docker run --rm -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest oxidized
|
|
275
288
|
```
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
|
|
290
|
+
create the `/etc/oxidized/router.db`
|
|
291
|
+
|
|
279
292
|
```
|
|
280
|
-
|
|
293
|
+
vim /etc/oxidized/router.db
|
|
281
294
|
```
|
|
282
|
-
root@bla:~# docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest
|
|
283
|
-
oxidized[1]: Oxidized starting, running as pid 1
|
|
284
|
-
oxidized[1]: Loaded 1 nodes
|
|
285
|
-
Puma 2.13.4 starting...
|
|
286
|
-
* Min threads: 0, max threads: 16
|
|
287
|
-
* Environment: development
|
|
288
|
-
* Listening on tcp://0.0.0.0:8888
|
|
289
|
-
^C
|
|
290
295
|
|
|
291
|
-
|
|
296
|
+
run container again:
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest
|
|
300
|
+
oxidized[1]: Oxidized starting, running as pid 1
|
|
301
|
+
oxidized[1]: Loaded 1 nodes
|
|
302
|
+
Puma 2.13.4 starting...
|
|
303
|
+
* Min threads: 0, max threads: 16
|
|
304
|
+
* Environment: development
|
|
305
|
+
* Listening on tcp://0.0.0.0:8888
|
|
292
306
|
```
|
|
293
307
|
|
|
294
308
|
If you want to have the config automatically reloaded (e.g. when using a http source that changes)
|
|
309
|
+
|
|
295
310
|
```
|
|
296
|
-
|
|
311
|
+
docker run -v /etc/oxidized:/root/.config/oxidized -p 8888:8888/tcp -e CONFIG_RELOAD_INTERVAL=3600 -t oxidized/oxidized:latest
|
|
297
312
|
```
|
|
298
313
|
|
|
299
314
|
## Cookbook
|
|
@@ -386,6 +401,31 @@ vars_map:
|
|
|
386
401
|
ssh_proxy: 3
|
|
387
402
|
...
|
|
388
403
|
```
|
|
404
|
+
### Source: SQL
|
|
405
|
+
Oxidized uses the `sequel` ruby gem. You can use a variety of databases that aren't explicitly listed. For more information visit https://github.com/jeremyevans/sequel Make sure you have the correct adapter!
|
|
406
|
+
### Source: MYSQL
|
|
407
|
+
|
|
408
|
+
```sudo apt-get install libmysqlclient-dev```
|
|
409
|
+
|
|
410
|
+
The values correspond to your fields in the DB such that ip, model, etc are field names in the DB
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
source:
|
|
414
|
+
default: sql
|
|
415
|
+
sql:
|
|
416
|
+
adapter: mysql2
|
|
417
|
+
database: oxidized
|
|
418
|
+
table: nodes
|
|
419
|
+
username: root
|
|
420
|
+
password: rootpass
|
|
421
|
+
map:
|
|
422
|
+
name: ip
|
|
423
|
+
model: model
|
|
424
|
+
username: username
|
|
425
|
+
password: password
|
|
426
|
+
vars_map:
|
|
427
|
+
enable: enable
|
|
428
|
+
```
|
|
389
429
|
|
|
390
430
|
### Source: SQLite
|
|
391
431
|
|
|
@@ -420,6 +460,8 @@ source:
|
|
|
420
460
|
url: https://url/api
|
|
421
461
|
scheme: https
|
|
422
462
|
delimiter: !ruby/regexp /:/
|
|
463
|
+
user: username
|
|
464
|
+
pass: password
|
|
423
465
|
map:
|
|
424
466
|
name: hostname
|
|
425
467
|
model: os
|
|
@@ -510,7 +552,7 @@ output:
|
|
|
510
552
|
|
|
511
553
|
### Output types
|
|
512
554
|
|
|
513
|
-
If you prefer to have different outputs in different files and/or directories, you can easily do this by modifying the corresponding model. To change the behaviour for IOS, you would edit `lib/oxidized/model/ios.rb
|
|
555
|
+
If you prefer to have different outputs in different files and/or directories, you can easily do this by modifying the corresponding model. To change the behaviour for IOS, you would edit `lib/oxidized/model/ios.rb` (run `gem contents oxidized` to find out the full file path).
|
|
514
556
|
|
|
515
557
|
For example, let's say you want to split out `show version` and `show inventory` into separate files in a directory called `nodiff` which your tools will not send automated diffstats for. You can apply a patch along the lines of
|
|
516
558
|
|
|
@@ -570,7 +612,7 @@ rest: 10.0.0.1:8000/oxidized
|
|
|
570
612
|
|
|
571
613
|
### Advanced Configuration
|
|
572
614
|
|
|
573
|
-
Below is an advanced example configuration. You will be able to (
|
|
615
|
+
Below is an advanced example configuration. You will be able to (optionally) override options per device. The router.db format used is ```hostname:model:username:password:enable_password```. Hostname and model will be the only required options, all others override the global configuration sections.
|
|
574
616
|
|
|
575
617
|
```
|
|
576
618
|
---
|
|
@@ -615,6 +657,28 @@ source:
|
|
|
615
657
|
model_map:
|
|
616
658
|
cisco: ios
|
|
617
659
|
juniper: junos
|
|
660
|
+
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Advanced Group Configuration
|
|
664
|
+
|
|
665
|
+
For group specific credentials
|
|
666
|
+
|
|
667
|
+
```
|
|
668
|
+
groups:
|
|
669
|
+
mikrotik:
|
|
670
|
+
username: admin
|
|
671
|
+
password: blank
|
|
672
|
+
ubiquiti:
|
|
673
|
+
username: ubnt
|
|
674
|
+
password: ubnt
|
|
675
|
+
```
|
|
676
|
+
and add group mapping
|
|
677
|
+
```
|
|
678
|
+
map:
|
|
679
|
+
model: 0
|
|
680
|
+
name: 1
|
|
681
|
+
group: 2
|
|
618
682
|
```
|
|
619
683
|
|
|
620
684
|
# Hooks
|
|
@@ -714,7 +778,7 @@ The following objects exist in Oxidized.
|
|
|
714
778
|
## Input
|
|
715
779
|
* gets config from nodes
|
|
716
780
|
* must implement 'connect', 'get', 'cmd'
|
|
717
|
-
* 'ssh' and '
|
|
781
|
+
* 'ssh', 'telnet, ftp, and tftp' implemented
|
|
718
782
|
|
|
719
783
|
## Output
|
|
720
784
|
* stores config
|
data/Rakefile
CHANGED
|
@@ -19,10 +19,10 @@ task :test do
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
desc 'Install gem'
|
|
23
|
-
task :install => :build do
|
|
24
|
-
|
|
25
|
-
end
|
|
22
|
+
## desc 'Install gem'
|
|
23
|
+
## task :install => :build do
|
|
24
|
+
## system "sudo -Es sh -c \'umask 022; gem install gems/#{file}\'"
|
|
25
|
+
## end
|
|
26
26
|
|
|
27
27
|
desc 'Remove gems'
|
|
28
28
|
task :clean do
|
data/bin/oxidized
CHANGED
data/extra/rest_client.rb
CHANGED
|
@@ -2,8 +2,30 @@ module Oxidized
|
|
|
2
2
|
class RestClient
|
|
3
3
|
require 'net/http'
|
|
4
4
|
require 'json'
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
require 'uri'
|
|
6
|
+
require 'asetus'
|
|
7
|
+
|
|
8
|
+
class Config
|
|
9
|
+
Root = Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
CFGS = Asetus.new :name=>'oxidized', :load=>false, :key_to_s=>true
|
|
13
|
+
CFGS.default.rest = '127.0.0.1:8888'
|
|
14
|
+
|
|
15
|
+
begin
|
|
16
|
+
CFGS.load
|
|
17
|
+
rescue => error
|
|
18
|
+
raise InvalidConfig, "Error loading config: #{error.message}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
restcfg = CFGS.cfg.rest
|
|
22
|
+
unless restcfg.match(/^http:\/\//)
|
|
23
|
+
restcfg.insert(0, 'http://')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
HOST = URI(restcfg).host
|
|
27
|
+
PORT = URI(restcfg).port
|
|
28
|
+
PATH = URI(restcfg).path
|
|
7
29
|
|
|
8
30
|
class << self
|
|
9
31
|
def next opt={}, host=HOST, port=PORT
|
|
@@ -18,7 +40,7 @@ module Oxidized
|
|
|
18
40
|
|
|
19
41
|
def next opt
|
|
20
42
|
data = JSON.dump opt
|
|
21
|
-
@web.put '/node/next/' + opt[:name].to_s, data
|
|
43
|
+
@web.put PATH + '/node/next/' + opt[:name].to_s, data
|
|
22
44
|
end
|
|
23
45
|
|
|
24
46
|
end
|
data/lib/oxidized/input/cli.rb
CHANGED
data/lib/oxidized/input/ssh.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Oxidized
|
|
|
42
42
|
unless @exec
|
|
43
43
|
shell_open @ssh
|
|
44
44
|
begin
|
|
45
|
-
|
|
45
|
+
login
|
|
46
46
|
rescue Timeout::Error
|
|
47
47
|
raise PromptUndetect, [ @output, 'not matching configured prompt', @node.prompt ].join(' ')
|
|
48
48
|
end
|
|
@@ -102,13 +102,18 @@ module Oxidized
|
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
# some models have SSH auth or terminal auth based on version of code
|
|
106
|
+
# if SSH is configured for terminal auth, we'll still try to detect prompt
|
|
107
|
+
def login
|
|
108
|
+
if @username
|
|
109
|
+
match = expect username, @node.prompt
|
|
110
|
+
if match == username
|
|
111
|
+
cmd @node.auth[:username], password
|
|
112
|
+
cmd @node.auth[:password]
|
|
113
|
+
end
|
|
114
|
+
else
|
|
115
|
+
expect @node.prompt
|
|
116
|
+
end
|
|
112
117
|
end
|
|
113
118
|
|
|
114
119
|
def exec state=nil
|
|
@@ -123,14 +128,18 @@ module Oxidized
|
|
|
123
128
|
@output
|
|
124
129
|
end
|
|
125
130
|
|
|
126
|
-
def expect
|
|
127
|
-
|
|
131
|
+
def expect *regexps
|
|
132
|
+
regexps = [regexps].flatten
|
|
133
|
+
Oxidized.logger.debug "lib/oxidized/input/ssh.rb: expecting #{regexps.inspect} at #{node.name}"
|
|
128
134
|
Timeout::timeout(Oxidized.config.timeout) do
|
|
129
135
|
@ssh.loop(0.1) do
|
|
130
136
|
sleep 0.1
|
|
131
|
-
|
|
137
|
+
match = regexps.find { |regexp| @output.match regexp }
|
|
138
|
+
return match if match
|
|
139
|
+
true
|
|
132
140
|
end
|
|
133
141
|
end
|
|
134
142
|
end
|
|
143
|
+
|
|
135
144
|
end
|
|
136
145
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Oxidized
|
|
2
|
+
require 'stringio'
|
|
3
|
+
require_relative 'cli'
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'net/tftp'
|
|
7
|
+
rescue LoadError
|
|
8
|
+
raise OxidizedError, 'net/tftp not found: sudo gem install net-tftp'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class TFTP < Input
|
|
12
|
+
|
|
13
|
+
include Input::CLI
|
|
14
|
+
|
|
15
|
+
# TFTP utilizes UDP, there is not a connection. We simply specify an IP and send/receive data.
|
|
16
|
+
def connect node
|
|
17
|
+
@node = node
|
|
18
|
+
|
|
19
|
+
@node.model.cfg['tftp'].each { |cb| instance_exec(&cb) }
|
|
20
|
+
@log = File.open(Oxidized::Config::Log + "/#{@node.ip}-tftp", 'w') if Oxidized.config.input.debug?
|
|
21
|
+
@tftp = Net::TFTP.new @node.ip
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def cmd file
|
|
25
|
+
Oxidized.logger.debug "TFTP: #{file} @ #{@node.name}"
|
|
26
|
+
config = StringIO.new
|
|
27
|
+
@tftp.getbinary file, config
|
|
28
|
+
config.rewind
|
|
29
|
+
config.read
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def disconnect
|
|
35
|
+
# TFTP uses UDP, there is no connection to close
|
|
36
|
+
ensure
|
|
37
|
+
@log.close if Oxidized.config.input.debug?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/oxidized/model/acos.rb
CHANGED
|
@@ -6,6 +6,13 @@ class ACOS < Oxidized::Model
|
|
|
6
6
|
##ACOS prompt changes depending on the state of the device
|
|
7
7
|
prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/
|
|
8
8
|
|
|
9
|
+
cmd :secret do |cfg|
|
|
10
|
+
cfg.gsub!(/community read encrypted (\S+)/, 'community read encrypted <hidden>') # snmp
|
|
11
|
+
cfg.gsub!(/secret encrypted (\S+)/, 'secret encrypted <hidden>') # tacacs-server
|
|
12
|
+
cfg.gsub!(/password encrypted (\S+)/, 'password encrypted <hidden>') # user
|
|
13
|
+
cfg
|
|
14
|
+
end
|
|
15
|
+
|
|
9
16
|
cmd 'show version' do |cfg|
|
|
10
17
|
cfg.gsub! /\s(Last configuration saved at).*/, ' \\1 <removed>'
|
|
11
18
|
cfg.gsub! /\s(Memory).*/, ' \\1 <removed>'
|
|
@@ -22,11 +29,20 @@ class ACOS < Oxidized::Model
|
|
|
22
29
|
comment cfg
|
|
23
30
|
end
|
|
24
31
|
|
|
32
|
+
cmd 'show partition-config all' do |cfg|
|
|
33
|
+
cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
|
|
34
|
+
cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
|
|
35
|
+
cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
|
|
36
|
+
cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
|
|
37
|
+
cfg
|
|
38
|
+
end
|
|
39
|
+
|
|
25
40
|
cmd 'show running-config all-partitions' do |cfg|
|
|
26
41
|
cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
|
|
27
42
|
cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
|
|
28
43
|
cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
|
|
29
44
|
cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
|
|
45
|
+
cfg
|
|
30
46
|
end
|
|
31
47
|
|
|
32
48
|
cmd 'show aflex all-partitions' do |cfg|
|
data/lib/oxidized/model/asa.rb
CHANGED
|
@@ -13,6 +13,9 @@ class ASA < Oxidized::Model
|
|
|
13
13
|
cmd :secret do |cfg|
|
|
14
14
|
cfg.gsub! /enable password (\S+) (.*)/, 'enable password <secret hidden> \2'
|
|
15
15
|
cfg.gsub! /username (\S+) password (\S+) (.*)/, 'username \1 password <secret hidden> \3'
|
|
16
|
+
cfg.gsub! /ikev2 pre-shared-key (\S+)/, 'ikev2 pre-shared-key <secret hidden>'
|
|
17
|
+
cfg.gsub! /ikev2 (remote|local)-authentication pre-shared-key (\S+)/, 'ikev2 \1-authentication pre-shared-key <secret hidden>'
|
|
18
|
+
cfg.gsub! /^(aaa-server TACACS\+? \(\S+\) host.*\n\skey) \S+$/mi, '\1 <secret hidden>'
|
|
16
19
|
cfg
|
|
17
20
|
end
|
|
18
21
|
|
data/lib/oxidized/model/catos.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Catos < Oxidized::Model
|
|
2
2
|
|
|
3
|
-
prompt /^[\w.@-]
|
|
3
|
+
prompt /^[\w.@-]+>\s?(\(enable\) )?$/
|
|
4
4
|
comment '# '
|
|
5
5
|
|
|
6
6
|
cmd :all do |cfg|
|
|
@@ -28,8 +28,15 @@ class Catos < Oxidized::Model
|
|
|
28
28
|
password /^Password:/
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
cfg :
|
|
31
|
+
cfg :telnet, :ssh do
|
|
32
32
|
post_login 'set length 0'
|
|
33
|
+
# preferred way to handle additional passwords
|
|
34
|
+
if vars :enable
|
|
35
|
+
post_login do
|
|
36
|
+
send "enable\n"
|
|
37
|
+
cmd vars(:enable)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
33
40
|
pre_logout 'exit'
|
|
34
41
|
end
|
|
35
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Cumulus < Oxidized::Model
|
|
2
2
|
|
|
3
|
-
prompt /^((\w*)@(.*)
|
|
3
|
+
prompt /^((\w*)@(.*)):/
|
|
4
4
|
comment '# '
|
|
5
5
|
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ class Cumulus < Oxidized::Model
|
|
|
22
22
|
cfg += cmd 'cat /etc/hosts'
|
|
23
23
|
|
|
24
24
|
cfg += add_comment 'THE INTERFACES'
|
|
25
|
-
cfg += cmd '
|
|
25
|
+
cfg += cmd 'grep -r "" /etc/network/interface* | cut -d "/" -f 4-'
|
|
26
26
|
|
|
27
27
|
cfg += add_comment 'RESOLV.CONF'
|
|
28
28
|
cfg += cmd 'cat /etc/resolv.conf'
|
|
@@ -30,6 +30,9 @@ class Cumulus < Oxidized::Model
|
|
|
30
30
|
cfg += add_comment 'NTP.CONF'
|
|
31
31
|
cfg += cmd 'cat /etc/ntp.conf'
|
|
32
32
|
|
|
33
|
+
cfg += add_comment 'IP Routes'
|
|
34
|
+
cfg += cmd 'netstat -rn'
|
|
35
|
+
|
|
33
36
|
cfg += add_comment 'QUAGGA DAEMONS'
|
|
34
37
|
cfg += cmd 'cat /etc/quagga/daemons'
|
|
35
38
|
|
|
@@ -55,10 +58,13 @@ class Cumulus < Oxidized::Model
|
|
|
55
58
|
cfg += cmd 'cat /etc/cumulus/switchd.conf'
|
|
56
59
|
|
|
57
60
|
cfg += add_comment 'ACL'
|
|
58
|
-
cfg += cmd 'iptables -L'
|
|
61
|
+
cfg += cmd 'iptables -L -n'
|
|
59
62
|
|
|
60
63
|
cfg += add_comment 'VERSION'
|
|
61
64
|
cfg += cmd 'cat /etc/cumulus/etc.replace/os-release'
|
|
65
|
+
|
|
66
|
+
cfg += add_comment 'License'
|
|
67
|
+
cfg += cmd 'cl-license'
|
|
62
68
|
|
|
63
69
|
end
|
|
64
70
|
|
|
@@ -73,4 +79,4 @@ class Cumulus < Oxidized::Model
|
|
|
73
79
|
end
|
|
74
80
|
|
|
75
81
|
|
|
76
|
-
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class PfSense < Oxidized::Model
|
|
2
|
+
|
|
3
|
+
# use other use than 'admin' user, 'admin' user cannot get ssh/exec. See issue #535
|
|
4
|
+
|
|
5
|
+
cmd :all do |cfg|
|
|
6
|
+
cfg.each_line.to_a[1..-2].join
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
cmd 'cat /cf/conf/config.xml' do |cfg|
|
|
10
|
+
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
cfg :ssh do
|
|
14
|
+
exec true
|
|
15
|
+
pre_logout 'exit'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class RouterOS < Oxidized::Model
|
|
2
|
-
prompt /\[\w+@\S
|
|
2
|
+
prompt /\[\w+@\S+(\s?\S+)*\]\s?>\s?$/
|
|
3
3
|
comment "# "
|
|
4
4
|
|
|
5
5
|
cmd '/system routerboard print' do |cfg|
|
|
@@ -8,6 +8,7 @@ class RouterOS < Oxidized::Model
|
|
|
8
8
|
|
|
9
9
|
cmd '/export' do |cfg|
|
|
10
10
|
cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours
|
|
11
|
+
cfg.gsub! /\\\r\n\s+/, '' # strip new line
|
|
11
12
|
cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
|
|
12
13
|
cfg.join("\n") + "\n"
|
|
13
14
|
end
|
data/lib/oxidized/model/saos.rb
CHANGED
|
@@ -17,8 +17,10 @@ class SAOS < Oxidized::Model
|
|
|
17
17
|
username /login:/
|
|
18
18
|
password /assword:/
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
cfg :telnet, :ssh do
|
|
22
|
+
post_login 'system shell set more off'
|
|
21
23
|
post_login 'system shell session set more off'
|
|
22
24
|
pre_logout 'exit'
|
|
23
25
|
end
|
|
24
|
-
end
|
|
26
|
+
end
|
data/lib/oxidized/model/timos.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
class TiMOS < Oxidized::Model
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
|
|
3
|
+
#
|
|
4
|
+
# Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent).
|
|
5
|
+
# Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP.
|
|
6
|
+
#
|
|
7
|
+
|
|
6
8
|
comment '# '
|
|
7
9
|
|
|
8
10
|
prompt /^([-\w\.:>\*]+\s?[#>]\s?)$/
|
|
@@ -12,26 +14,81 @@ class TiMOS < Oxidized::Model
|
|
|
12
14
|
new_cfg << cfg.each_line.to_a[1..-2].join
|
|
13
15
|
end
|
|
14
16
|
|
|
17
|
+
#
|
|
18
|
+
# Show the boot options file.
|
|
19
|
+
#
|
|
15
20
|
cmd 'show bof' do |cfg|
|
|
16
21
|
comment cfg
|
|
17
22
|
end
|
|
18
23
|
|
|
24
|
+
#
|
|
25
|
+
# Show the system information.
|
|
26
|
+
#
|
|
19
27
|
cmd 'show system information' do |cfg|
|
|
20
|
-
#
|
|
28
|
+
#
|
|
29
|
+
# Strip uptime.
|
|
30
|
+
#
|
|
21
31
|
cfg.sub! /^System Up Time.*\n/, ''
|
|
22
32
|
comment cfg
|
|
23
33
|
end
|
|
24
34
|
|
|
35
|
+
#
|
|
36
|
+
# Show the card state.
|
|
37
|
+
#
|
|
25
38
|
cmd 'show card state' do |cfg|
|
|
26
39
|
comment cfg
|
|
27
40
|
end
|
|
28
41
|
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
#
|
|
43
|
+
# Show the boot log.
|
|
44
|
+
#
|
|
45
|
+
cmd 'file type bootlog.txt' do |cfg|
|
|
46
|
+
#
|
|
47
|
+
# Strip carriage returns and backspaces.
|
|
48
|
+
#
|
|
49
|
+
cfg.gsub! /\r/, ''
|
|
50
|
+
cfg.gsub! /[\b][\b][\b]/, "\n"
|
|
51
|
+
comment cfg
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# Show the running debug configuration.
|
|
56
|
+
#
|
|
57
|
+
cmd 'show debug' do |cfg|
|
|
31
58
|
comment cfg
|
|
32
59
|
end
|
|
33
60
|
|
|
34
|
-
|
|
61
|
+
#
|
|
62
|
+
# Show the saved debug configuration (admin debug-save).
|
|
63
|
+
#
|
|
64
|
+
cmd 'file type config.dbg' do |cfg|
|
|
65
|
+
#
|
|
66
|
+
# Strip carriage returns.
|
|
67
|
+
#
|
|
68
|
+
cfg.gsub! /\r/, ''
|
|
69
|
+
comment cfg
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# Show the running persistent indices.
|
|
74
|
+
#
|
|
75
|
+
cmd 'admin display-config index' do |cfg|
|
|
76
|
+
#
|
|
77
|
+
# Strip carriage returns.
|
|
78
|
+
#
|
|
79
|
+
cfg.gsub! /\r/, ''
|
|
80
|
+
comment cfg
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# Show the running configuration.
|
|
85
|
+
#
|
|
86
|
+
cmd 'admin display-config' do |cfg|
|
|
87
|
+
#
|
|
88
|
+
# Strip carriage returns.
|
|
89
|
+
#
|
|
90
|
+
cfg.gsub! /\r/, ''
|
|
91
|
+
end
|
|
35
92
|
|
|
36
93
|
cfg :telnet do
|
|
37
94
|
username /^Login: /
|
data/lib/oxidized/node.rb
CHANGED
|
@@ -128,24 +128,15 @@ module Oxidized
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def resolve_auth opt
|
|
131
|
-
# Resolve configured username/password
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
elsif ['username', 'password'].all? {|e| Oxidized.config.has_key?(e)}
|
|
137
|
-
[Oxidized.config.username, Oxidized.config.password]
|
|
138
|
-
else
|
|
139
|
-
[nil, nil]
|
|
140
|
-
end
|
|
141
|
-
auth = {}
|
|
142
|
-
auth[:username] = (opt[:username] or cfg_username)
|
|
143
|
-
auth[:password] = (opt[:password] or cfg_password)
|
|
144
|
-
auth
|
|
131
|
+
# Resolve configured username/password
|
|
132
|
+
{
|
|
133
|
+
username: resolve_key(:username, opt),
|
|
134
|
+
password: resolve_key(:password, opt),
|
|
135
|
+
}
|
|
145
136
|
end
|
|
146
137
|
|
|
147
138
|
def resolve_input opt
|
|
148
|
-
inputs =
|
|
139
|
+
inputs = resolve_key :input, opt, Oxidized.config.input.default
|
|
149
140
|
inputs.split(/\s*,\s*/).map do |input|
|
|
150
141
|
if not Oxidized.mgr.input[input]
|
|
151
142
|
Oxidized.mgr.add_input input or raise MethodNotFound, "#{input} not found for node #{ip}"
|
|
@@ -155,7 +146,7 @@ module Oxidized
|
|
|
155
146
|
end
|
|
156
147
|
|
|
157
148
|
def resolve_output opt
|
|
158
|
-
output =
|
|
149
|
+
output = resolve_key :output, opt, Oxidized.config.output.default
|
|
159
150
|
if not Oxidized.mgr.output[output]
|
|
160
151
|
Oxidized.mgr.add_output output or raise MethodNotFound, "#{output} not found for node #{ip}"
|
|
161
152
|
end
|
|
@@ -163,7 +154,7 @@ module Oxidized
|
|
|
163
154
|
end
|
|
164
155
|
|
|
165
156
|
def resolve_model opt
|
|
166
|
-
model =
|
|
157
|
+
model = resolve_key :model, opt
|
|
167
158
|
if not Oxidized.mgr.model[model]
|
|
168
159
|
Oxidized.logger.debug "lib/oxidized/node.rb: Loading model #{model.inspect}"
|
|
169
160
|
Oxidized.mgr.add_model model or raise ModelNotFound, "#{model} not found for node #{ip}"
|
|
@@ -187,6 +178,33 @@ module Oxidized
|
|
|
187
178
|
end
|
|
188
179
|
end
|
|
189
180
|
|
|
181
|
+
def resolve_key key, opt, global=nil
|
|
182
|
+
# resolve key, first get global, then get group then get node config
|
|
183
|
+
key_sym = key.to_sym
|
|
184
|
+
key_str = key.to_s
|
|
185
|
+
value = global
|
|
186
|
+
Oxidized.logger.debug "node.rb: resolving node key '#{key}', with passed global value of '#{value}' and node value '#{opt[key_sym]}'"
|
|
187
|
+
|
|
188
|
+
#global
|
|
189
|
+
if not value and Oxidized.config.has_key?(key_str)
|
|
190
|
+
value = Oxidized.config[key_str]
|
|
191
|
+
Oxidized.logger.debug "node.rb: setting node key '#{key}' to value '#{value}' from global"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
#group
|
|
195
|
+
if Oxidized.config.groups.has_key?(@group)
|
|
196
|
+
if Oxidized.config.groups[@group].has_key?(key_str)
|
|
197
|
+
value = Oxidized.config.groups[@group][key_str]
|
|
198
|
+
Oxidized.logger.debug "node.rb: setting node key '#{key}' to value '#{value}' from group"
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
#node
|
|
203
|
+
value = opt[key_sym] || value
|
|
204
|
+
Oxidized.logger.debug "node.rb: returning node key '#{key}' with value '#{value}'"
|
|
205
|
+
value
|
|
206
|
+
end
|
|
207
|
+
|
|
190
208
|
def is_git? opt
|
|
191
209
|
(opt[:output] || Oxidized.config.output.default) == 'git'
|
|
192
210
|
end
|
data/lib/oxidized/output/file.rb
CHANGED
|
@@ -17,7 +17,7 @@ class OxidizedFile < Output
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def store node, outputs, opt={}
|
|
20
|
-
file = @cfg.directory
|
|
20
|
+
file = File.expand_path @cfg.directory
|
|
21
21
|
if opt[:group]
|
|
22
22
|
file = File.join File.dirname(file), opt[:group]
|
|
23
23
|
end
|
|
@@ -28,14 +28,16 @@ class OxidizedFile < Output
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def fetch node, group
|
|
31
|
-
cfg_dir = @cfg.directory
|
|
31
|
+
cfg_dir = File.expand_path @cfg.directory
|
|
32
|
+
node_name = node.name
|
|
33
|
+
|
|
32
34
|
if group # group is explicitly defined by user
|
|
33
|
-
IO.readlines File.join(cfg_dir, group,
|
|
35
|
+
IO.readlines File.join(cfg_dir, group, node_name)
|
|
34
36
|
else
|
|
35
|
-
if File.exists? File.join(cfg_dir,
|
|
36
|
-
IO.readlines File.join(cfg_dir,
|
|
37
|
+
if File.exists? File.join(cfg_dir, node_name) # node configuration file is stored on base directory
|
|
38
|
+
IO.readlines File.join(cfg_dir, node_name)
|
|
37
39
|
else
|
|
38
|
-
path = Dir.glob File.join(cfg_dir, '**',
|
|
40
|
+
path = Dir.glob File.join(cfg_dir, '**', node_name) # fetch node in all groups
|
|
39
41
|
return nil if path[0].nil?
|
|
40
42
|
open(path[0], 'r').readlines
|
|
41
43
|
end
|
data/lib/oxidized/source/csv.rb
CHANGED
|
@@ -20,7 +20,7 @@ class CSV < Source
|
|
|
20
20
|
nodes = []
|
|
21
21
|
open(File.expand_path @cfg.file).each_line do |line|
|
|
22
22
|
next if line.match(/^\s*#/)
|
|
23
|
-
data = line.chomp.split
|
|
23
|
+
data = line.chomp.split(@cfg.delimiter, -1)
|
|
24
24
|
next if data.empty?
|
|
25
25
|
# map node parameters
|
|
26
26
|
keys = {}
|
|
@@ -29,9 +29,11 @@ class CSV < Source
|
|
|
29
29
|
end
|
|
30
30
|
keys[:model] = map_model keys[:model] if keys.key? :model
|
|
31
31
|
|
|
32
|
-
# map node specific vars
|
|
32
|
+
# map node specific vars
|
|
33
33
|
vars = {}
|
|
34
|
-
@cfg.vars_map.each
|
|
34
|
+
@cfg.vars_map.each do |key, position|
|
|
35
|
+
vars[key.to_sym] = node_var_interpolate data[position]
|
|
36
|
+
end
|
|
35
37
|
keys[:vars] = vars unless vars.empty?
|
|
36
38
|
|
|
37
39
|
nodes << keys
|
data/lib/oxidized/source/http.rb
CHANGED
|
@@ -43,9 +43,11 @@ class HTTP < Source
|
|
|
43
43
|
end
|
|
44
44
|
keys[:model] = map_model keys[:model] if keys.key? :model
|
|
45
45
|
|
|
46
|
-
# map node specific vars
|
|
46
|
+
# map node specific vars
|
|
47
47
|
vars = {}
|
|
48
|
-
@cfg.vars_map.each
|
|
48
|
+
@cfg.vars_map.each do |key, position|
|
|
49
|
+
vars[key.to_sym] = node_var_interpolate line[position]
|
|
50
|
+
end
|
|
49
51
|
keys[:vars] = vars unless vars.empty?
|
|
50
52
|
|
|
51
53
|
nodes << keys
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
module Oxidized
|
|
2
2
|
class Source
|
|
3
3
|
class NoConfig < OxidizedError; end
|
|
4
|
+
|
|
4
5
|
def initialize
|
|
5
6
|
@map = (Oxidized.config.model_map or {})
|
|
6
7
|
end
|
|
8
|
+
|
|
7
9
|
def map_model model
|
|
8
10
|
@map.has_key?(model) ? @map[model] : model
|
|
9
11
|
end
|
|
12
|
+
|
|
13
|
+
def node_var_interpolate var
|
|
14
|
+
case var
|
|
15
|
+
when "nil" then nil
|
|
16
|
+
when "false" then false
|
|
17
|
+
when "true" then true
|
|
18
|
+
else var
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
10
22
|
end
|
|
11
23
|
end
|
data/lib/oxidized/source/sql.rb
CHANGED
|
@@ -31,7 +31,9 @@ class SQL < Source
|
|
|
31
31
|
|
|
32
32
|
# map node specific vars
|
|
33
33
|
vars = {}
|
|
34
|
-
@cfg.vars_map.each
|
|
34
|
+
@cfg.vars_map.each do |key, sql_column|
|
|
35
|
+
vars[key.to_sym] = node_var_interpolate node[sql_column.to_sym]
|
|
36
|
+
end
|
|
35
37
|
keys[:vars] = vars unless vars.empty?
|
|
36
38
|
|
|
37
39
|
nodes << keys
|
data/lib/oxidized/version.rb
CHANGED
data/lib/oxidized.rb
CHANGED
data/oxidized.gemspec
CHANGED
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.required_ruby_version = '>= 2.0.0'
|
|
22
22
|
s.add_runtime_dependency 'asetus', '~> 0.1'
|
|
23
23
|
s.add_runtime_dependency 'slop', '~> 3.5'
|
|
24
|
-
s.add_runtime_dependency 'net-ssh', '
|
|
24
|
+
s.add_runtime_dependency 'net-ssh', '~> 3.0.2'
|
|
25
25
|
s.add_runtime_dependency 'rugged', '~> 0.21', '>= 0.21.4'
|
|
26
26
|
|
|
27
27
|
if defined?(RUBY_VERSION) && RUBY_VERSION > '2.3'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oxidized
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Saku Ytti
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2016-
|
|
13
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: asetus
|
|
@@ -44,22 +44,16 @@ dependencies:
|
|
|
44
44
|
name: net-ssh
|
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
|
46
46
|
requirements:
|
|
47
|
-
- - "
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
49
|
-
version: 3.0.0
|
|
50
|
-
- - "<"
|
|
47
|
+
- - "~>"
|
|
51
48
|
- !ruby/object:Gem::Version
|
|
52
|
-
version:
|
|
49
|
+
version: 3.0.2
|
|
53
50
|
type: :runtime
|
|
54
51
|
prerelease: false
|
|
55
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
53
|
requirements:
|
|
57
|
-
- - "
|
|
58
|
-
- !ruby/object:Gem::Version
|
|
59
|
-
version: 3.0.0
|
|
60
|
-
- - "<"
|
|
54
|
+
- - "~>"
|
|
61
55
|
- !ruby/object:Gem::Version
|
|
62
|
-
version:
|
|
56
|
+
version: 3.0.2
|
|
63
57
|
- !ruby/object:Gem::Dependency
|
|
64
58
|
name: rugged
|
|
65
59
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -211,12 +205,14 @@ files:
|
|
|
211
205
|
- lib/oxidized/input/input.rb
|
|
212
206
|
- lib/oxidized/input/ssh.rb
|
|
213
207
|
- lib/oxidized/input/telnet.rb
|
|
208
|
+
- lib/oxidized/input/tftp.rb
|
|
214
209
|
- lib/oxidized/job.rb
|
|
215
210
|
- lib/oxidized/jobs.rb
|
|
216
211
|
- lib/oxidized/manager.rb
|
|
217
212
|
- lib/oxidized/model/acos.rb
|
|
218
213
|
- lib/oxidized/model/aireos.rb
|
|
219
214
|
- lib/oxidized/model/airos.rb
|
|
215
|
+
- lib/oxidized/model/alvarion
|
|
220
216
|
- lib/oxidized/model/aos.rb
|
|
221
217
|
- lib/oxidized/model/aos7.rb
|
|
222
218
|
- lib/oxidized/model/aosw.rb
|
|
@@ -256,6 +252,7 @@ files:
|
|
|
256
252
|
- lib/oxidized/model/opengear.rb
|
|
257
253
|
- lib/oxidized/model/outputs.rb
|
|
258
254
|
- lib/oxidized/model/panos.rb
|
|
255
|
+
- lib/oxidized/model/pfsense.rb
|
|
259
256
|
- lib/oxidized/model/powerconnect.rb
|
|
260
257
|
- lib/oxidized/model/procurve.rb
|
|
261
258
|
- lib/oxidized/model/quantaos.rb
|