Skip to content

Commit

Permalink
Merge branch 'master' into tcrichto/fsos
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcheramy authored Feb 16, 2024
2 parents 9bd2cc7 + 2a6d2ff commit c666131
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Added `linux/arm64` and `linux/amd64` platforms to Docker build/publish. (@disaac)
- Added verion info for Vyatta (@systeembeheerder)
- model for Fibrestore (fs.com) FSOS (@tcrichton)
- model for IP Infusion OcNOS

## Changed
- tp-link: fixed enable mode post login entrance (@mirackle-spb)
Expand Down Expand Up @@ -55,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Fixed pre_logout for BDCOM switches
- Fix 'wpa passphrase' hashed secret for SonicOS devices with built-in wireless #3036 (@lazynooblet)
- Fix potential busy wait when retries and/or next_adds_job is enabled (@gs-kamnas)
- Reverting PR #2498 as it broke old procurve models (2510G, 2610, 2824). Fixes #2833, #2871 (@robertcheramy)

## [0.29.1 - 2023-04-24]

Expand Down
7 changes: 4 additions & 3 deletions docs/Supported-OS-Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
|Arbor Networks |ArbOS |[arbos](/lib/oxidized/model/arbos.rb) | |[ArbOS](Model-Notes/ArbOS.md)
|Arista |EOS |[eos](/lib/oxidized/model/eos.rb) | |[EOS](Model-Notes/EOS.md)
|Arris |C4CMTS |[c4cmts](/lib/oxidized/model/c4cmts.rb)
|Aruba |AOS-CX |[aoscx](/lib/oxidized/model/aoscx.rb)
|Aruba |AOS-CX |[aoscx](/lib/oxidized/model/aoscx.rb) |@robertcheramy
| |AOSW |[Aaosw](/lib/oxidized/model/aosw.rb)
|Asterfusion |AsterNOS |[asternos](/lib/oxidized/model/asternos.rb)
|AudioCodes |AudioCodes |[audiocodes](/lib/oxidized/model/audiocodes.rb)
Expand Down Expand Up @@ -100,15 +100,16 @@
|Hillstone Networks |StoneOS |[stoneos](/lib/oxidized/model/stoneos.rb)
|Hirschmann |Classic |[hirschmann](/lib/oxidized/model/hirschmann.rb)
| |HiOS |[hios](/lib/oxidized/model/hios.rb)
|HP |Comware (HP A-series, H3C, 3Com)|[comware](/lib/oxidized/model/comware.rb) | |[Comware](Model-Notes/Comware.md)
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb)
|HP |Comware (HP A-series, H3C, 3Com)|[comware](/lib/oxidized/model/comware.rb) |@robertcheramy |[Comware](Model-Notes/Comware.md)
| |Procurve |[procurve](/lib/oxidized/model/procurve.rb) |@robertcheramy
| |BladeSystem (Onboard Administrator)|[hpebladesystem](/lib/oxidized/model/hpebladesystem.rb)
| |MSA |[hpemsa](/lib/oxidized/model/hpemsa.rb)
| |MSM (Wireless Controller) |[hpmsm](/lib/oxidized/model/hpmsm.rb)
|H3C |S6520X |[h3c](/lib/oxidized/model/h3c.rb)
|Huawei |VRP |[vrp](/lib/oxidized/model/vrp.rb) | |[VRP-Huawei](Model-Notes/VRP-Huawei.md)
| |SmartAX series |[smartax](/lib/oxidized/model/smartax.rb) | |[SmartAX-Huawei](Model-Notes/SmartAX-Huawei.md)
|Icotera |6400 series |[icotera](/lib/oxidized/model/icotera.rb)
|IP Infusion |OcNOS |[ocnos](/lib/oxidized/model/ocnos.rb)
|Juniper |JunOS |[junos](/lib/oxidized/model/junos.rb) | |[MX/QFX/EX/SRX/J Series](Model-Notes/JunOS.md)
| |ScreenOS (Netscreen) |[screenos](/lib/oxidized/model/screenos.rb)
|LANCOM Systems GmbH |LCOS |[lancom](/lib/oxidized/model/lancom.rb)
Expand Down
42 changes: 42 additions & 0 deletions lib/oxidized/model/ocnos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class OcNOS < Oxidized::Model
using Refinements

prompt /([\w.@-]+[#>]\s?)$/
comment '# '

cfg :ssh do
post_login 'terminal length 0'
pre_logout do
send "disable\r"
send "logout\r"
end
end

cmd :all do |cfg|
cfg.lines.to_a[1..-2].join
end

cmd 'show version' do |cfg|
comment cfg
end

cmd 'show system fru' do |cfg|
comment cfg
end

cmd 'show system-information board-info' do |cfg|
comment cfg
end

cmd 'show forwarding profile limit' do |cfg|
comment cfg
end

cmd 'show license' do |cfg|
comment cfg
end

cmd 'show running-config' do |cfg|
cfg
end
end
4 changes: 3 additions & 1 deletion lib/oxidized/model/procurve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Procurve < Oxidized::Model
# ssh switches prompt may start with \r, followed by the prompt itself, regex ([\w\s.-]+[#>] ), which ends the line
# telnet switches may start with various vt100 control characters, regex (\e\[24;[0-9][hH]), followed by the prompt, followed
# by at least 3 other vt100 characters
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+(\((config|vlan-[0-9]{1,4}|y\/n)\)|\(o\)nce)?[#>:?\]] {1,2})($|(\e\[24;[0-9][0-9]?[hH]){3})/
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+[#>] )($|(\e\[24;[0-9][0-9]?[hH]){3})/

comment '! '

Expand Down Expand Up @@ -36,6 +36,8 @@ class Procurve < Oxidized::Model
cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, ''
# Additional filtering for power usage reporting which obviously changes over time
cfg.gsub! /^(.*AC [0-9]{3}V\/?([0-9]{3}V)?) *([0-9]{1,3}) (.*)/, '\\1 <removed> \\4'
# Remove failed commands that are not supported on all models
cfg.gsub! /^Invalid input: [A-Za-z-]+\n/, ''
cfg
end

Expand Down
47 changes: 27 additions & 20 deletions spec/input/ssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
describe Oxidized::SSH do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger
Oxidized.config.timeout = 30
Oxidized.config.input.ssh.secure = true
Expand Down Expand Up @@ -31,16 +32,19 @@

proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W [%h]:%p").returns(proxy)
Net::SSH.expects(:start).with('93.184.216.34', 'alma', port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy)
ssh_options = {
port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy
}
Net::SSH.expects(:start).with('93.184.216.34', 'alma', ssh_options)

ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
Expand All @@ -64,16 +68,19 @@

proxy = mock
Net::SSH::Proxy::Command.expects(:new).with("ssh test.com -W [%h]:%p").returns(proxy)
Net::SSH.expects(:start).with('example.com', 'alma', port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy)
ssh_options = {
port: 22,
verify_host_key: Oxidized.config.input.ssh.secure ? :always : :never,
append_all_supported_algorithms: true,
keepalive: true,
forward_agent: false,
password: 'armud',
timeout: Oxidized.config.timeout,
number_of_password_prompts: 0,
auth_methods: %w[none publickey password],
proxy: proxy
}
Net::SSH.expects(:start).with('example.com', 'alma', ssh_options)

ssh.instance_variable_set("@exec", true)
ssh.connect(@node)
Expand Down
1 change: 1 addition & 0 deletions spec/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe Oxidized::Node do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger

Oxidized::Node.any_instance.stubs(:resolve_repo)
Expand Down
1 change: 1 addition & 0 deletions spec/nodes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
before(:each) do
Resolv.any_instance.stubs(:getaddress)
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger

opts = {
Expand Down
4 changes: 3 additions & 1 deletion spec/refinements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@

_(str2.instance_variable_get(:@cmd)).must_equal str1.instance_variable_get(:@cmd)
_(str2.instance_variable_get(:@name)).must_equal str1.instance_variable_get(:@name)
_(str2.instance_variable_get(:@type)).must_equal str1.instance_variable_get(:@type)
# :@type is always nil
_(str2.instance_variable_get(:@type)).must_be_nil
_(str1.instance_variable_get(:@type)).must_be_nil
end
end
end
4 changes: 2 additions & 2 deletions spec/source/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[0].ip")).must_equal "10.10.10.10"
end
it "should return nil on non-existing string key" do
_(Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.3")).must_equal nil
_(Oxidized::HTTP.new.send(:string_navigate, h1, "jotain.3")).must_be_nil
end
it "should return nil on non-existing array index" do
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[3]")).must_equal nil
_(Oxidized::HTTP.new.send(:string_navigate, h1, "inventory[3]")).must_be_nil
end
end
end

0 comments on commit c666131

Please sign in to comment.