Sha256: 0cf066a7fd8fb6eb99ab55b6b88698e807f6ea4678399bedc7e3f62671744cda

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

module Infoblox
  class Client
    ##
    # :username
    # :password
    # :host (host if infoblox appliance, including protocol)
    def initialize(options={})
      Resource.connection = Connection.new(options)
    end

    def all_hosts
      Host.all
    end

    ## 
    # Find all host records by wildcard name. 
    # 
    def find_host_by_name(name)
      Host.find(:"name~" => name)
    end

    ##
    # Find all ipv4addr records by ip address fragment.
    # ex:  find_ips('10.10.2') => [#<Infoblox::Ipv4addr>...]
    #
    def find_ips(ip_fragment)
      Ipv4addr.find(:"ipv4addr~" => ip_fragment)
    end

    ##
    # hostname : string
    # ip       : ipv4 string, i.e. "10.40.20.3"
    def create_host(hostname, ip, dns=true)
      host = Host.new(:name => hostname, :configure_for_dns => true)
      host.add_ipv4addr(ip)
      host.create
    end

    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
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
infoblox-0.0.11 lib/infoblox/client.rb
infoblox-0.0.10 lib/infoblox/client.rb
infoblox-0.0.9 lib/infoblox/client.rb
infoblox-0.0.8 lib/infoblox/client.rb
infoblox-0.0.7 lib/infoblox/client.rb
infoblox-0.0.6 lib/infoblox/client.rb
infoblox-0.0.5 lib/infoblox/client.rb
infoblox-0.0.4 lib/infoblox/client.rb
infoblox-0.0.3 lib/infoblox/client.rb