module Construqt::Ipsecs
Public Class Methods
add_connection(cfg, id, to_id, iname)
click to toggle source
# File lib/construqt/ipsecs.rb, line 20 def self.add_connection(cfg, id, to_id, iname) throw "my not found #{cfg[id].inspect}" unless cfg[id]['my'] throw "host not found #{cfg[id].inspect}" unless cfg[id]['host'] throw "remote not found #{cfg[id].inspect}" unless cfg[id]['remote'] cfg[id]['other'] = nil cfg[id]['cfg'] = nil cfg[id]['my'].host = cfg[id]['host'] cfg[id]['my'].name = "#{iname}-#{cfg[id]['host'].name}" cfg[id]['interface'] = nil cfg[id] = cfg[id]['host'].flavour.create_ipsec(cfg[id]) end
build_config()
click to toggle source
# File lib/construqt/ipsecs.rb, line 63 def self.build_config() hosts = {} @ipsecs.values.each do |ipsec| hosts[ipsec.left.host.object_id] ||= ipsec.left.host hosts[ipsec.right.host.object_id] ||= ipsec.right.host end #binding.pry hosts.values.each do |host| host.flavour.ipsec.header(host) if host.flavour.ipsec.respond_to?(:header) end @ipsecs.each do |name, ipsec| ipsec.build_config() end end
connection(name, cfg)
click to toggle source
# File lib/construqt/ipsecs.rb, line 32 def self.connection(name, cfg) # binding.pry add_connection(cfg, 'left', 'right', Util.add_gre_prefix(cfg['right']['host'].name)) add_connection(cfg, 'right', 'left', Util.add_gre_prefix(cfg['left'].host.name)) cfg['name'] = name cfg['transport_family'] ||= Construqt::Addresses::IPV6 cfg = @ipsecs[name] = Ipsec.new(cfg) cfg.left.other = cfg.right cfg.left.cfg = cfg cfg.right.other = cfg.left cfg.right.cfg = cfg cfg.left.host.add_ipsec(cfg) cfg.right.host.add_ipsec(cfg) #puts "-------- #{cfg.left.my.host.name} - #{cfg.right.my.host.name}" cfg.left.interface = cfg.left.my.host.region.interfaces.add_gre(cfg.left.my.host, cfg.left.other.host.name, "address" => cfg.left.my, "local" => cfg.left.remote, "remote" => cfg.right.remote, "ipsec" => cfg ) cfg.right.interface = cfg.left.my.host.region.interfaces.add_gre(cfg.right.my.host, cfg.right.other.host.name, "address" => cfg.right.my, "local" => cfg.right.remote, "remote" => cfg.left.remote, "ipsec" => cfg ) cfg end