Skip to content

Commit

Permalink
Merge pull request #480 from berndfinger/issue-475
Browse files Browse the repository at this point in the history
sap_install_media_detect: Also recognize MP Stack XML files and correctly handle VCH AFL files
  • Loading branch information
sean-freeman authored Sep 27, 2023
2 parents 6c238ab + f430d74 commit e9b0ca5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions roles/sap_install_media_detect/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ sap_install_media_detect_kernel: false
sap_install_media_detect_kernel_db: '' # saphana, sapase, sapmaxdb, oracledb, ibmdb2
# (only necessary if there is more than one SAPEXEDB file in the source directory)
sap_install_media_detect_webdisp: false
sap_install_media_detect_mpstack: false
sap_install_media_detect_export: '' # saps4hana, sapbw4hana, sapecc, sapecc_ides,
# sapnwas_abap, sapnwas_java, sapsolman_abap, sapsolman_java

Expand Down
16 changes: 13 additions & 3 deletions roles/sap_install_media_detect/files/tmp/sapfile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ for _FILE in "$@"; do
/RAR archive data/{_file_type="rar"}
/Zip archive data/{_file_type="zip"}
/SAPCAR archive data/{_file_type="sapcar"}
/XML/&&/ASCII/{_file_type="xml"}
/directory/{_file_type="dir"}
END{print _file_type}')
if [[ ${_GENERIC_FILE_TYPE}. == "rarexe." ]]; then
Expand All @@ -207,6 +208,8 @@ for _FILE in "$@"; do
_list_content="zipinfo -1"
elif [[ ${_GENERIC_FILE_TYPE}. == "sapcar." ]]; then
_list_content="${_SAPCAR_FILE} -tvf"
elif [[ ${_GENERIC_FILE_TYPE}. == "xml." ]]; then
_list_content="cat"
elif [[ ${_GENERIC_FILE_TYPE}. == "dir." ]]; then
_list_content=""
fi
Expand Down Expand Up @@ -240,7 +243,7 @@ for _FILE in "$@"; do
/S4/&&/LANG/{_sap_file_type="sap_s4hana_lang"}
/S4/&&/EXPORT/{_sap_file_type="sap_export_s4hana"}
/BW4/&&/EXPORT/{_sap_file_type="sap_export_bw4hana"}
/VCH/&&/\.SAR/{_sap_file_type="sap_vch_afl"}
/VCH/&&/\.SAR/{_sap_file_type="saphana_vch_afl"}
END{print _sap_file_type}')
if [[ ${SAP_FILE_TYPE_FROM_FILENAME}. == "sap_kernel_db." ]]; then
SAP_FILE_TYPE_FROM_FILENAME=$(eval "${_list_content}" "${_FILE}" | awk '
Expand All @@ -256,7 +259,8 @@ for _FILE in "$@"; do
elif [[ ${_GENERIC_FILE_TYPE}. == "rarexe." ||
${_GENERIC_FILE_TYPE}. == "rar." ||
${_GENERIC_FILE_TYPE}. == "zip." ||
${_GENERIC_FILE_TYPE}. == "sapcar." ]]; then
${_GENERIC_FILE_TYPE}. == "sapcar." ||
${_GENERIC_FILE_TYPE}. == "xml." ]]; then
_SAP_FILE_TYPE=$(eval "${_list_content}" "${_FILE}" | awk '
BEGIN{_sap_file_type="sap_unknown"}
/BD_SYBASE_ASE/{_sap_file_type="sapase"}
Expand All @@ -273,6 +277,7 @@ for _FILE in "$@"; do
/DATA_UNITS\/EXP[0-9]/{_sap_file_type="sap_export_nwas_abap"}
/DATA_UNITS\/JAVA_EXPORT_JDMP/{_sap_file_type="sap_export_nwas_java"}
/DATA_UNITS\/SOLMAN/&&/_JAVA_UT/{_sap_file_type="sap_export_solman_java"}
/<sp-stacks/{_sap_file_type="sap_mp_xml"}
/format error in header/{_sap_file_type="format_error_in_header"}
END{print _sap_file_type}')
if [[ ${_SAP_FILE_TYPE}. == "sap_export_nwas_abap." && ${_GENERIC_FILE_TYPE}. == "zip." ]]; then
Expand Down Expand Up @@ -343,7 +348,7 @@ for _FILE in "$@"; do
ibmdb2|ibmdb2_client|ibmdb2_license)
_TARGET_DIRECTORY="ibmdb2"
;;
saphana|saphana_other|sap_vch_afl)
saphana|saphana_other|saphana_vch_afl)
_TARGET_DIRECTORY="sap_hana"
_EXTRACTION_DIRECTORY="sap_hana_extracted"
_EXTRACT="y"
Expand All @@ -363,6 +368,11 @@ for _FILE in "$@"; do
_EXTRACTION_DIRECTORY="none"
_EXTRACT="n"
;;
sap_mp_xml)
_TARGET_DIRECTORY="sap_swpm_download_basket"
_EXTRACTION_DIRECTORY="none"
_EXTRACT="n"
;;
sap_export*)
;;
*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@
- sap_install_media_detect_webdisp
- sap_swpm_web_dispatcher_file_name_get.stdout_lines | count > 1

- name: SAP Install Media Detect - Find files after extraction - Find Maintenance Planner Stack XML file
ansible.builtin.shell: set -o pipefail && ls -1tr *.xml | tail -1
args:
chdir: "{{ sap_swpm_software_path }}"
register: sap_swpm_mp_xml_file_name_get
changed_when: false
when: sap_install_media_detect_mpstack

- name: SAP Install Media Detect - Find files after extraction - Find SAP ECC Export
ansible.builtin.find:
paths: "{{ __sap_install_media_detect_software_main_directory }}/sap_export_ecc_extracted"
Expand Down
3 changes: 2 additions & 1 deletion roles/sap_install_media_detect/tasks/organize_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
- (line_item.archive_type == 'zip' or
line_item.archive_type == 'rarexe' or
line_item.archive_type == 'rar' or
line_item.archive_type == 'sapcar')
line_item.archive_type == 'sapcar' or
line_item.archive_type == 'xml')

- name: SAP Install Media Detect - Organize all files - Create target directory 'sap_hana'
ansible.builtin.file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
when:
(item.stdout.split(';')[1] == 'sapcar') or
(item.stdout.split(';')[1] == 'sap_jvm') or
(item.stdout.split(';')[1] == 'sap_mp_xml') or
(item.stdout.split(';')[1] == 'sap_unknown') or
(sap_install_media_detect_swpm and item.stdout.split(';')[1] == 'sap_swpm') or
(sap_install_media_detect_hostagent and item.stdout.split(';')[1] == 'sap_hostagent') or
Expand All @@ -56,7 +57,8 @@
(sap_install_media_detect_webdisp and item.stdout.split(';')[1] == 'sap_webdisp') or
(sap_install_media_detect_db == 'saphana' and (
item.stdout.split(';')[1] == 'saphana' or
item.stdout.split(';')[1] == 'saphana_other')
item.stdout.split(';')[1] == 'saphana_other' or
item.stdout.split(';')[1] == 'saphana_vch_afl')
) or
(sap_install_media_detect_db_client == 'saphana' and item.stdout.split(';')[1] == 'saphana_client') or
(sap_install_media_detect_db == 'sapmaxdb' and item.stdout.split(';')[1] == 'sapmaxdb') or
Expand Down
9 changes: 9 additions & 0 deletions roles/sap_install_media_detect/tasks/set_global_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
sap_swpm_igs_helper_file_name: "{{ sap_swpm_igs_helper_file_name_get.stdout }}"
when: sap_install_media_detect_igs

- name: SAP Install Media Detect - Detection completed - Set facts for SAP Maintenance Planner Stack XML files
ansible.builtin.set_fact:
sap_swpm_mp_stack_path: "{{ sap_swpm_software_path }}/"
sap_swpm_mp_stack_file_name: "{{ sap_swpm_mp_xml_file_name_get.stdout }}"
ignore_errors: true
when: sap_install_media_detect_mpstack

- name: SAP Install Media Detect - Detection completed - Set facts for WebDisp
ansible.builtin.set_fact:
sap_swpm_web_dispatcher_path: "{{ sap_swpm_software_path }}/"
Expand Down Expand Up @@ -241,6 +248,8 @@
- sap_swpm_kernel_independent_file_name
- sap_swpm_web_dispatcher_path
- sap_swpm_web_dispatcher_file_name
- sap_swpm_mp_stack_path
- sap_swpm_mp_stack_file_name

- name: SAP Install Media Detect - Detection completed - Display result
ansible.builtin.debug:
Expand Down

0 comments on commit e9b0ca5

Please sign in to comment.