Skip to content

Commit 86e2602

Browse files
committed
update IMDB validation and add SAPEXE validation
1 parent d871eb8 commit 86e2602

17 files changed

Lines changed: 1364 additions & 279 deletions

File tree

plugins/module_utils/software_center/search.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def find_file(client, name, deduplicate, search_alternatives, search_upgrades=Fa
135135
last_option = software_search_alternatives_filtered[-1]['Title']
136136

137137
raise FileNotFoundError(
138-
f'More than one alternative was found: '
139-
f'{", ".join(names)}.\n'
138+
f'More than one alternative was found: {alternatives_count} files\n'
139+
f'Files: {", ".join(names)}\n'
140140
f'Please use a more specific filename '
141141
f'or set deduplicate parameter.\n'
142142
f'Options for deduplicate:\n'
@@ -164,7 +164,8 @@ def find_file(client, name, deduplicate, search_alternatives, search_upgrades=Fa
164164
last_option = software_filtered[-1]['Title']
165165

166166
raise FileNotFoundError(
167-
f'More than one result was found: {", ".join(names)}.\n'
167+
f'More than one result was found: {files_count} files\n'
168+
f'Files: {", ".join(names)}\n'
168169
f'Please use the correct full filename '
169170
f'or set deduplicate parameter.\n'
170171
f'Options for deduplicate:\n'
@@ -235,8 +236,12 @@ def _search_software_fuzzy(client, query, search_upgrades=False):
235236
if f'-{filename_id}' in r.get('Title', ''):
236237
fuzzy_results.append(_remove_useless_keys(r))
237238

239+
# Check if prefix search hit the 50-result limit (may have missed results)
240+
# If yes, fallback to paginated ID search to ensure completeness
241+
if len(results) >= 50:
242+
fuzzy_results = [] # Clear partial results, will use paginated ID search below
238243
# If empty and suggested_filename_next exists, try incremented version
239-
if len(fuzzy_results) == 0 and suggested_filename_next:
244+
elif len(fuzzy_results) == 0 and suggested_filename_next:
240245
results = _search_software(client, suggested_filename_next)
241246
for r in results:
242247
if f'-{filename_id}' in r.get('Title', ''):

roles/sap_software_download/README.md

Lines changed: 172 additions & 74 deletions
Large diffs are not rendered by default.

roles/sap_software_download/defaults/main.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ sap_software_download_suser_id: ''
99
# The password for the SAP S-User specified in 'sap_software_download_suser_id' (String).
1010
sap_software_download_suser_password: ''
1111

12+
# The directory where downloaded SAP software files will be stored (String).
13+
# It will be created if it does not exist. Must be an absolute path.
14+
sap_software_download_directory: '/software'
15+
1216
# A list of SAP software file names to download (List of Strings).
1317
sap_software_download_files: []
1418

@@ -25,13 +29,18 @@ sap_software_download_mp_stack_xml: true
2529
### Optional variables for controlling the download process
2630

2731
# Enables searching for alternative files if the requested file is not found (Boolean).
28-
# Only applies to files specified in 'sap_software_download_files'.
32+
# Only applies to files specified in 'sap_software_download_files', not Maintenance Plan files.
2933
# If set to 'false', the role will not search for alternatives.
34+
# NOTE: Files like IMDB_SERVER have strict naming and the variable 'sap_software_download_find_upgrades' for broader search.
35+
# Example: IMDB_SERVER20_067_4-80002046.SAR searches for: IMDB_SERVER20_067
3036
sap_software_download_find_alternatives: true
3137

32-
# The directory where downloaded SAP software files will be stored (String).
33-
# It will be created if it does not exist. Must be an absolute path.
34-
sap_software_download_directory: '/software'
38+
# Enables broader searching for alternative files if the requested file is not found (Boolean).
39+
# Only applies to files specified in 'sap_software_download_files', not Maintenance Plan files.
40+
# Only applies when file was not found with 'sap_software_download_find_alternatives set to 'true'.
41+
# If set to 'false', the role will not search for upgrade candidates.
42+
# Example: IMDB_SERVER20_067_4-80002046.SAR searches for: IMDB_SERVER20_067, IMDB_SERVER20_068, IMDB_SERVER20_
43+
sap_software_download_find_upgrades: false
3544

3645
# Determines whether to ignore errors when a requested file is not found (Boolean).
3746
# If set to 'true', the role will continue execution and download other files, even if some files are not found.
@@ -44,24 +53,19 @@ sap_software_download_ignore_file_not_found: false
4453
# If set to 'false', the role will fail if the specified Maintenance Plan is not found.
4554
sap_software_download_ignore_plan_not_found: false
4655

47-
# Enables validation of relationships between SAP software files (Boolean).
56+
# Enables validation of relationships between known combinations of SAP files (Boolean).
4857
# Only applies to files specified in 'sap_software_download_files', not Maintenance Plan files.
4958
# If set to 'false', no relationship validation will be performed.
50-
# Example: Verify version of IMDB_LCAPPS against IMDB_SERVER if IMDB_SERVER was found.
51-
# NOTE: This option will result in longer execution time
52-
# when 'sap_software_download_find_alternatives' is set to 'true',
53-
# because it attempts download in Dry run to gather list of alternative files for validation.
59+
# See section 'Explanation of relationship validation logic' in README.md for more information.
5460
sap_software_download_validate_relationships: true
5561

56-
# Enables automatic upgrade of related HANA components when SERVER version changes.
57-
# Only applies when 'sap_software_download_validate_relationships: true'.
58-
# If IMDB_SERVER is not found and 'search_upgrades' finds a newer revision,
59-
# all related components (AFL, LCAPPS) will be searched with matching revision.
60-
# Example: If SERVER 084 is removed and only available revision is 089,
61-
# then AFL/LCAPPS will search for 089* revisions.
62-
# WARNING: This does not guarantee installation compatibility due to SAP's
63-
# inconsistent versioning (filename vs. actual package version).
64-
# Recommended to test before production use.
62+
# Enables automatic upgrade of related known combinations of SAP files when leading component version changes.
63+
# Only applies when 'sap_software_download_validate_relationships' is set to 'true'.
64+
# If set to 'false', no search for upgrade candidates before validation will be performed.
65+
# See section 'Explanation of relationship validation logic' in README.md for more information.
66+
# NOTE: Important for when SAP releases new patch for SAP HANA Revision, because:
67+
# - Previous patch of 'IMDB_SERVER' will be removed and only new patch will be available to download.
68+
# - Previous patch for other components like 'IMDB_AFL' will remain available to download as well as new patch.
6569
sap_software_download_upgrade_relationships: false
6670

6771
# Determines whether to ignore warnings during file relationship validation (Boolean).
@@ -80,6 +84,7 @@ sap_software_download_ignore_validate_credentials: false
8084
# - 'first': Download the first file found (generally oldest).
8185
# - 'last': Download the last file found (generally newest).
8286
# - '': No deduplication, will cause an error if multiple files with the same name are found.
87+
# Can be used to find list of all available files without downloading them.
8388
sap_software_download_deduplicate: last
8489

8590
# Enables checksum validation of existing files present in 'sap_software_download_directory' (Boolean).
@@ -112,7 +117,7 @@ sap_software_download_use_venv: true
112117
# sap_software_download_python_package: ''
113118

114119
# The list of the OS packages that provide modules for the desired Python version (List of Strings).
115-
# Required modules: wheel, urllib3, requests, beautifulsoup4, lxml
120+
# Required modules: 'wheel', 'urllib3', 'requests', 'beautifulsoup4', 'lxml'
116121
# The listed package versions must match the Python version specified by 'sap_software_download_python_interpreter'.
117122
# The default value is determined by the operating system and is set in the corresponding OS-specific variables file.
118123
# Examples:

roles/sap_software_download/tasks/download_files.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
33

4+
- name: SAP Software Download - Download - SAP Software Files - Notice before download
5+
ansible.builtin.debug:
6+
msg: |
7+
INFO: Download will be started for {{ __sap_software_download_files | d([]) | length }} file(s).
8+
Large files (Media CD/DVD, Exports, Databases, etc.) may take considerably longer to download.
9+
Following task might appear unresponsive during download,
10+
but it is working in the background. Please wait for results.
11+
412
- name: SAP Software Download - Download - SAP Software Files - Get files
513
community.sap_launchpad.software_center_download:
614
suser_id: "{{ sap_software_download_suser_id }}"
715
suser_password: "{{ sap_software_download_suser_password }}"
816
search_query: "{{ item }}"
917
dest: "{{ sap_software_download_directory }}"
1018
search_alternatives: "{{ sap_software_download_find_alternatives | d(true) }}"
19+
search_upgrades: "{{ sap_software_download_find_upgrades | d(false) }}"
1120
deduplicate: "{{ sap_software_download_deduplicate }}"
1221
validate_checksum: "{{ sap_software_download_validate_checksum | d(false) }}"
1322
# Loop condition acts as when conditional

roles/sap_software_download/tasks/download_plan.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
33

4+
- name: SAP Software Download - Download - SAP Software Files - Notice before download
5+
ansible.builtin.debug:
6+
msg: |
7+
INFO: Download will be started for {{ __sap_software_download_register_mp_files.download_basket | d([]) | length }} file(s).
8+
Large files (Media CD/DVD, Exports, Databases, etc.) may take considerably longer to download.
9+
Following task might appear unresponsive during download,
10+
but it is working in the background. Please wait for results.
11+
412
- name: SAP Software Download - Download - Maintenance Plan - Get files
513
community.sap_launchpad.software_center_download:
614
suser_id: "{{ sap_software_download_suser_id }}"
@@ -10,7 +18,7 @@
1018
dest: "{{ sap_software_download_directory }}"
1119
validate_checksum: "{{ sap_software_download_validate_checksum | d(false) }}"
1220
# Loop condition acts as when conditional
13-
loop: "{{ __sap_software_download_fact_mp_files.download_basket | d([]) }}"
21+
loop: "{{ __sap_software_download_register_mp_files.download_basket | d([]) }}"
1422
loop_control:
1523
label: "{{ item.Filename }} : {{ __sap_software_download_files_plan_results.msg | d('') }}"
1624
register: __sap_software_download_files_plan_results

roles/sap_software_download/tasks/download_stack.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
---
33

44
- name: SAP Software Download - Download - Maintenance Plan Stack XML - Get file
5-
when: sap_software_download_use_venv | d(true)
65
community.sap_launchpad.maintenance_planner_stack_xml_download:
76
suser_id: "{{ sap_software_download_suser_id }}"
87
suser_password: "{{ sap_software_download_suser_password }}"

roles/sap_software_download/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
file: download_plan.yml
7474
when:
7575
- sap_software_download_mp_transaction | length > 0
76-
- __sap_software_download_fact_mp_files.download_basket is defined
77-
and __sap_software_download_fact_mp_files.download_basket | length > 0
76+
- __sap_software_download_register_mp_files.download_basket is defined
77+
and __sap_software_download_register_mp_files.download_basket | length > 0
7878

7979
- name: SAP Software Download - Include tasks to download files in the variable 'sap_software_download_files'
8080
ansible.builtin.include_tasks:
Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,23 @@
11
# SPDX-License-Identifier: Apache-2.0
22
---
33

4-
- name: SAP Software Download - Maintenance Plan - Python venv - Get list of files
5-
when: sap_software_download_use_venv | d(true)
4+
- name: SAP Software Download - Maintenance Plan - Get list of files
65
community.sap_launchpad.maintenance_planner_files:
76
suser_id: "{{ sap_software_download_suser_id }}"
87
suser_password: "{{ sap_software_download_suser_password }}"
98
transaction_name: "{{ sap_software_download_mp_transaction }}"
10-
register: __sap_software_download_register_mp_files_venv
9+
register: __sap_software_download_register_mp_files
1110
retries: 1
12-
environment:
13-
PATH: "{{ __sap_software_download_fact_venv_path }}"
14-
PYTHONPATH: "{{ __sap_software_download_fact_venv_pythonpath }}"
15-
VIRTUAL_ENV: "{{ __sap_software_download_register_temp_venv.path }}"
11+
environment: "{{ __venv_environment if sap_software_download_use_venv | d(true) else {} }}"
1612
vars:
1713
ansible_python_interpreter: "{{ __sap_software_download_fact_python_interpreter_path }}"
14+
__venv_environment:
15+
PATH: "{{ __sap_software_download_fact_venv_path }}"
16+
PYTHONPATH: "{{ __sap_software_download_fact_venv_pythonpath }}"
17+
VIRTUAL_ENV: "{{ __sap_software_download_register_temp_venv.path }}"
1818
changed_when: false # Getting list of files does not change anything
1919
ignore_errors: true # Errors are ignored and validated afterwards
2020

21-
22-
- name: SAP Software Download - Maintenance Plan - Default Python - Get list of files
23-
when: not sap_software_download_use_venv | d(true)
24-
community.sap_launchpad.maintenance_planner_files:
25-
suser_id: "{{ sap_software_download_suser_id }}"
26-
suser_password: "{{ sap_software_download_suser_password }}"
27-
transaction_name: "{{ sap_software_download_mp_transaction }}"
28-
register: __sap_software_download_register_mp_files_default
29-
retries: 1
30-
vars:
31-
ansible_python_interpreter: "{{ __sap_software_download_fact_python_interpreter_path }}"
32-
changed_when: false # Getting list of files does not change anything
33-
ignore_errors: true # Errors are ignored and validated afterwards
34-
35-
36-
- name: SAP Software Download - Maintenance Plan - Set fact with list of files
37-
ansible.builtin.set_fact:
38-
__sap_software_download_fact_mp_files:
39-
"{{ __sap_software_download_register_mp_files_venv
40-
if sap_software_download_use_venv | d(true)
41-
else __sap_software_download_register_mp_files_default }}"
42-
43-
4421
- name: SAP Software Download - Maintenance Plan - Fail if Maintenance Plan was not found
4522
ansible.builtin.fail:
4623
msg: |
@@ -49,7 +26,7 @@
4926
or ignore this error with 'sap_software_download_ignore_plan_not_found' set to 'true'.
5027
when:
5128
- not sap_software_download_ignore_plan_not_found | d(false)
52-
- __sap_software_download_fact_mp_files.failed
29+
- __sap_software_download_register_mp_files.failed
5330

5431
- name: SAP Software Download - Maintenance Plan - Inform that Maintenance Plan was not found but error is ignored
5532
ansible.builtin.debug:
@@ -58,4 +35,4 @@
5835
Error was ignored with 'sap_software_download_ignore_plan_not_found' set to 'true'.
5936
when:
6037
- sap_software_download_ignore_plan_not_found | d(false)
61-
- __sap_software_download_fact_mp_files.failed
38+
- __sap_software_download_register_mp_files.failed

0 commit comments

Comments
 (0)