Sha256: bbb5f77271b43938c87958989d3ffa59f5f47535b05db7741d1d026073f28edc

Contents?: true

Size: 546 Bytes

Versions: 5

Compression:

Stored size: 546 Bytes

Contents


#
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
#

provides "routes"
routes Mash.new

output = `route -n`
# build list of routes
output.split("\n").each do |line|
  if line.strip != ""
    if line[0].match(/^default.*/) || line[0].match(/^[0-9]+.*/)
      pattern = /^([0-9a-z\-A-Z\.]+)\s+([0-9a-z\-A-Z\.]+).*\s(.*)$/
      target = line.gsub(pattern, '\1')
      gw = line.gsub(pattern, '\2')
      iface = line.gsub(pattern, '\3')
      routes[target] = {
        "gateway" => gw,
        "interface" => iface
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloud-toaster-1.1.6 lib/toaster/ohai/routes/routes.rb
cloud-toaster-1.1.5 lib/toaster/ohai/routes/routes.rb
cloud-toaster-1.1.4 lib/toaster/ohai/routes/routes.rb
cloud-toaster-1.1.3 lib/toaster/ohai/routes/routes.rb
cloud-toaster-1.1.2 lib/toaster/ohai/routes/routes.rb