X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Finfra-ansible.git;a=blobdiff_plain;f=roles%2Fallocate_cpu_cores%2Ftasks%2Fmain.yml;h=4c400bcece70217a11f78e221f8b26d0ba6e4b2f;hp=b1c835fe65b973061f1c0381ba50a47c2b4281ba;hb=86e9056a7ee8ec41856edb13b72273951edb3d87;hpb=b761808359bb9b38db9847e06bf6a074a09f7807 diff --git a/roles/allocate_cpu_cores/tasks/main.yml b/roles/allocate_cpu_cores/tasks/main.yml index b1c835f..4c400bc 100644 --- a/roles/allocate_cpu_cores/tasks/main.yml +++ b/roles/allocate_cpu_cores/tasks/main.yml @@ -1,5 +1,4 @@ --- - # Copyright 2019 Nokia # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,19 +16,19 @@ - name: Prepare. set_fact: - cloud_cpu_remain: [] - cloud_cpu_sets: {} + cpu_remain: [] + cpu_sets: {} - name: Get CPU topology. get_cpu_topology: - var: cloud_cpu_topology + var: cpu_topology - debug: - var: cloud_cpu_topology + var: cpu_topology - name: Make default performance profile. set_fact: perf_profile: { - platform_cpus: "{{ cloud_cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], cloud_default_platform_cpus, virtual_env, hosts | length < 2) }}" + platform_cpus: "{{ cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], platform_cpus, virtual_env, hosts | length < 2) }}" } - debug: var: perf_profile @@ -56,7 +55,7 @@ - name: Set collocated VM CPU set. set_fact: - vm_share_percent: "{{ 100 - (perf_profile['caas_cpu_pool_share'] | default(100) | int) }}" + vm_share_percent: "{{ 100 - (perf_profile['caas_cpu_pool_share'] | default(caas_cpu_pool_share_default) | int) }}" when: - "'compute' in hosts[hostname]['service_profiles']" - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) @@ -66,13 +65,22 @@ loop_control: loop_var: cpu_set with_items: - - { 'name': 'vm', 'request': "{{ cloud_cpu_topology | get_cpu_count_by_percent(vm_share_percent) }}", 'where': 'tail' } + - { 'name': 'vm', 'request': "{{ cpu_topology | get_cpu_count_by_percent(vm_share_percent) }}", 'where': 'tail' } when: - "'compute' in hosts[hostname]['service_profiles']" +- name: Make CaaS default CPU set. + include_tasks: make_cpu_sets.yaml + loop_control: + loop_var: cpu_set + with_items: + - { 'name': 'caas_default', 'request': "{{ cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], caas_default_pool_cpus, virtual_env, hosts | length < 2) }}", 'where': 'tail' } + when: + - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) + - name: Calculate CaaS CPU counts set_fact: - perf_profile: "{{ perf_profile | combine({ item.key: cloud_cpu_topology | get_cpu_count_by_percent(item.value) }) }}" + perf_profile: "{{ perf_profile | combine({ item.key: cpu_topology | get_cpu_count_by_percent(item.value) }) }}" with_dict: "{{ perf_profile['caas_cpu_pools'] | default({}) }}" when: hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) @@ -89,19 +97,29 @@ - name: Make set of remaining CPUs. set_fact: - cloud_cpu_remain: "{{ cloud_cpu_remain | union(item) }}" - with_items: "{{ cloud_cpu_topology.values() }}" + cpu_remain: "{{ cpu_remain | union(item) }}" + with_items: "{{ cpu_topology.values() }}" - debug: - var: cloud_cpu_remain + var: cpu_remain + +- name: Allocate remaining CPUs to CaaS default. + set_fact: + cpu_sets: "{{ cpu_sets | combine({ 'caas_default': cpu_sets['caas_default'] | default([]) | union(cpu_remain) }) }}" + cpu_remain: [] + when: + - "cpu_remain | length > 0" + - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) - name: Allocate remaining CPUs to platform. set_fact: - cloud_cpu_sets: "{{ cloud_cpu_sets | combine({ 'platform': cloud_cpu_sets['platform'] | default([]) | union(cloud_cpu_remain) }) }}" - cloud_cpu_remain: [] - when: "cloud_cpu_remain | length > 0" + cpu_sets: "{{ cpu_sets | combine({ 'platform': cpu_sets['platform'] | default([]) | union(cpu_remain) }) }}" + cpu_remain: [] + when: + - "cpu_remain | length > 0" + - not hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) - debug: - var: cloud_cpu_sets + var: cpu_sets - name: Make sure facts directory exists. file: @@ -111,7 +129,7 @@ - name: Save CPU allocation. template: - src: cloud_cpu_allocation.fact.j2 + src: cpu_allocation.fact.j2 dest: "{{ allocation_fact_file }}" register: cpu_allocation