Class: Warthog::A10::AXDevice

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/warthog/a10/rest.rb

Defined Under Namespace

Classes: AXapiError, AuthenticationError, HTTPError

Constant Summary collapse

API_VERSIONS =
%w(V2)

Instance Method Summary collapse

Constructor Details

#initialize(hostname, username, password, options = {}) ⇒ AXDevice

Returns a new instance of AXDevice.

Raises:

  • (StandardError)


15
16
17
18
19
20
21
22
# File 'lib/warthog/a10/rest.rb', line 15

def initialize(hostname,username,password,options={})
  @hostname = hostname
  @session_id = nil
  @api_version = nil

  axapi :authenticate, :username => username, :password => password
  raise StandardError, "unable to obtain session id" unless @session_id
end

Instance Method Details

#slb_service_group_allObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/warthog/a10/rest.rb', line 24

def slb_service_group_all
  output = ''
  service_group_list = axapi 'slb.service_group.getAll'
  service_group_list['response']['service_group_list']['service_group'].each do |service_group|
    name = service_group['name']
    service_group['member_list']['member'].each do |member|
      output << "%-16s %12s:%-5s %s %s %s\n" % [name,member['server'],member['port'],member['template'],member['priority'],member['status']] if Hash === member
    end
  end
  output
end

#slb_service_group_search(name) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/warthog/a10/rest.rb', line 36

def slb_service_group_search(name)
  output = ''
  service_group = axapi 'slb.service_group.search', :name => name
  service_group['response']['service_group']['member_list']['member'].each do |member|
    output << "%-16s %12s:%-5s %s %s %s\n" % [name,member['server'],member['port'],member['template'],member['priority'],member['status']]
  end
  output
end