forked from ytti/oxidized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmimosab11.rb
34 lines (31 loc) · 981 Bytes
/
mimosab11.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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