https://github.com/ytti/oxidized-script
CLI and LIB for scripting network devices via Oxidized
https://github.com/ytti/oxidized-script
Last synced: about 1 year ago
JSON representation
CLI and LIB for scripting network devices via Oxidized
- Host: GitHub
- URL: https://github.com/ytti/oxidized-script
- Owner: ytti
- Created: 2014-04-13T09:03:23.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T17:18:10.000Z (about 3 years ago)
- Last Synced: 2024-04-26T07:40:56.849Z (about 2 years ago)
- Language: Ruby
- Size: 57.6 KB
- Stars: 41
- Watchers: 18
- Forks: 24
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Oxidized Script
CLI and Library to interface with network devices in Oxidized
## Install
% gem install oxidized-script
## Use
### CLI
```
[fisakytt@lan-login1 ~]% oxs S-2250220 'sh ver'
Jan 29 2010 12:18:24
K.14.54
79
[fisakytt@lan-login1 ~]% cat > cmds
show ip route
[fisakytt@lan-login1 ~]% oxs -x cmds 62.236.123.199
Default gateway is 62.236.123.198
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
[fisakytt@lan-login1 ~]% cat >> cmds
sh ip cef
[fisakytt@lan-login1 ~]% cat cmds|oxs -x- 62.236.123.199
Default gateway is 62.236.123.198
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
%IPv4 CEF not running
[nertwork@lan-login2 ~]% oxs --verbose --group ios --threads 4 --regex ^test 'show vrf'
running list for hosts in group: ios and matching: ^test
## HOST - test-node-1
## OXS - show vrf
Name Default RD Protocols Interfaces
mgmtVRF ipv4,ipv6 Fa1
[fisakytt@lan-login1 ~]% oxs --help
Usage: oxs [options] hostname [command]
-m, --model host model (ios, junos, etc), otherwise discovered from Oxidized source
-o, --ostype OS Type (ios, junos, etc)
-x, --commands commands file to be sent
-u, --username username to use
-p, --password password to use
-t, --timeout timeout value to use
-e, --enable enable password to use
-c, --community snmp community to use for discovery
-g, --group group to run commands on (ios, junos, etc), specified in oxidized db
-r, --threads specify ammount of threads to use for running group (default: 1)
--regex run on all hosts that match the regexp
--dryrun do a dry run on either groups or regexp to find matching hosts
--protocols protocols to use, default "ssh, telnet"
-v, --verbose verbose output, e.g. show commands sent
-d, --debug turn on debugging
--terse display clean output
--list-models list supported models
--list-nodes list nodes in oxidized source
-h, --help Display this help message.
[fisakytt@lan-login1 ~]%
```
### Library
```
[fisakytt@lan-login1 ~]% cat moi42.b
#!/usr/bin/env ruby
require 'oxidized/script'
Oxidized::Config.load
Oxidized.setup_logger
Oxidized::Script.new(:host=>'62.236.123.199') do |oxs|
puts oxs.cmd 'show mac address-table dynamic vlan 101'
end
[fisakytt@lan-login1 ~]% ./moi42.b
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
101 44d3.ca4c.383e DYNAMIC Gi0/1
[fisakytt@lan-login1 ~]%
```
## TODO
* Interactive use?
* Tests+docs, as always :(