Class: Infoblox::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

:username :password :host (host if infoblox appliance, including protocol)



7
8
9
# File 'lib/infoblox/client.rb', line 7

def initialize(options={})
  Resource.connection = Connection.new(options)
end

Instance Method Details

#all_hostsObject



11
12
13
# File 'lib/infoblox/client.rb', line 11

def all_hosts
  Host.all
end

#create_host(hostname, ip, dns = true) ⇒ Object

hostname : string ip : ipv4 string, i.e. “10.40.20.3”



33
34
35
36
37
# File 'lib/infoblox/client.rb', line 33

def create_host(hostname, ip, dns=true)
  host = Host.new(:name => hostname, :configure_for_dns => true)
  host.add_ipv4addr(ip)
  host.create
end

#delete_host(hostname) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/infoblox/client.rb', line 39

def delete_host(hostname)
  if !(hosts = Host.find(:name => hostname)).empty?
    hosts.map(&:delete)
    hosts
  else
    raise Exception.new("host #{hostname} not found")
    false
  end
end

#find_host_by_name(name) ⇒ Object

Find all host records by wildcard name.



18
19
20
# File 'lib/infoblox/client.rb', line 18

def find_host_by_name(name)
  Host.find(:"name~" => name)
end

#find_ips(ip_fragment) ⇒ Object

Find all ipv4addr records by ip address fragment. ex: find_ips(‘10.10.2’) => [#<Infoblox::Ipv4addr>…]



26
27
28
# File 'lib/infoblox/client.rb', line 26

def find_ips(ip_fragment)
  Ipv4addr.find(:"ipv4addr~" => ip_fragment)
end