Sha256: f52a4ee228f5f9ea87d75425034d7cf6c523b9b81f8865ba760b294f31cb09e1

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

module Infoblox
  class Host < Resource
    remote_attr_accessor :aliases,
                         :comment,
                         :configure_for_dns,
                         :disable,
                         :extattrs,
                         :extensible_attributes,
                         :ipv4addrs,
                         :name,
                         :view,
                         :zone

    wapi_object "record:host"

    ##
    # The more robust way to add IP addresses to your host record, 
    # allowing you to set all the attributes. 
    #
    # Example: 
    # 
    #     host.ipv4addrs=[{:ipv4addr => '10.10.10.10', :mac => '0x0x0x0x0x0x0x'}]
    #
    def ipv4addrs=(attrs=[])
      attrs.each do |att|
        ipv4addrs << HostIpv4addr.new(att)
      end
    end

    ##
    # Add an IP address to this host.  Only allows setting the ipv4addr field
    # of the remote HostIpv4Addr record.  If you need to set other fields, 
    # such as mac or configure_for_dns, use #ipv4addrs=
    #
    def add_ipv4addr(address)
      ipv4addrs << HostIpv4addr.new(:ipv4addr => address)
    end

    def ipv4addrs
      @ipv4addrs ||= []
    end

    def remote_attribute_hash(write=false, post=false)
      super.tap do |hsh|
        hsh[:ipv4addrs] = ipv4addrs.map do |i|
          i.remote_attribute_hash(write, post).delete_if{|k,v| v.nil? }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
infoblox-0.4.0 lib/infoblox/resource/host.rb
infoblox-0.3.3 lib/infoblox/resource/host.rb