kavlan.conf.erb 2.55 KB
Newer Older
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
34
35
36
37
38
39
40
{
   "site": "<%= site_uid %>",
   "cookie": "eebi6AiN",
   "remote-servers": [
<%
   refapi['sites'].sort.to_h.each do |remote_site_uid, remote_site_refapi|
     if remote_site_refapi.has_key?('kavlans') and remote_site_uid != site_uid
-%>
        {"node": "kavlan-server@kavlan.<%= remote_site_uid %>.grid5000.fr"},
<%
     end
   end
-%>
   ],
   "DefaultVLAN": "PRODUCTION",
   "loglevel": "notice",
   "admins": "oar;deploy;root;g5kadmin",
   "trace": { "active": "off", "path": "/tmp/traces" },
   "SNMPCommunity": "<%= conf.has_key?('snmp_community') ? conf['snmp_community'] : 'public' %>",
   "db": { "host": "mysql", "name": "deploy3", "user": "<%= conf['db_user'] or 'deploy'%>", "passwd": "<%= conf['db_password'] or fail "Missing db_password entry" %>"},
   "vlan": [
       {"value": 100, "name": "PRODUCTION", "type": "NULL"},
<%
       site_refapi['kavlans'].each do |kavlan_id, kavlan|
         if kavlan_id.to_i.between?(1, 3)
-%>
       {"value": 70<%= kavlan_id %>, "name": "KAVLAN-<%= kavlan_id %>", "type": "kavlan-local", "dhcpd": "ssh kavlan-<%= kavlan_id %> sudo /etc/init.d/isc-dhcp-server"},
<%       elsif kavlan_id.to_i.between?(4, 9) -%>
       {"value": 70<%= kavlan_id %>, "name": "KAVLAN-<%= kavlan_id %>", "type": "kavlan", "dhcpd": "sudo /etc/init.d/isc-dhcp-server-<%= kavlan_id %>"},
<%       elsif kavlan_id.to_i >= 10 -%>
       {"value": 7<%= kavlan_id %>, "name": "KAVLAN-<%= kavlan_id %>", "type": "kavlan-global","dhcpd": "sudo /etc/init.d/isc-dhcp-server-0"},
<%
         end
       end

       (10..21).each.reject{ |kavlan_id| site_refapi['kavlans'].include?(kavlan_id) }.each do |kavlan_id|
-%>
       {"value": 7<%= kavlan_id %>, "name": "KAVLAN-<%= kavlan_id %>", "type": "kavlan-remote"},
<%
       end
41
42
43
44
45
46
47

       if site_refapi.has_key?('kavlan_topo')
         Range.new(*site_refapi['kavlan_topo'].split("..").map{|d| Integer(d)}).each do |kavlan_topo_id| -%>
       {"value": <%= kavlan_topo_id %>, "name": "KAVLAN-<%= kavlan_topo_id %>", "type": "kavlan-topo"},
<%
         end
       end
48
49
50
51
52

       if site_refapi.has_key?('kavlan_nef') -%>
       {"value": <%= site_refapi['kavlan_nef'] %>, "name": "NEF", "type": "NULL"},
<%
       end
53
54
55
56
57
58
59
60
61
62
63
64
-%>
     ],
     "switch": [
<%
     conf.fetch('devices', []).sort.to_h.each do |dev_id, dev|
-%>
       {"name": "<%= dev_id %>", "IP": "<%= dev['ip'] %>", "type": "<%= dev['driver'] %>", <%= dev.has_key?('port')? "\"Port\": #{dev['port']}," : "" %> <%= dev.has_key?('user')? "\"User\": \"#{dev['user']}\"," : "" %> <%= dev.has_key?('password')? "\"Passwd\": \"#{dev['password']}\"," : "" %>},
<%
     end
-%>
     ]
}