summaryrefslogtreecommitdiff
path: root/provider_base/files/service-definitions/v1/smtp-service.json.erb
blob: 68d4bbabf5ef7d7a69e329293f05b4e7d61c9468 (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
<%=
  def underscore(words)
    words = words.to_s.dup
    words.downcase!
    words.gsub! /[^a-z]/, '_'
    words
  end

  hsh = {}
  hsh["serial"] = 1
  hsh["version"] = 1
  locations = {}
  hosts = {}
  nodes_like_me[:services => 'mx'].each_node do |node|
    host = {}
    host["hostname"] = node.domain.full
    host["ip_address"] = node.ip_address
    host["port"] = 25 # hard coded for now, later node.smtp.port
    if node['location']
      location_name = underscore(node.location.name)
      host["location"] = location_name
      locations[location_name] ||= node.location
    end
    hosts[node.name] = host
  end
  hsh["hosts"] = hosts
  hsh["locations"] = locations
  generate_json hsh
%>