states: Rename openstack, add baremetal_init
[fuel.git] / mcp / reclass / classes / cluster / baremetal-mcp-ocata-common-ha / openstack_compute_init.yml.j2
1 ##############################################################################
2 # Copyright (c) 2017 Mirantis Inc., Enea AB and others.
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 ##############################################################################
8 {# NOTE: br-{mgmt,ctl} are cross-referenced, careful when changing names #}
9 {%- if conf.net_config is defined and conf.idf is defined -%}
10     {#- NOTE: Currently, we assume all cluster nodes use the same mapping -#}
11
12     {#- Determine interface index for each network (plumbing vars) -#}
13     {%- set idx_admin = conf['net_config']['admin']['interface'] -%}
14     {%- set idx_mgmt = conf['net_config']['mgmt']['interface'] -%}
15     {%- set idx_private = conf['net_config']['private']['interface'] -%}
16     {%- set idx_public = conf['net_config']['public']['interface'] -%}
17
18     {#- Physical interface OS name for each network (e.g. em1, enp1s0f1) -#}
19     {%- set iface_names = conf['idf']['fuel']['network']['node'][3]['interfaces'] -%}
20     {%- set nic_admin = iface_names[idx_admin] -%}
21     {%- set nic_mgmt = iface_names[idx_mgmt] -%}
22     {%- set nic_private = iface_names[idx_private] -%}
23     {%- set nic_public = iface_names[idx_public] -%}
24
25     {#- VLAN for each network (only untagged 'admin' is supported by MaaS config!) -#}
26     {%- set vlan_admin = conf['net_config']['admin']['vlan'] -%}
27     {%- set vlan_mgmt = conf['net_config']['mgmt']['vlan'] -%}
28     {%- set vlan_private = conf['net_config']['private']['vlan'] -%}
29     {%- set vlan_public = conf['net_config']['public']['vlan'] -%}
30 {%- else -%}
31     {%- set nic_admin = 'enp6s0' -%}
32     {%- set nic_mgmt = 'enp6s0' -%}
33     {%- set nic_private = None -%}
34     {%- set nic_public = None -%}
35     {%- set vlan_admin = 'native' -%}
36     {%- set vlan_mgmt = '300' -%}
37     {%- set vlan_private = '1000' -%}
38 {%- endif -%}
39
40 {#- Filter-out NIC duplicates by constructing a dict (used NICs only) -#}
41 {%- set nics = { nic_admin: True, nic_mgmt: True, nic_public: True} -%}
42
43 {%- set vlans = { vlan_admin: nic_admin, vlan_mgmt: nic_mgmt, vlan_public: nic_public} -%}
44 ---
45 parameters:
46   linux:
47     network:
48       bridge: openvswitch
49       interface:
50 {%- for nic in nics %}
51     {%- if nic == nic_admin %}
52         {{ nic }}:
53           enabled: true
54           type: eth
55           proto: dhcp
56           name: {{ nic }}
57     {%- else %}
58         {{ nic }}:
59           enabled: true
60           type: eth
61           proto: manual
62           address: 0.0.0.0
63           netmask: 255.255.255.0
64           mtu: ${_param:interface_mtu}
65           name: {{ nic }}
66     {%- endif %}
67 {%- endfor %}
68
69 {%- for vlan in vlans %}
70     {%- if vlan and vlan != 'native' %}
71         {{ vlans[vlan] }}.{{ vlan }}:
72           enabled: true
73           proto: manual
74           type: vlan
75           name: {{ vlans[vlan] }}.{{ vlan }}
76           use_interfaces:
77             - {{ vlans[vlan] }}
78     {%- endif %}
79 {%- endfor %}
80
81         br-ctl:
82           enabled: true
83           type: bridge
84           proto: static
85           address: ${_param:single_address}
86           netmask: 255.255.255.0
87           use_interfaces:
88             - {{ nic_mgmt }}{% if vlan_mgmt and vlan_mgmt != 'native' %}.{{ vlan_mgmt }}{% endif %}
89         br-floating:
90           enabled: true
91           type: ovs_bridge
92           mtu: ${_param:interface_mtu}
93         float-to-ex:
94           enabled: true
95           type: ovs_port
96           mtu: ${_param:interface_mtu}
97           bridge: br-floating
98         br-ex:
99           enabled: true
100           type: bridge
101           mtu: ${_param:interface_mtu}
102           address: ${_param:external_address}
103           netmask: 255.255.255.0
104           use_interfaces:
105             - {{ nic_public }}{% if vlan_public and vlan_public != 'native' %}.{{ vlan_public }}{% endif %}
106           use_ovs_ports:
107             - float-to-ex