312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu.rb', line 312
def build_config(host, gre)
gre_delegate = gre.delegate
cfg = nil
if gre_delegate.local.first_ipv6
cfg = OpenStruct.new(:prefix=>6, :my=>gre_delegate.local.first_ipv6, :other => gre_delegate.remote.first_ipv6, :mode => "ip6gre")
elsif gre_delegate.local.first_ipv4
cfg = OpenStruct.new(:prefix=>4, :my=>gre_delegate.local.first_ipv4, :other => gre_delegate.remote.first_ipv4, :mode => "ipgre")
end
throw "need a local address #{host.name}:#{gre_delegate.name}" unless cfg
local_iface = host.interfaces.values.find { |iface| iface.address && iface.address.match_network(cfg.my) }
throw "need a interface with address #{host.name}:#{cfg.my}" unless local_iface
iname = Util.clean_if("gt#{cfg.prefix}", gre_delegate.name)
writer_local = host.result.etc_network_interfaces.get(local_iface)
writer_local.lines.up("/bin/bash /etc/network/#{iname}-up.iface")
writer_local.lines.down("/bin/bash /etc/network/#{iname}-down.iface")
writer = host.result.etc_network_interfaces.get(gre_delegate)
writer.skip_interfaces..interface_name(iname)
writer.lines.up("ip -#{cfg.prefix} tunnel add #{iname} mode #{cfg.mode} local #{cfg.my.to_s} remote #{cfg.other.to_s}")
Device.build_config(host, gre)
writer.lines.down("ip -#{cfg.prefix} tunnel del #{iname}")
end
|