class DHCP::Lease

Attributes

hostname[R]
ip[R]
mac[R]
mask[R]
name[R]
pxe_path[R]

Public Class Methods

new(definition) click to toggle source
# File lib/dhcp.rb, line 50
def initialize(definition)
    @name = definition[:name]
    @ip = definition[:ip]
    @mask = definition[:mask]
    @mac = definition[:mac]
    @pxe_path = definition[:pxe_path] if definition.include? :pxe_path
    @hostname = definition[:hostname] if definition.include? :hostname
end

Public Instance Methods

ip2hex(ip) click to toggle source
# File lib/dhcp.rb, line 70
def ip2hex ip
  ip.split(".").map{|i| "%02x" % i }.join(":")
end
statements_string() click to toggle source
# File lib/dhcp.rb, line 59
def statements_string
    out = "option subnet-mask = #{ip2hex(@mask)};"
    if @pxe_path
        out += " filename = \\\"#{@pxe_path}\\\";"
    end
    if @hostname
        out += " host-name = \\\"#{@hostname}\\\";"
    end
    return out
end