Skip to content

Commit

Permalink
Merge pull request #3233 from mabezi/patch-1
Browse files Browse the repository at this point in the history
update prompt for aosw
  • Loading branch information
robertcheramy authored Jul 25, 2024
2 parents 9ef40fe + 6498c4a commit 5279280
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- saos: fixed handling of 'unsaved configuration' indicator in prompt (@grbeneke)
- rgos: also strip "System uptime" for installed modules (@spike77453)
- fixed digest authentication when using http input (@spike77453)

- fixed aosw prompt; now working with ArubaOS 8 (@mabezi, @robertcheramy)

## [0.30.1 – 2024-04-12]

Expand Down
14 changes: 10 additions & 4 deletions lib/oxidized/model/aosw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ class AOSW < Oxidized::Model
# All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored.

comment '# '
prompt /^([\w\(:.@-]+(\)?\s?)[#>]\s?)$/
# see /spec/model/aosw_spec.rb for prompt examples
prompt(/^\(?[\w\:.@-]+\)? ?[*^]?(\[[\w\/]+\] ?)?[#>] ?$/)

# Ignore cariage returns - also for the prompt
expect "\r" do |data, re|
data.gsub re, ''
end

cmd :all do |cfg|
cfg.cut_both
Expand Down Expand Up @@ -61,7 +67,7 @@ class AOSW < Oxidized::Model
end

cmd 'show license passphrase' do |cfg|
cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS)
cfg = "" if cfg.match(/(Invalid input detected at '\^' marker|Parse error)/) # Don't show for unsupported devices (IAP and MAS)
rstrip_cfg comment cfg
end

Expand All @@ -78,8 +84,8 @@ class AOSW < Oxidized::Model
end

cfg :telnet do
username /^User:\s*/
password /^Password:\s*/
username(/^User:\s*/)
password(/^Password:\s*/)
end

cfg :telnet, :ssh do
Expand Down
44 changes: 44 additions & 0 deletions spec/model/aosw_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require_relative '../spec_helper'

describe 'Model aosw' do
before(:each) do
Oxidized.asetus = Asetus.new
Oxidized.asetus.cfg.debug = false
Oxidized.setup_logger

Oxidized::Node.any_instance.stubs(:resolve_repo)
Oxidized::Node.any_instance.stubs(:resolve_output)

@node = Oxidized::Node.new(name: 'example.com',
input: 'ssh',
output: 'file',
model: 'aosw',
username: 'alma',
password: 'armud')
end

it "matches different prompts" do
# Virtual controller - ArubaOS (MODEL: 515), Version 8.10.0.7 LSR
_('AAAA-AP123456# ').must_match AOSW.prompt

# Hardware controller- ArubaOS (MODEL: Aruba7210), Version 8.10.0.7 LSR
# - (host) ^[mynode] – This indicates unsaved configuration.
# - (host) *[mynode] – This indicates available crash information.
# - (host) [mynode] – This indicates a saved configuration.
# [mynode] indicates the "path" you are in. On my controller, it can be
# [/], [mm] or [mynode]. you have to 'cd ..' or 'cd /' to change it, so
# we may never encounter [/].
# There could be other values than [/], [mm] or [mynode]
# Now to the test prompts:
# Controller with saved configuration
_('(WPP-ArubaVMC) [mynode] #').must_match AOSW.prompt
# Controller with unsaved configuration
_('(AAAA-WLC42) ^[mynode] #').must_match AOSW.prompt
# Controller with available crash information
_('(AAAA-WLC42) *[mynode] #').must_match AOSW.prompt
# Controller with crash information in path /
_('(AAAA-WLC42) *[/] #').must_match AOSW.prompt
# Controller with saved configuration in path mm
_('(AAAA-WLC42) [mm] #').must_match AOSW.prompt
end
end

0 comments on commit 5279280

Please sign in to comment.