Class: Construqt::Flavour::Ubuntu::Gre
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Construqt::Flavour::Ubuntu::Gre
- Defined in:
- lib/construqt/flavour/ubuntu/flavour_ubuntu.rb
Instance Method Summary collapse
- #build_config(host, gre) ⇒ Object
-
#initialize(cfg) ⇒ Gre
constructor
A new instance of Gre.
Constructor Details
#initialize(cfg) ⇒ Gre
Returns a new instance of Gre.
308 309 310 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu.rb', line 308 def initialize(cfg) super(cfg) end |
Instance Method Details
#build_config(host, gre) ⇒ Object
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.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 |