Skip to content

Commit

Permalink
Extracting SGA and processes parameters from oracle_databases and ora…
Browse files Browse the repository at this point in the history
…cle_asm_instance improved
  • Loading branch information
Thilo Solbrig authored and Rendanic committed Oct 25, 2024
1 parent 370ab61 commit ce4509f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 48 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/sga_calculation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- "orahost_meta: Applying 'lower' filter to oracle_databases+oracle_asm_instance converts list to string (oravirt#484)"
9 changes: 2 additions & 7 deletions roles/orahost_meta/tasks/aggregate_processes.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
---
- name: aggregate_processes | Pick processes parameter
ansible.builtin.set_fact:
__orahost_oracle_database_processes: |
{{ (__orahost_oracle_database.init_parameters | selectattr('name', 'equalto', 'processes'))[0].value }}
- name: aggregate_processes | Sum up processes
ansible.builtin.set_fact:
oracle_databases_processes_sum: |
{{ (oracle_databases_processes_sum | default(0) | int) + (__orahost_oracle_database_processes | int) }}
{{ (oracle_databases_processes_sum | default(0) | int) + (__orahost_oracle_database_processes.value | int) }}
- name: aggregate_processes | Calc max processes
ansible.builtin.set_fact:
oracle_databases_processes_max: >-
{{ [(oracle_databases_processes_max | default(0) | int), (__orahost_oracle_database_processes | int)] | max }}
{{ [(oracle_databases_processes_max | default(0) | int), (__orahost_oracle_database_processes.value | int)] | max }}
24 changes: 2 additions & 22 deletions roles/orahost_meta/tasks/aggregate_sgas.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
---
- name: aggregate_sgas | Reset __orahost_oracle_database_sga
ansible.builtin.set_fact:
__orahost_oracle_database_sga: "0"

- name: aggregate_sgas | sga_max_size preceeds sga_target
block:
- name: aggregate_sgas | Derive SGA size from sga_max_size
ansible.builtin.set_fact:
__orahost_oracle_database_sga: |
{{ (__orahost_oracle_database.init_parameters
| selectattr('name','equalto', 'sga_max_size'))[0].value | default(0) | human_to_bytes }}
- name: aggregate_sgas | Derive SGA size from sga_target
ansible.builtin.set_fact:
__orahost_oracle_database_sga: |
{{ (__orahost_oracle_database.init_parameters
| selectattr('name','equalto', 'sga_target'))[0].value | default(0) | human_to_bytes }}
when:
- __orahost_oracle_database_sga == "0"

- name: aggregate_sgas | Sum up SGAs
ansible.builtin.set_fact:
oracle_databases_sga_sum: |
{{ (oracle_databases_sga_sum | default(0) | int) + (__orahost_oracle_database_sga | int) }}
{{ (oracle_databases_sga_sum | default(0) | int) + (__orahost_oracle_database_sga.value | human_to_bytes | int) }}
- name: aggregate_sgas | Calc max SGA
ansible.builtin.set_fact:
oracle_databases_sga_max: |
{{ [(oracle_databases_sga_max | default(0) | int), (__orahost_oracle_database_sga | int)] | max }}"
{{ [(oracle_databases_sga_max | default(0) | int), (__orahost_oracle_database_sga.value | human_to_bytes | int)] | max }}"
47 changes: 28 additions & 19 deletions roles/orahost_meta/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,38 @@
{{ (__orahost_kdump_state.status.ActiveState == 'active') | ternary(0, 1) }}
- name: Calculate SGA aggregates
ansible.builtin.include_tasks: aggregate_sgas.yml
loop: |
{{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') )
+ ( oracle_asm_instance | default ([]) )) | lower }}
loop_control:
loop_var: __orahost_oracle_database
label: >-
oracle_db_name: {{ __orahost_oracle_database.oracle_db_name | default('') }}
when:
"'sga_target' in __orahost_oracle_database.init_parameters | map(attribute='name') or
'sga_max_size' in __orahost_oracle_database.init_parameters | map(attribute='name') "
block:
- name: Extract SGA parameters, choose sga_max_size over sga_target if both are definied
ansible.builtin.set_fact:
__orahost_oracle_database_sgas: >-
{{ (__orahost_oracle_database_sgas | default([])) +
(( __orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_max_size$') ) | length > 0 )
| ternary(__orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_max_size$'),
__orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_target$')) }}
loop: >-
{{ ((oracle_databases | default([])) + (oracle_asm_instance | default([])))
| map(attribute='init_parameters', default=[]) }}
loop_control:
loop_var: __orahost_oracle_database_init_parameter
when: (__orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)(sga_target|sga_max_size)$')) | length > 0

- name: Aggregate SGAs
ansible.builtin.include_tasks: aggregate_sgas.yml
loop: "{{ __orahost_oracle_database_sgas }}"
loop_control:
loop_var: __orahost_oracle_database_sga
label: "{{ __orahost_oracle_database_sga.name + ': ' + __orahost_oracle_database_sga.value }}"

- name: Calculate processes aggregates
ansible.builtin.include_tasks: aggregate_processes.yml
loop: |
{{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') )
+ ( oracle_asm_instance | default ([]) )) | lower }}
loop: >-
{{ ((oracle_databases | default([])) + (oracle_asm_instance | default([])))
| map(attribute='init_parameters', default=[])
| flatten
| selectattr('name', 'match', '^(?i)processes$') }}
loop_control:
loop_var: __orahost_oracle_database
label: >-
oracle_db_name: {{ __orahost_oracle_database.oracle_db_name | default('') }}
when:
"'processes' in __orahost_oracle_database.init_parameters | map(attribute='name')"
loop_var: __orahost_oracle_database_processes
label: "{{ __orahost_oracle_database_processes.name + ': ' + __orahost_oracle_database_processes.value | string }}"

- name: Count number of instances (including ASM)
ansible.builtin.set_fact:
Expand Down

0 comments on commit ce4509f

Please sign in to comment.