Module: Xhyve::DHCP
- Defined in:
- lib/xhyve/dhcp.rb
Constant Summary collapse
- LEASES_FILE =
'/var/db/dhcpd_leases'
Class Method Summary collapse
Class Method Details
.get_ip_for_mac(mac) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/xhyve/dhcp.rb', line 4 def self.get_ip_for_mac(mac) contents = File.read(ENV['LEASES_FILE'] || LEASES_FILE) pattern = contents.match(/ip_address=(\S+)\n\thw_address=\d+,#{mac}/) if pattern addrs = pattern.captures addrs.first if addrs end end |