class Specinfra::HostInventory::Ip
Public Instance Methods
get()
click to toggle source
# File lib/pullmatic/resource/interface.rb, line 32 def get cmd = backend.command.get(:get_inventory_ip) ret = backend.run_command(cmd) if ret.exit_status == 0 parse(ret.stdout) else nil end end
parse(ret)
click to toggle source
# File lib/pullmatic/resource/interface.rb, line 42 def parse(ret) ifs = {} name = ipv4 = ipv6 = nil ret.split("\n").each do |l| name = $2 if l =~ /^(\d+):\s(\w+):/ ipv4 = $1 if l =~ /^\s+inet\s([0-9.\/]+)/ ipv6 = $1 if l =~ /^\s+inet6\s([0-9a-f:.\/]+)/ ifs[name] = {:ipv4 => ipv4, :ipv6 => ipv6} end ifs end