Sha256: 8a24ac54e4ca2e65bc7898a069c6889671bcc4fb24b23f29f81905f0ba05510a

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

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

    def find_host_by_name(name)
      Host.find(:"name~" => name)
    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

2 entries across 2 versions & 1 rubygems

Version Path
infoblox-0.0.2 lib/infoblox/client.rb
infoblox-0.0.1 lib/infoblox/client.rb