diff options
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | README.md | 57 | ||||
-rw-r--r-- | lib/oxidized/config/vars.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/model/asa.rb | 48 | ||||
-rw-r--r-- | lib/oxidized/model/fabricos.rb | 21 | ||||
-rw-r--r-- | lib/oxidized/model/vyatta.rb | 27 | ||||
-rw-r--r-- | lib/oxidized/string.rb | 4 | ||||
-rw-r--r-- | oxidized.gemspec | 2 |
8 files changed, 163 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..911a961 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# 0.2.0 +- FEATURE: Force10 model added by @lysiszegerman +- FEATURE: FabricOS model added by @thakala +- FEATURE: ASA model added by @thakala +- BUGFIX: Oxidized::String convenience methods for models fixed + +# 0.1.1 +- BUGFIX: vars needs to return value of r, not value of evaluation @@ -8,8 +8,29 @@ * restful API to fetch configurations (/node/fetch/[NODE] or /node/fetch/group/[NODE]) * restful API to show list of nodes (GET /nodes) +# Supported OS types + + * A10 Networks ACOS + * Alcatel-Lucent Operating System AOS + * Alcatel-Lucent Operating System AOS7 + * Alcatel-Lucent Operating System Wireless + * Alcatel-Lucent TiMOS + * Arista EOS + * Brocade Fabric OS + * Brocade Ironware + * Cisco AireOS + * Cisco ASA + * Cisco IOS + * Cisco IOS-XR + * DELL PowerConnect + * Force10 FTOS + * FortiGate FortiOS + * HP ProCurve + * Juniper JunOS + # Install - * early days, but try: + + * Debian 1. apt-get install ruby ruby-dev libsqlite3-dev libssl-dev 2. gem install oxidized 3. gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config @@ -18,6 +39,38 @@ 6. (maybe point to your rancid/router.db or copy it there) 7. oxidized + * CentOS, Oracle Linux, Red Hat Linux version 6 + 1. Install Ruby 1.9.3 or greater + * For Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM" + 2. Install Oxidized dependencies + * yum install cmake sqlite-devel openssl-devel + 3. Install Oxidized daemon and Web front-end from Ruby Gems + * gem install oxidized + * gem install oxidized-script oxidized-web + 4. Start Oxidized, this will create initial configuration + * oxidized + 5. Edit Oxidized configuration and create device database + * vi ~/.config/oxidized/config + * vi ~/.config/oxidized/router.db + 6. If you are using file system storage create config directory + * mkdir -p ~/.config/oxidized/configs/default + 7. Start Oxidized + * oxidized + + * Installing Ruby 2.1.2 using RVM + 1. Install Ruby 2.1.2 build dependencies + * yum install curl gcc-c++ patch readline readline-devel zlib zlib-devel + * yum install libyaml-devel libffi-devel openssl-devel make cmake + * yum install bzip2 autoconf automake libtool bison iconv-devel + 2. Install RVM + * curl -L get.rvm.io | bash -s stable + 3. Setup RVM environment + * source /etc/profile.d/rvm.sh + 4. Compile and install Ruby 2.1.2 + * rvm install 2.1.2 + 5. Set Ruby 2.1.2 as default + * rvm use --default 2.1.2 + # API ## Input * gets config from nodes @@ -67,7 +120,7 @@ source: default: sql sql: adapter: sqlite - file: "/usr/local/lan/corona.db" + database: "/usr/local/lan/corona.db" table: device map: name: ptr diff --git a/lib/oxidized/config/vars.rb b/lib/oxidized/config/vars.rb index 40e4808..1fd81ef 100644 --- a/lib/oxidized/config/vars.rb +++ b/lib/oxidized/config/vars.rb @@ -5,5 +5,6 @@ module Oxidized::Config::Vars r = @node.vars[name] unless @node.vars.nil? r ||= Oxidized::CFG.groups[@node.group].vars[name.to_s] if Oxidized::CFG.groups.has_key?(@node.group) r ||= Oxidized::CFG.vars[name.to_s] if Oxidized::CFG.vars.has_key?(name) + r end end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb new file mode 100644 index 0000000..3ee4e2d --- /dev/null +++ b/lib/oxidized/model/asa.rb @@ -0,0 +1,48 @@ +class ASA < Oxidized::Model + + # Cisco ASA model # + # Only SSH supported for the sake of security + + prompt /^\r*([\w]+[#>]\s?)$/ + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub! /enable password (\S+) (.*)/, 'enable password <secret hidden> \2' + cfg.gsub! /username (\S+) password (\S+) (.*)/, 'username \1 password <secret hidden> \3' + cfg + end + + cmd 'show clock' do |cfg| + comment cfg + end + + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[3..-1].join + cfg.gsub! /^: [^\n]*\n/, '' + cfg + end + + cmd 'show inventory' do |cfg| + comment cfg + end + + cfg :ssh do + if vars :enable + post_login do + send "enable\n" + send vars(:enable) + "\n" + end + end + post_login 'terminal pager 0' + pre_logout 'exit' + end + +end diff --git a/lib/oxidized/model/fabricos.rb b/lib/oxidized/model/fabricos.rb new file mode 100644 index 0000000..7ab9fd5 --- /dev/null +++ b/lib/oxidized/model/fabricos.rb @@ -0,0 +1,21 @@ +class FabricOS < Oxidized::Model + + # Brocade Fabric OS model # + ## FIXME: Only ssh exec mode support, no telnet, no ssh screenscraping + + prompt /^([\w]+:+[\w]+[>]\s)$/ + comment '# ' + + cmd 'chassisShow' do |cfg| + comment cfg + end + + cmd 'configShow -all' do |cfg| + cfg + end + + cfg :ssh do + exec true # don't run shell, run each command in exec channel + end + +end diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb new file mode 100644 index 0000000..8d977aa --- /dev/null +++ b/lib/oxidized/model/vyatta.rb @@ -0,0 +1,27 @@ +class Vyatta < Oxidized::Model + + # Brocade Vyatta / VyOS model # + + prompt /\@.*?\:~\$\s/ + + cmd :all do |cfg| + cfg = cfg.lines.to_a[1..-2].join + end + + cmd :secret do |cfg| + cfg.gsub! /community (\S+) {/, 'community <hidden> {' + cfg + end + + cmd 'show configuration | no-more' + + cfg :telnet do + username /login:\s/ + password /^Password:\s/ + end + + cfg :telnet, :ssh do + pre_logout 'exit' + end + +end diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb index bcc393a..35dc5af 100644 --- a/lib/oxidized/string.rb +++ b/lib/oxidized/string.rb @@ -3,11 +3,11 @@ module Oxidized class String < String # @return [Oxidized::String] copy of self with last line removed def cut_tail - Oxy::String.new each_line.to_a[0..-2].join + Oxidized::String.new each_line.to_a[0..-2].join end # @return [Oxidized::String] copy of self with first line removed def cut_head - Oxy::String.new each_line.to_a[1..-1].join + Oxidized::String.new each_line.to_a[1..-1].join end end end diff --git a/oxidized.gemspec b/oxidized.gemspec index 9d8e38f..5c396a2 100644 --- a/oxidized.gemspec +++ b/oxidized.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'oxidized' - s.version = '0.1.0' + s.version = '0.1.1' s.licenses = ['Apache-2.0'] s.platform = Gem::Platform::RUBY s.authors = [ 'Saku Ytti' ] |