Class: DHCP::Lease
- Inherits:
-
Object
- Object
- DHCP::Lease
- Defined in:
- lib/dhcp.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#mask ⇒ Object
readonly
Returns the value of attribute mask.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pxe_path ⇒ Object
readonly
Returns the value of attribute pxe_path.
Instance Method Summary collapse
-
#initialize(definition) ⇒ Lease
constructor
A new instance of Lease.
- #ip2hex(ip) ⇒ Object
- #statements_string ⇒ Object
Constructor Details
#initialize(definition) ⇒ Lease
Returns a new instance of Lease.
50 51 52 53 54 55 56 57 |
# 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 |
Instance Attribute Details
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def hostname @hostname end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def ip @ip end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def mac @mac end |
#mask ⇒ Object (readonly)
Returns the value of attribute mask.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def mask @mask end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def name @name end |
#pxe_path ⇒ Object (readonly)
Returns the value of attribute pxe_path.
48 49 50 |
# File 'lib/dhcp.rb', line 48 def pxe_path @pxe_path end |
Instance Method Details
#ip2hex(ip) ⇒ Object
70 71 72 |
# File 'lib/dhcp.rb', line 70 def ip2hex ip ip.split(".").map{|i| "%02x" % i }.join(":") end |
#statements_string ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# 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 |