Add support for IPv6 to machine and cluster chart
[icn.git] / deploy / machine / templates / _networkdata.json
1 {{- define "machine.networkData" -}}
2 {{- if .networkData -}}
3 {
4   "links": [
5 {{- $local := dict "first" true -}}
6 {{- range $name, $link := .networkData.links.ethernets }}
7 {{- if not $local.first }}
8     },{
9 {{- else }}
10     {
11 {{- end }}
12 {{- $_ := set $local "first" false }}
13       "id": "{{ $name }}_nic",
14       "ethernet_mac_address": "{{ $link.macAddress }}",
15       "type": "phy"
16 {{- end }}
17     }
18   ],
19   "networks": [
20 {{- $local := dict "first" true -}}
21 {{- range $name, $network := .networkData.networks.ipv4DHCP }}
22 {{- if not $local.first }}
23     },{
24 {{- else }}
25     {
26 {{- end }}
27 {{- $_ := set $local "first" false }}
28       "id": "{{ $name }}",
29       "link": "{{ $network.link | default $name }}_nic",
30       "type": "ipv4_dhcp"
31 {{- end }}
32 {{- range $name, $network := .networkData.networks.ipv4 }}
33     },{
34       "id": "{{ $name }}",
35       "link": "{{ $network.link | default $name }}_nic",
36       "type": "ipv4"{{- if $network.ipAddress }},
37       "ip_address": "{{ $network.ipAddress }}"{{- end }}{{- if $network.gateway }},
38       "gateway": "{{ $network.gateway }}"{{- end }}
39 {{- end }}
40 {{- range $name, $network := .networkData.networks.ipv6DHCP }}
41     },{
42       "id": "{{ $name }}",
43       "link": "{{ $network.link | default $name }}_nic",
44       "type": "ipv4_dhcp"
45 {{- end }}
46 {{- range $name, $network := .networkData.networks.ipv6 }}
47     },{
48       "id": "{{ $name }}",
49       "link": "{{ $network.link | default $name }}_nic",
50       "type": "ipv6"{{- if $network.ipAddress }},
51       "ip_address": "{{ $network.ipAddress }}"{{- end }}{{- if $network.gateway }},
52       "gateway": "{{ $network.gateway }}"{{- end }}
53 {{- end }}
54     }
55   ],
56   "services": [
57 {{- $local := dict "first" true -}}
58 {{- range $address := .networkData.services.dns }}
59 {{- if not $local.first }}
60     },{
61 {{- else }}
62     {
63 {{- end }}
64 {{- $_ := set $local "first" false }}
65       "type": "dns",
66       "address": "{{ $address }}"
67 {{- end }}
68     }
69   ]
70 }
71 {{ end }}
72 {{- end }}