Class: Construqt::Flavour::Ubuntu::EtcNetworkInterfaces

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ EtcNetworkInterfaces

Returns a new instance of EtcNetworkInterfaces.



220
221
222
223
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 220

def initialize(result)
  @result = result
  @entries = {}
end

Instance Method Details

#commitObject



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 367

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) ⇒ Object



362
363
364
365
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 362

def get(iface)
  throw "clazz needed #{iface.name}" unless iface.clazz
  @entries[iface.name] ||= Entry.new(@result, iface)
end