sapcar_extract: Add overwrite mode and improve exist validation#77
Conversation
sean-freeman
left a comment
There was a problem hiding this comment.
LGTM functionally.... however I'd prefer an altered stdout that specifically states files were overwritten? I can foresee issues with end users and an overwrite param
@sean-freeman |
|
Updated output after Sean's comment: changed: true
msg: Files extracted to /tmp/sapcar_extract
stderr: ''
stderr_lines: []
stdout: |-
SAPCAR: processing archive /software/SAPEXEDB_51-70007806.SAR (version 2.01)
x db4cncl
x dbdb2slib.so
x dbdb4slib.so
changed: false
msg: Expected file names were found in /tmp/sapcar_extract. No extraction needed.
stderr: ''
stderr_lines: []
stdout: ''
stdout_lines: []
changed: true
msg: Files extracted to /tmp/sapcar_extract (overwrite mode enabled)
stderr: ''
stderr_lines: []
stdout: |-
SAPCAR: processing archive /software/SAPEXEDB_51-70007806.SAR (version 2.01) |
|
@marcelmamula Good to merge 🙂 Thank you for taking my concern into consideration |
|
Tested the following and LGTM too : |
|
Wait, something is not exactly on par with what was planed, this is the result with overwrite: true ; shouldn't it specify it in the msg ? : |
|
@nbttmbrg This message is generated under 2 cases:
Overwrite message is always addition, so it must be missing in your parameters. if params['overwrite']:
msg += " (overwrite mode enabled)" |
|
@marcelmamula Sorry my bad, typo in my register for my last task, I was debugging the wrong var. I see the correct message : |
Changes
Add new optional parameter
overwritewhich allows extraction regardless if files are present. We cannot validate that extracted files are what is in archive, only file names. Overwrite mode allows users to trigger overwrite like mentioned in sapcar_extract - bad check_if_present #71 by @crysaki @nbttmbrgAdd
pathvalidation and clearer messages, instead of incorrect message that files are already present. Mentioned in sapcar_extract - "OK: already unpacked" when path not exists #72 by @crysakiSmall refactoring for clarity and readability, not code change.
Tests
Tested on SLES_SAP 16.0 with BW4HANA system.
pathpoints to wrong archive, no longer success message:msg: 'File missing: File defined in the "path" parameter does not exist: /software/SAPEXEDB_51-70007806.SARx'destcontains expected file names, overwrite mode is disabled (default):stdout: Expected file names were found in /tmp/sapcar_extract folder. No extraction needed.destcontains expected file names, overwrite mode is enabled:stdout: |- SAPCAR: processing archive /software/SAPEXEDB_51-70007806.SAR (version 2.01) x db4cncl x dbdb2slib.so x dbdb4slib.so x dbdb6slib.so