class Construqt::Flavour::Ubuntu::EtcNetworkInterfaces

Public Class Methods

new(result) click to toggle source
# File lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb, line 220
def initialize(result)
  @result = result
  @entries = {}
end

Public Instance Methods

commit() click to toggle source
# File lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb, line 379
def commit
  #      binding.pry
  out = [@entries['lo']]
  clazzes = {}
  @entries.values.each do |entry|
    name = entry.iface.clazz#.name[entry.iface.clazz.name.rindex(':')+1..-1]
    #puts "NAME=>#{name}:#{entry.iface.clazz.name.rindex(':')+1}:#{entry.iface.clazz.name}:#{entry.name}"
    clazzes[name] ||= []
    clazzes[name] << entry
  end

  ['device', 'bond', 'vlan', 'bridge', 'gre'].each do |type|
    out += (clazzes[type]||[]).select{|i| !out.first || i.name != out.first.name }.sort{|a,b| a.name<=>b.name }
  end

  out.flatten.compact.inject("") { |r, entry| r += entry.commit; r }
end
get(iface) click to toggle source
# File lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb, line 374
def get(iface)
  throw "clazz needed #{iface.name}" unless iface.clazz
  @entries[iface.name] ||= Entry.new(@result, iface)
end