f976ab73a9d746d32f0d14125586675693916ee5
[pharos.git] / config / installers / daisy / network.yaml.j2
1 ##############################################################################
2 # Copyright (c) 2018 ZTE Corporation and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 ##############################################################################
11 # Description
12 # MANAGEMENT: used for management
13 # STORAGE: used for storage access
14 # EXTERNAL: tenant public/floating IP associated network
15 # PUBLICAPI: used for horizon access, openstack API access
16 # TENANT: used for tenant access, vlan and VxLan supported, default VxLan
17 # HEARTBEAT: used for heartbeat, requires a dedicated interface
18 ##############################################################################
19
20 ---
21
22 network-config-metadata:
23   title: 'Deployment Adapter for baremetal POD'
24   version: '0.1'
25   created: 'Nov 22 2017'
26   comment: 'For Daisy initial'
27
28 {%- set mapping = {'HEARTBEAT': 'admin',
29                    'MANAGEMENT': 'mgmt',
30                    'PUBLICAPI': 'mgmt',
31                    'STORAGE': 'storage',
32                    'TENANT': 'private',
33                    'EXTERNAL': 'public'} -%}
34
35 {%- if "idf" in conf and ("daisy" in conf["idf"] or "fuel" in conf["idf"]) -%}
36   {%- if "daisy" in conf["idf"] -%}
37     {%- set installer = "daisy" -%}
38   {%- else -%}
39     {%- set installer = "fuel" -%}
40   {%- endif %}
41
42 networks:
43
44   {%- set nodes_num = conf['nodes'] | length -%}
45   {%- set networks = {} -%}
46   {%- for key in mapping -%}
47     {%- set net_data = conf.idf.net_config[mapping[key]] -%}
48     {%- set interface = net_data['interface'] -%}
49     {%- set interface_name = conf.idf[installer].network.node[0].interfaces[interface] -%}
50     {%- set bus_addr = conf.idf[installer].network.node[0].busaddr[interface] -%}
51     {%- set vlan = net_data['vlan'] -%}
52     {%- if vlan == "native" or vlan == None -%}
53       {%- set vlan = "null" -%}
54     {%- endif -%}
55     {%- set network = net_data['network'] -%}
56     {%- set ips = network.split(".") -%}
57     {%- set mask = net_data['mask'] -%}
58     {%- if 'ip-range' in net_data -%}
59       {%- set ip_range = net_data['ip-range'] -%}
60       {%- set (start, end) = ip_range.split("-") -%}
61     {%- else -%}
62       {%- set start = ".".join([ips[0], ips[1], ips[2], "10"]) -%}
63       {%- set end = ".".join([ips[0], ips[1], ips[2], "200"]) -%}
64     {%- endif -%}
65     {%- set vip = start.split(".")[3] | int -%}
66     {%- set vip = vip + nodes_num + 10 - (vip + nodes_num) % 10 -%}
67     {%- set vip = ".".join([ips[0], ips[1], ips[2], vip | string]) -%}
68
69     {%- if 'gateway' in net_data -%}
70       {%- set gateway = net_data.gateway -%}
71     {%- else -%}
72       {%- set gateway = ".".join([ips[0], ips[1], ips[2], "1"]) -%}
73     {%- endif -%}
74
75     {#- set v=v.update(...) is unpredictable and breaks in older j2 -#}
76     {%- set _ = networks.update({key: {'interface_name': interface_name,
77                                               'bus_addr': bus_addr,
78                                               'vlan': vlan,
79                                               'network': network,
80                                               'mask': mask,
81                                               'start': start,
82                                               'end': end,
83                                               'vip': vip,
84                                               'gateway': gateway
85                                              }
86                                        }) %}
87
88   - cidr: '{{ network }}/{{ mask }}'
89     gateway: '{{ gateway }}'
90     ip_ranges:
91       - 'start': '{{ start }}'
92         'end': '{{ end }}'
93     vlan_id: {{ vlan }}
94     name: '{{ key }}'
95     {%- if key == 'EXTERNAL' %}
96     network_name: 'admin_external'
97     mapping: 'physnet1'
98     {%- endif -%}
99   {%- endfor %}
100
101 interfaces:
102   {%- for key in mapping %}
103   - name: '{{ key }}'
104     interface: '{{ networks[key].interface_name }}'
105   {%- endfor %}
106
107 internal_vip: '{{ networks['MANAGEMENT'].vip }}'
108 public_vip: '{{ networks['PUBLICAPI'].vip }}'
109
110 {%- endif %}