Make own CPU allocation for CaaS default CPU pool
[ta/infra-ansible.git] / roles / allocate_cpu_cores / tasks / make_cpu_sets.yaml
1 ---
2 # Copyright 2019 Nokia
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - name: Set requested CPUs.
17   set_fact:
18     cpu_request: "{% if cpu_set.opt is defined %}{{ perf_profile[cpu_set.opt] }}{% else %}{{ cpu_set.request }}{% endif %}"
19
20 - name: Allocate CPU set.
21   set_fact:
22     allocated_cpu_set: "{{ cpu_topology | cpu_topology_alloc(cpu_request, cpu_set.where) }}"
23
24 - name: Append allocated CPU set.
25   set_fact:
26     combined_cpu_set: "{{ allocated_cpu_set | union(cpu_sets[cpu_set.name] | default([])) | sort }}"
27
28 - name: Make CPU set.
29   set_fact:
30     cpu_sets: "{{ cpu_sets | combine({ cpu_set.name: combined_cpu_set }) }}"
31     cpu_topology: "{{ cpu_topology | cpu_topology_trim(cpu_request, cpu_set.where) }}"
32
33 - name: Show created CPU sets.
34   debug:
35     var: cpu_sets
36
37 - name: Show CPU topology after sets creation.
38   debug:
39     var: cpu_topology