Replace outdated instruction with link to upstream doc
[apex-tripleo-heat-templates.git] / extraconfig / pre_network / host_config_and_reboot.yaml
1 heat_template_version: pike
2
3 description: >
4   All configurations which require reboot should be initiated via PreNetworkConfig. After
5   this configuration is completed, the corresponding node will be rebooted.
6
7 parameters:
8   server:
9     type: string
10   RoleParameters:
11     type: json
12     description: Role Specific parameters
13     default: {}
14   ServiceNames:
15     type: comma_delimited_list
16     default: []
17   IsolCpusList:
18     default: "0"
19     description: List of cores to be isolated by tuned
20     type: string
21     constraints:
22       - allowed_pattern: "[0-9,-]+"
23   OvsEnableDpdk:
24     default: false
25     description: Whether or not to configure enable DPDK in OVS
26     type: boolean
27   OvsDpdkCoreList:
28     description: >
29       List of cores to be used for DPDK lcore threads.  Note, these threads
30       are used by the OVS control path for validator and handling functions.
31     type: string
32     constraints:
33       - allowed_pattern: "[0-9,-]*"
34     default: ""
35   OvsDpdkMemoryChannels:
36     description: Number of memory channels per socket to be used for DPDK
37     type: string
38     constraints:
39       - allowed_pattern: "[0-9]*"
40     default: ""
41   OvsDpdkSocketMemory:
42     default: ""
43     description: >
44       Sets the amount of hugepage memory to assign per NUMA node. It is
45       recommended to use the socket closest to the PCIe slot used for the
46       desired DPDK NIC.  The format should be in "<socket 0 mem>, <socket 1
47       mem>, <socket n mem>", where the value is specified in MB.  For example:
48       "1024,0".
49     type: string
50   OvsDpdkDriverType:
51     default: "vfio-pci"
52     description: >
53       DPDK Driver type. Ensure the Overcloud NIC to be used for DPDK supports
54       this UIO/PMD driver.
55     type: string
56   OvsPmdCoreList:
57     description: >
58       A list or range of CPU cores for PMD threads to be pinned to.  Note, NIC
59       location to cores on socket, number of hyper-threaded logical cores, and
60       desired number of PMD threads can all play a role in configuring this
61       setting.  These cores should be on the same socket where
62       OvsDpdkSocketMemory is assigned.  If using hyperthreading then specify
63       both logical cores that would equal the physical core. Also, specifying
64       more than one core will trigger multiple PMD threads to be spawned which
65       may improve dataplane performance.
66     constraints:
67       - allowed_pattern: "[0-9,-]*"
68     type: string
69     default: ""
70   # DEPRECATED: the following options are deprecated and are currently maintained
71   # for backwards compatibility. They will be removed in the Queens cycle.
72   HostCpusList:
73     description: List of cores to be used for host process
74     type: string
75     constraints:
76       - allowed_pattern: "[0-9,-]+"
77     default: '0'
78   NeutronDpdkCoreList:
79     description: List of cores to be used for DPDK Poll Mode Driver
80     type: string
81     constraints:
82       - allowed_pattern: "[0-9,-]*"
83     default: ''
84   NeutronDpdkMemoryChannels:
85     description: Number of memory channels to be used for DPDK
86     type: string
87     constraints:
88       - allowed_pattern: "[0-9]*"
89     default: ''
90   NeutronDpdkSocketMemory:
91     default: ''
92     description: Memory allocated for each socket
93     type: string
94   NeutronDpdkDriverType:
95     default: "vfio-pci"
96     description: DPDK Driver type
97     type: string
98
99 conditions:
100   is_host_config_required: {not: {equals: [{get_param: [RoleParameters, KernelArgs]}, ""]}}
101   # YAQL is enabled in conditions with https://review.openstack.org/#/c/467506/
102   is_dpdk_config_required:
103     or:
104       - yaql:
105         expression: $.data.service_names.contains('neutron_ovs_dpdk_agent')
106         data:
107           service_names: {get_param: ServiceNames}
108       - {get_param: OvsEnableDpdk}
109       - {get_param: [RoleParameters, OvsEnableDpdk]}
110   is_reboot_config_required:
111     or:
112       - is_host_config_required
113       - is_dpdk_config_required
114   l_cores_empty: {equals: [{get_param: OvsDpdkCoreList}, '']}
115   pmd_cores_empty: {equals: [{get_param: OvsPmdCoreList}, '']}
116   mem_channels_empty: {equals: [{get_param: OvsDpdkMemoryChannels}, '']}
117   socket_mem_empty: {equals: [{get_param: OvsDpdkSocketMemory}, '']}
118   driver_not_set: {equals: [{get_param: OvsDpdkDriverType}, 'vfio-pci']}
119   isol_cpus_empty: {equals: [{get_param: IsolCpusList}, '0']}
120
121 resources:
122   RoleParametersValue:
123     type: OS::Heat::Value
124     properties:
125       type: json
126       value:
127         map_replace:
128           - map_replace:
129             - IsolCpusList: IsolCpusList
130               OvsDpdkCoreList: OvsDpdkCoreList
131               OvsDpdkMemoryChannels: OvsDpdkMemoryChannels
132               OvsDpdkSocketMemory: OvsDpdkSocketMemory
133               OvsDpdkDriverType: OvsDpdkDriverType
134               OvsPmdCoreList: OvsDpdkCoreList
135             - values: {get_param: [RoleParameters]}
136           - values:
137               IsolCpusList: {if: [isol_cpus_empty, {get_param: HostCpusList}, {get_param: IsolCpusList}]}
138               OvsDpdkCoreList: {if: [l_cores_empty, {get_param: HostCpusList}, {get_param: OvsDpdkCoreList}]}
139               OvsDpdkMemoryChannels: {if: [mem_channels_empty, {get_param: NeutronDpdkMemoryChannels}, {get_param: OvsDpdkMemoryChannels}]}
140               OvsDpdkSocketMemory: {if: [socket_mem_empty, {get_param: NeutronDpdkSocketMemory}, {get_param: OvsDpdkSocketMemory}]}
141               OvsDpdkDriverType: {if: [driver_not_set, {get_param: NeutronDpdkDriverType}, {get_param: OvsDpdkDriverType}]}
142               OvsPmdCoreList: {if: [pmd_cores_empty, {get_param: NeutronDpdkCoreList}, {get_param: OvsPmdCoreList}]}
143
144   HostParametersConfig:
145     type: OS::Heat::SoftwareConfig
146     condition: is_host_config_required
147     properties:
148       group: ansible
149       inputs:
150         - name: _KERNEL_ARGS_
151         - name: _TUNED_PROFILE_NAME_
152         - name: _TUNED_CORES_
153       outputs:
154         - name: result
155       config:
156         get_file: ansible_host_config.yaml
157
158   HostParametersDeployment:
159     type: OS::Heat::SoftwareDeployment
160     condition: is_host_config_required
161     properties:
162       name: HostParametersDeployment
163       server:  {get_param: server}
164       config: {get_resource: HostParametersConfig}
165       actions: ['CREATE'] # Only do this on CREATE
166       input_values:
167         _KERNEL_ARGS_: {get_param: [RoleParameters, KernelArgs]}
168         _TUNED_PROFILE_NAME_: {get_param: [RoleParameters, TunedProfileName]}
169         _TUNED_CORES_: {get_param: [RoleParameters, IsolCpusList]}
170
171   EnableDpdkConfig:
172     type: OS::Heat::SoftwareConfig
173     condition: is_dpdk_config_required
174     properties:
175       group: script
176       config:
177         str_replace:
178           template: |
179             #!/bin/bash
180             set -x
181             # DO NOT use --detailed-exitcodes
182             puppet apply --logdest console \
183               --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules \
184               -e '
185                 class {"vswitch::dpdk":
186                   host_core_list  => "$HOST_CORES",
187                   pmd_core_list   => "$PMD_CORES",
188                   memory_channels => "$MEMORY_CHANNELS",
189                   socket_mem      => "$SOCKET_MEMORY",
190                 }
191               '
192           params:
193             $HOST_CORES: {get_attr: [RoleParametersValue, value, OvsDpdkCoreList]}
194             $PMD_CORES: {get_attr: [RoleParametersValue, value, OvsPmdCoreList]}
195             $MEMORY_CHANNELS: {get_attr: [RoleParametersValue, value, OvsDpdkMemoryChannels]}
196             $SOCKET_MEMORY: {get_attr: [RoleParametersValue, value, OvsDpdkSocketMemory]}
197
198   EnableDpdkDeployment:
199     type: OS::Heat::SoftwareDeployment
200     condition: is_dpdk_config_required
201     properties:
202       name: EnableDpdkDeployment
203       server:  {get_param: server}
204       config: {get_resource: EnableDpdkConfig}
205       actions: ['CREATE'] # Only do this on CREATE
206
207   RebootConfig:
208     type: OS::Heat::SoftwareConfig
209     condition: is_reboot_config_required
210     properties:
211       group: script
212       config: |
213         #!/bin/bash
214         # Stop os-collect-config to avoid any race collecting another
215         # deployment before reboot happens
216         systemctl stop os-collect-config.service
217         /sbin/reboot
218
219   RebootDeployment:
220     type: OS::Heat::SoftwareDeployment
221     depends_on: HostParametersDeployment
222     condition: is_reboot_config_required
223     properties:
224       name: RebootDeployment
225       server:  {get_param: server}
226       config: {get_resource: RebootConfig}
227       actions: ['CREATE'] # Only do this on CREATE
228       signal_transport: NO_SIGNAL
229
230 outputs:
231   result:
232     condition: is_host_config_required
233     value:
234       get_attr: [HostParametersDeployment, result]
235   stdout:
236     condition: is_host_config_required
237     value:
238       get_attr: [HostParametersDeployment, deploy_stdout]
239   stderr:
240     condition: is_host_config_required
241     value:
242       get_attr: [HostParametersDeployment, deploy_stderr]
243   status_code:
244     condition: is_host_config_required
245     value:
246       get_attr: [HostParametersDeployment, deploy_status_code]