class Construqt::Flavour::Ubuntu::Gre

Public Class Methods

new(cfg) click to toggle source
Calls superclass method
# File lib/construqt/flavour/ubuntu/flavour_ubuntu.rb, line 308
def initialize(cfg)
  super(cfg)
end

Public Instance Methods

build_config(host, gre) click to toggle source
# 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.header.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}")
  #writer.lines.up("ip -#{cfg.prefix} tunnel add #{iname} mode #{cfg.mode} local #{cfg.my.to_s} remote #{cfg.other.to_s}")
  #/sbin/ip -6 tunnel add gt4nactr01 mode ip4ip6 remote 2a04:2f80:f:f003::2 local 2a04:2f80:f:f003::1
  #      writer.lines.up("ip -#{cfg.prefix} link set dev #{iname} up")
  Device.build_config(host, gre)
  #      Device.add_address(host, iname, iface, writer.lines, writer)
  writer.lines.down("ip -#{cfg.prefix} tunnel del #{iname}")
end