Class: Isepick::IseMNT

Inherits:
Object
  • Object
show all
Defined in:
lib/isepick.rb

Instance Method Summary collapse

Constructor Details

#initialize(mnt_host, mnt_user, mnt_password) ⇒ IseMNT

Returns a new instance of IseMNT.



9
10
11
12
13
14
15
16
# File 'lib/isepick.rb', line 9

def initialize(mnt_host, mnt_user, mnt_password)
  @client = Faraday.new("https://#{mnt_host}/admin/API/mnt/") do |conn|
    conn.basic_auth(mnt_user, mnt_password)
    conn.adapter Faraday.default_adapter
    conn.ssl[:verify] = false
    conn.headers["Accept"] = "application/xml"
  end
end

Instance Method Details

#activeSessions(pageSize = 25, page = 1) ⇒ Object



18
19
20
21
# File 'lib/isepick.rb', line 18

def activeSessions(pageSize = 25, page = 1)
  session_xml = Nokogiri::XML(@client.get("Session/ActiveList", {pageSize: pageSize, page: page}).body)
  return Hash.from_xml(session_xml.to_s)
end

#session_filterByIP(ip_addr) ⇒ Object



29
30
31
32
# File 'lib/isepick.rb', line 29

def session_filterByIP(ip_addr)
  session_xml = Nokogiri::XML(@client.get("Session/EndPointIPAddress/#{ip_addr}").body)
  return Hash.from_xml(session_xml.to_s)
end

#session_filterByMAC(mac_addr) ⇒ Object



23
24
25
26
27
# File 'lib/isepick.rb', line 23

def session_filterByMAC(mac_addr)
  filter_param = mac_addr.gsub(/[^a-fA-F0-9]/, "").upcase.gsub(/(.{2})(?=.)/, '\1:\2')
  session_xml = Nokogiri::XML(@client.get("Session/MACAddress/#{filter_param}").body)
  return Hash.from_xml(session_xml.to_s)
end