Sha256: cd61d3043e01af5a56b35cee6fb0f2bb263852c03c85e4e8774a587223742425

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oxidized-0.30.1 lib/oxidized/model/mimosab11.rb
oxidized-0.30.0 lib/oxidized/model/mimosab11.rb