summaryrefslogtreecommitdiff
path: root/provider_base/files/service-definitions/eip-service.json.erb
blob: 095f3530e12d77b4cc5a21c8abfcab904664f828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<%=
  def underscore(words)
    words = words.to_s.dup
    words.downcase!
    words.gsub! /[^a-z]/, '_'
    words
  end

  hsh = {}
  hsh["serial"] = 1
  hsh["version"] = 1
  clusters = {}
  gateways = []
  global.services['openvpn'].node_list.each_node do |node|
    next if node.vagrant?
    gateway = {}
    gateway["capabilities"] = node.openvpn.pick(
      :ports, :protocols, :user_ips, :adblock, :filter_dns)
    gateway["capabilities"]["transport"] = ["openvpn"]
    gateway["ip_address"] = node.ip_address
    gateway["host"] = node.domain.full
    gateway["cluster"] = underscore(node.openvpn.location)
    gateways << gateway
    clusters[gateway["cluster"]] ||= {
      "name" => gateway["cluster"],
      "label" => {"en" => node.openvpn.location}
    }
  end
  hsh["gateways"] = gateways
  hsh["clusters"] = clusters.values

  generate_json hsh
%>