Class: Specinfra::HostInventory::Ip
- Inherits:
-
Base
- Object
- Base
- Specinfra::HostInventory::Ip
- Defined in:
- lib/pullmatic/resource/interface.rb
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
32 33 34 35 36 37 38 39 40 |
# 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) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# 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 |