aboutsummaryrefslogtreecommitdiffstats
path: root/extraconfig/pre_network/host_config_and_reboot.yaml
blob: e4898a6ec5e3fff40b52d4dda780e29197bcadb7 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
heat_template_version: pike

description: >
  All configurations which require reboot should be initiated via PreNetworkConfig. After
  this configuration is completed, the corresponding node will be rebooted.

parameters:
  server:
    type: string
  RoleParameters:
    type: json
    description: Role Specific parameters
    default: {}
  ServiceNames:
    type: comma_delimited_list
    default: []
  HostCpusList:
    default: "0"
    description: List of cores to be used for host process
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]+"
  NeutronDpdkCoreList:
    default: ""
    description: List of cores to be used for DPDK Poll Mode Driver
    type: string
    constraints:
      - allowed_pattern: "[0-9,-]*"
  NeutronDpdkMemoryChannels:
    default: ""
    description: Number of memory channels to be used for DPDK
    type: string
    constraints:
      - allowed_pattern: "[0-9]*"
  NeutronDpdkSocketMemory:
    default: ""
    description: Memory allocated for each socket
    type: string
  NeutronDpdkDriverType:
    default: "vfio-pci"
    description: DPDK Driver type
    type: string

conditions:
  is_host_config_required: {not: {equals: [{get_param: [RoleParameters, KernelArgs]}, ""]}}
  # YAQL is enabled in conditions with https://review.openstack.org/#/c/467506/
  is_dpdk_config_required:
    yaql:
      expression: $.data.service_names.contains('neutron_ovs_dpdk_agent')
      data:
        service_names: {get_param: ServiceNames}
  is_reboot_config_required:
    or:
      - is_host_config_required
      - is_dpdk_config_required

resources:
  RoleParametersValue:
    type: OS::Heat::Value
    properties:
      type: json
      value:
        map_replace:
          - map_replace:
            - HostCpusList: HostCpusList
              NeutronDpdkCoreList: NeutronDpdkCoreList
              NeutronDpdkMemoryChannels: NeutronDpdkMemoryChannels
              NeutronDpdkSocketMemory: NeutronDpdkSocketMemory
            - values: {get_param: [RoleParameters]}
          - values:
              HostCpusList: {get_param: HostCpusList}
              NeutronDpdkCoreList: {get_param: NeutronDpdkCoreList}
              NeutronDpdkMemoryChannels: {get_param: NeutronDpdkMemoryChannels}
              NeutronDpdkSocketMemory: {get_param: NeutronDpdkSocketMemory}

  HostParametersConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_host_config_required
    properties:
      group: ansible
      inputs:
        - name: _KERNEL_ARGS_
        - name: _TUNED_PROFILE_NAME_
        - name: _TUNED_CORES_
      outputs:
        - name: result
      config:
        get_file: ansible_host_config.yaml

  HostParametersDeployment:
    type: OS::Heat::SoftwareDeployment
    condition: is_host_config_required
    properties:
      name: HostParametersDeployment
      server:  {get_param: server}
      config: {get_resource: HostParametersConfig}
      actions: ['CREATE'] # Only do this on CREATE
      input_values:
        _KERNEL_ARGS_: {get_param: [RoleParameters, KernelArgs]}
        _TUNED_PROFILE_NAME_: {get_param: [RoleParameters, TunedProfileName]}
        _TUNED_CORES_: {get_param: [RoleParameters, HostIsolatedCoreList]}

  EnableDpdkConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_dpdk_config_required
    properties:
      group: script
      config:
        str_replace:
          template: |
            #!/bin/bash
            set -x
            # DO NOT use --detailed-exitcodes
            puppet apply --logdest console \
              --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules \
              -e '
                class {"vswitch::dpdk":
                  host_core_list  => "$HOST_CORES",
                  pmd_core_list   => "$PMD_CORES",
                  memory_channels => "$MEMORY_CHANNELS",
                  socket_mem      => "$SOCKET_MEMORY",
                }
              '
          params:
            $HOST_CORES: {get_attr: [RoleParametersValue, value, HostCpusList]}
            $PMD_CORES: {get_attr: [RoleParametersValue, value, NeutronDpdkCoreList]}
            $MEMORY_CHANNELS: {get_attr: [RoleParametersValue, value, NeutronDpdkMemoryChannels]}
            $SOCKET_MEMORY: {get_attr: [RoleParametersValue, value, NeutronDpdkSocketMemory]}

  EnableDpdkDeployment:
    type: OS::Heat::SoftwareDeployment
    condition: is_dpdk_config_required
    properties:
      name: EnableDpdkDeployment
      server:  {get_param: server}
      config: {get_resource: EnableDpdkConfig}
      actions: ['CREATE'] # Only do this on CREATE

  RebootConfig:
    type: OS::Heat::SoftwareConfig
    condition: is_reboot_config_required
    properties:
      group: script
      config: |
        #!/bin/bash
        # Stop os-collect-config to avoid any race collecting another
        # deployment before reboot happens
        systemctl stop os-collect-config.service
        /sbin/reboot

  RebootDeployment:
    type: OS::Heat::SoftwareDeployment
    depends_on: HostParametersDeployment
    condition: is_reboot_config_required
    properties:
      name: RebootDeployment
      server:  {get_param: server}
      config: {get_resource: RebootConfig}
      actions: ['CREATE'] # Only do this on CREATE
      signal_transport: NO_SIGNAL

outputs:
  result:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, result]
  stdout:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_stdout]
  stderr:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_stderr]
  status_code:
    condition: is_host_config_required
    value:
      get_attr: [HostParametersDeployment, deploy_status_code]