From 90b322d4aa0250da0ed1440c61b57bf30313c8b3 Mon Sep 17 00:00:00 2001 From: simran Date: Tue, 6 Oct 2020 14:52:37 -0700 Subject: [PATCH 1/3] Workaround for installation when using exe archive --- hana/enable_cost_optimized.sls | 11 ++++++++++- hana/extract_hana_package.sls | 7 +------ hana/install.sls | 9 +++++++++ hana/monitoring.sls | 11 ++++++++++- saphanabootstrap-formula.changes | 5 +++++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/hana/enable_cost_optimized.sls b/hana/enable_cost_optimized.sls index c7805f5..e238bb1 100644 --- a/hana/enable_cost_optimized.sls +++ b/hana/enable_cost_optimized.sls @@ -1,7 +1,16 @@ {%- from "hana/map.jinja" import hana with context -%} -{%- from "hana/extract_hana_package.sls" import hana_extract_dir with context -%} {% set host = grains['host'] %} +{% set hana_extract_dir = hana.hana_extract_dir %} + +# Below is temporary workaround to update the software installation path when using unrar for HANA multipart rar archive +# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive +# Below logic finds the extraction location based on name of multipart exe archive filename +{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} +{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} +{% set archive_name = archive_base_name.split('_')[0] %} +{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} +{% endif %} {% for node in hana.nodes %} {% if node.host == host and node.scenario_type is defined and node.scenario_type.lower() == 'cost-optimized' and node.cost_optimized_parameters is defined%} diff --git a/hana/extract_hana_package.sls b/hana/extract_hana_package.sls index 2a7e415..bdbd20c 100644 --- a/hana/extract_hana_package.sls +++ b/hana/extract_hana_package.sls @@ -25,6 +25,7 @@ install_unrar_package: pkg.installed: - name: {{ unrar_package }} +# unrar tool does not have the option to skip extracting top-level directory when using multipart exe archives# extract_hana_multipart_archive: cmd.run: - name: unrar x {{ hana_package }} @@ -32,12 +33,6 @@ extract_hana_multipart_archive: - require: - install_unrar_package -{# Below is temporary workaround to update the extraction path when using unrar for multipart rar archive#} -{# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive#} -{% set archive_base_name = salt['file.basename'](hana_package.split('.')[0]) %} -{% set archive_name = archive_base_name.split('_')[0] %} -{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} - {%- elif hana_package.endswith((".sar", ".SAR")) and hana.sapcar_exe_file is defined %} extract_hdbserver_sar_archive: diff --git a/hana/install.sls b/hana/install.sls index 310d4f6..be01705 100644 --- a/hana/install.sls +++ b/hana/install.sls @@ -2,6 +2,15 @@ {% set host = grains['host'] %} {% set hana_extract_dir = hana.hana_extract_dir %} +# Below is temporary workaround to update the software installation path when using unrar for HANA multipart rar archive# +# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive +# Below logic finds the extraction location based on name of multipart exe archive filename +{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} +{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} +{% set archive_name = archive_base_name.split('_')[0] %} +{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} +{% endif %} + include: - .enable_cost_optimized diff --git a/hana/monitoring.sls b/hana/monitoring.sls index e72d8f8..f1640ce 100644 --- a/hana/monitoring.sls +++ b/hana/monitoring.sls @@ -1,7 +1,16 @@ {%- from "hana/map.jinja" import hana with context -%} -{%- from "hana/extract_hana_package.sls" import hana_extract_dir with context -%} {% set pydbapi_output_dir = '/tmp/pydbapi' %} +{% set hana_extract_dir = hana.hana_extract_dir %} + +# Below is temporary workaround to update the software path when using unrar for HANA multipart rar archive +# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive +# Below logic finds the extraction location based on name of multipart exe archive filename +{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} +{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} +{% set archive_name = archive_base_name.split('_')[0] %} +{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} +{% endif %} {% for node in hana.nodes if node.host == grains['host'] %} diff --git a/saphanabootstrap-formula.changes b/saphanabootstrap-formula.changes index 2a1aef2..155b2dc 100644 --- a/saphanabootstrap-formula.changes +++ b/saphanabootstrap-formula.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Oct 6 21:36:18 UTC 2020 - Simranpal Singh + +- Fix the hana media extraction and installation logic when using exe archives + ------------------------------------------------------------------- Sat Oct 3 04:59:38 UTC 2020 - Simranpal Singh From 38598ad49a0d251cac2a97a73cff3d9c647a5083 Mon Sep 17 00:00:00 2001 From: simran Date: Thu, 8 Oct 2020 11:41:57 -0700 Subject: [PATCH 2/3] Define macros for exe extraction and udpate spec file --- hana/enable_cost_optimized.sls | 12 ++---------- hana/install.sls | 12 ++---------- hana/macros/get_hana_exe_extract_dir.sls | 12 ++++++++++++ hana/monitoring.sls | 12 ++---------- saphanabootstrap-formula.spec | 2 ++ 5 files changed, 20 insertions(+), 30 deletions(-) create mode 100644 hana/macros/get_hana_exe_extract_dir.sls diff --git a/hana/enable_cost_optimized.sls b/hana/enable_cost_optimized.sls index e238bb1..b1791d3 100644 --- a/hana/enable_cost_optimized.sls +++ b/hana/enable_cost_optimized.sls @@ -1,16 +1,8 @@ {%- from "hana/map.jinja" import hana with context -%} +{%- from 'hana/macros/get_hana_exe_extract_dir.sls' import get_hana_exe_extract_dir with context %} +{% set hana_extract_dir = get_hana_exe_extract_dir(hana) %} {% set host = grains['host'] %} -{% set hana_extract_dir = hana.hana_extract_dir %} - -# Below is temporary workaround to update the software installation path when using unrar for HANA multipart rar archive -# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive -# Below logic finds the extraction location based on name of multipart exe archive filename -{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} -{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} -{% set archive_name = archive_base_name.split('_')[0] %} -{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} -{% endif %} {% for node in hana.nodes %} {% if node.host == host and node.scenario_type is defined and node.scenario_type.lower() == 'cost-optimized' and node.cost_optimized_parameters is defined%} diff --git a/hana/install.sls b/hana/install.sls index be01705..47f52d4 100644 --- a/hana/install.sls +++ b/hana/install.sls @@ -1,15 +1,7 @@ {%- from "hana/map.jinja" import hana with context -%} +{%- from 'hana/macros/get_hana_exe_extract_dir.sls' import get_hana_exe_extract_dir with context %} {% set host = grains['host'] %} -{% set hana_extract_dir = hana.hana_extract_dir %} - -# Below is temporary workaround to update the software installation path when using unrar for HANA multipart rar archive# -# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive -# Below logic finds the extraction location based on name of multipart exe archive filename -{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} -{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} -{% set archive_name = archive_base_name.split('_')[0] %} -{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} -{% endif %} +{% set hana_extract_dir = get_hana_exe_extract_dir(hana) %} include: - .enable_cost_optimized diff --git a/hana/macros/get_hana_exe_extract_dir.sls b/hana/macros/get_hana_exe_extract_dir.sls new file mode 100644 index 0000000..4bdd9ca --- /dev/null +++ b/hana/macros/get_hana_exe_extract_dir.sls @@ -0,0 +1,12 @@ +{% macro get_hana_exe_extract_dir(hana) -%} +{%- set hana_extract_dir = hana.hana_extract_dir %} + {#- Below is temporary workaround to update the software installation path when using unrar for HANA multipart rar archive#} + {#- TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive#} + {#- Below logic finds the extraction location based on name of multipart exe archive filename#} + {%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} + {%- set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} + {%- set archive_name = archive_base_name.split('_')[0] %} + {%- set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} + {%- endif %} +{{- hana_extract_dir }} +{%- endmacro %} \ No newline at end of file diff --git a/hana/monitoring.sls b/hana/monitoring.sls index f1640ce..e56c52f 100644 --- a/hana/monitoring.sls +++ b/hana/monitoring.sls @@ -1,16 +1,8 @@ {%- from "hana/map.jinja" import hana with context -%} +{%- from 'hana/macros/get_hana_exe_extract_dir.sls' import get_hana_exe_extract_dir with context %} +{% set hana_extract_dir = get_hana_exe_extract_dir(hana) %} {% set pydbapi_output_dir = '/tmp/pydbapi' %} -{% set hana_extract_dir = hana.hana_extract_dir %} - -# Below is temporary workaround to update the software path when using unrar for HANA multipart rar archive -# TODO: Find better solution to set or detect the correct extraction path when extracting multipart rar archive -# Below logic finds the extraction location based on name of multipart exe archive filename -{%- if hana.hana_archive_file is defined and hana.hana_archive_file.endswith((".exe", ".EXE")) %} -{% set archive_base_name = salt['file.basename']( hana.hana_archive_file.split('.')[0]) %} -{% set archive_name = archive_base_name.split('_')[0] %} -{% set hana_extract_dir = hana_extract_dir| path_join(archive_name) %} -{% endif %} {% for node in hana.nodes if node.host == grains['host'] %} diff --git a/saphanabootstrap-formula.spec b/saphanabootstrap-formula.spec index 44b36db..3833ca2 100644 --- a/saphanabootstrap-formula.spec +++ b/saphanabootstrap-formula.spec @@ -36,6 +36,7 @@ Suggests: prometheus-hanadb_exporter >= 0.7.0 %define fname hana %define fdir %{_datadir}/salt-formulas %define ftemplates templates +%define fmacros macros %description SAP HANA deployment salt formula. This formula is capable to install @@ -76,6 +77,7 @@ fi %attr(0755, root, salt) %{fdir}/states/%{fname} %attr(0755, root, salt) %{fdir}/states/%{fname}/%{ftemplates} +%attr(0755, root, salt) %{fdir}/states/%{fname}/%{fmacros} %attr(0755, root, salt) %{fdir}/metadata/%{fname} %changelog From 520f9a588d1d0197de0b8f0a064984e567686185 Mon Sep 17 00:00:00 2001 From: simran Date: Sat, 10 Oct 2020 21:22:44 -0700 Subject: [PATCH 3/3] update changelog and remove marcos changes from spec file update changelog entry Remove macros changes in the spec file Add newline char to spec file --- saphanabootstrap-formula.changes | 5 +++++ saphanabootstrap-formula.spec | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/saphanabootstrap-formula.changes b/saphanabootstrap-formula.changes index 61f0ae2..442df41 100644 --- a/saphanabootstrap-formula.changes +++ b/saphanabootstrap-formula.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sun Oct 11 04:21:32 UTC 2020 - Simranpal Singh + +- Fix the hana media extraction and installation logics when using exe archives + ------------------------------------------------------------------- Thu Oct 8 02:34:37 UTC 2020 - Simranpal Singh diff --git a/saphanabootstrap-formula.spec b/saphanabootstrap-formula.spec index 3833ca2..44b36db 100644 --- a/saphanabootstrap-formula.spec +++ b/saphanabootstrap-formula.spec @@ -36,7 +36,6 @@ Suggests: prometheus-hanadb_exporter >= 0.7.0 %define fname hana %define fdir %{_datadir}/salt-formulas %define ftemplates templates -%define fmacros macros %description SAP HANA deployment salt formula. This formula is capable to install @@ -77,7 +76,6 @@ fi %attr(0755, root, salt) %{fdir}/states/%{fname} %attr(0755, root, salt) %{fdir}/states/%{fname}/%{ftemplates} -%attr(0755, root, salt) %{fdir}/states/%{fname}/%{fmacros} %attr(0755, root, salt) %{fdir}/metadata/%{fname} %changelog