Skip to content

Commit

Permalink
added model mimosab11 (#2902)
Browse files Browse the repository at this point in the history
* added model mimosab11

* Update mimosab11.rb

Fixed errors picked up on test

* Update mimosab11.rb

* additional change to CHANGELOG and Supported OS types for PR #2902
  • Loading branch information
ritzbhuj authored Aug 16, 2023
1 parent 94b241f commit 39bb8cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- model for Asterfusion Network Operating System (@avl-dev)
- pagination for http source (@davama)
- model for Ericsson Miniling 6600 series (@schouwenburg)

- model for Mimosa B11 (@ritzbhuj)
+ Added ability to send mail with the Docker container
+ Documentation to send mail with hooks

Expand Down
2 changes: 2 additions & 0 deletions docs/Supported-OS-Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@
* Mikrotik
* [RouterOS](/lib/oxidized/model/routeros.rb)
* [SwOS and SwOS Lite](/lib/oxidized/model/swos.rb)
* Mimosa
* [Mimosa (B11)](/lib/oxidized/model/mimosab11.rb)
* Motorola
* [RFS](/lib/oxidized/model/mtrlrfs.rb)
* MRV
Expand Down
34 changes: 34 additions & 0 deletions lib/oxidized/model/mimosab11.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
begin
# Mechanize has to be intialized here as the login needs a POST request
require "mechanize"
rescue LoadError
# Oxidized requires mechanize
raise Oxidized::OxidizedError, "mechanize not found: sudo gem install mechanize"
end

class Mimosab11 < Oxidized::Model
using Refinements
# Callback cfg_cb function to login(POST) then get(GET) the configuration
cfg_cb = lambda do
@e = Mechanize.new
# Set login query endpoint(lqe) and login POST data(lqp)
lqe = "https://#{@node.ip}/?q=index.login&mimosa_ajax=1"
lgp = { "username" => "configure", "password" => @password }
# Set get request endpoint(gc) for config
gc = "https://#{@node.ip}/?q=preferences.configure&mimosa_action=download"
# Not to verify self signed
@e.verify_mode = 0
@e.post(lqe, lgp)
cfg = @e.get(gc)
cfg.body
end

cmd cfg_cb do |cfg|
cfg
end

cfg :http do
@username = @node.auth[:username]
@password = @node.auth[:password]
end
end

0 comments on commit 39bb8cc

Please sign in to comment.