Skip to content

Conversation

@marcelmamula
Copy link
Contributor

@marcelmamula marcelmamula commented Sep 5, 2025

Changes

1. Architectural Refactoring

  • Modularization: Core logic has been extracted into dedicated packages (software_center, maintenance_planner, systems) with a clean separation of concerns (api.py, main.py).
  • API Client: A new ApiClient class now centralizes session management, retry logic, and common headers, providing a cleaner interface for all API communication.
  • Code Cleanup: Removed significant amounts of dead or unused code, including legacy authentication flows, unused helper functions, and obsolete constants.

2. Bug Fixes & Stability Enhancements

  • Authentication: Hardened the entire authentication flow to correctly handle complex SAP SSO, Gigya, and CSRF token mechanisms, including fallbacks for cookie-based tokens.
  • API Inconsistencies:
    • Resolved multiple 400 and 403 errors by adapting to specific API requirements for OData filters, request headers (X-Requested-With), and request payloads.
    • Gracefully handles the API's inconsistent use of Prodver and Version keys for product version IDs.
  • Idempotency: The license_keys module now fails with a clear error when multiple systems with the same SID are found, preventing ambiguous updates.
  • Robustness:
    • Fixed a regression in software_center_download to correctly handle wildcard searches.
    • Corrected the validate_checksum logic to properly handle alternative files.
    • Added a robust retry mechanism to handle backend replication delays.
  • Fixed docs: missing readme ref and file for modules license_keys and systems_info #38
  • Fixed collection: Remove executable flag from LICENSE file #45

3. Documentation Overhaul

  • Execution Flow: All module documentation (.md files) has been updated with a new "Execution Flow" section to clearly explain the module's logic.
  • Accuracy: All examples, parameter descriptions, and return values have been reviewed and updated for accuracy and clarity.

Simple test play

    - name: Execute Ansible Module with venv Python to download SAP installation media
      community.sap_launchpad.software_center_download:
        suser_id: "{{ sap_id_user }}"
        suser_password: "{{ sap_id_user_password }}"
        search_query: "{{ item }}"
        dest: "/download"
        search_alternatives: true
        validate_checksum: true
      loop:
        - 'SAPCAR_1115-70006178.EXE'  # Valid file
        - 'SWPM20SP20_1-80003424.SAR'  # Old file with alternative SWPM20SP21_3-80003424.SAR
        - 'SWPM20SP21_3-80003424.SAR'  # Valid file
      loop_control:
        label: "{{ item }} : {{ download_task.msg | d('') }}"
      register: download_task

Test results

First download

TASK [Execute Ansible Module with venv Python to download SAP installation media] ********************************************************
 [started TASK: Execute Ansible Module with venv Python to download SAP installation media on ae1ascs]
changed: [ae1ascs] => (item=SAPCAR_1115-70006178.EXE : Successfully downloaded SAP software: SAPCAR_1115-70006178.EXE)
changed: [ae1ascs] => (item=SWPM20SP20_1-80003424.SAR : Successfully downloaded alternative SAP software: SWPM20SP21_3-80003424.SAR - original file SWPM20SP20_1-80003424.SAR is not available to download)
skipping: [ae1ascs] => (item=SWPM20SP21_3-80003424.SAR : File already exists and checksum is valid: SWPM20SP21_3-80003424.SAR)

Second download

TASK [Execute Ansible Module with venv Python to download SAP installation media] ********************************************************
 [started TASK: Execute Ansible Module with venv Python to download SAP installation media on ae1ascs]
skipping: [ae1ascs] => (item=SAPCAR_1115-70006178.EXE : File already exists and checksum is valid: SAPCAR_1115-70006178.EXE)
skipping: [ae1ascs] => (item=SWPM20SP20_1-80003424.SAR : Alternative file SWPM20SP21_3-80003424.SAR already exists and checksum is valid.)
skipping: [ae1ascs] => (item=SWPM20SP21_3-80003424.SAR : File already exists and checksum is valid: SWPM20SP21_3-80003424.SAR)

Third download after emptying SAPCAR file

echo "" > SAPCAR_1115-70006178.EXE

TASK [Execute Ansible Module with venv Python to download SAP installation media] ********************************************************
 [started TASK: Execute Ansible Module with venv Python to download SAP installation media on ae1ascs]
changed: [ae1ascs] => (item=SAPCAR_1115-70006178.EXE : Successfully re-downloaded SAPCAR_1115-70006178.EXE due to an invalid checksum.)
skipping: [ae1ascs] => (item=SWPM20SP20_1-80003424.SAR : Alternative file SWPM20SP21_3-80003424.SAR already exists and checksum is valid.)
skipping: [ae1ascs] => (item=SWPM20SP21_3-80003424.SAR : File already exists and checksum is valid: SWPM20SP21_3-80003424.SAR)

@marcelmamula marcelmamula self-assigned this Sep 5, 2025
@marcelmamula marcelmamula added the enhancement New feature or request label Sep 5, 2025
@marcelmamula marcelmamula changed the title collection: Refactor all Ansible Modules collection: Refactor all Ansible Modules WORK IN PROGRESS Sep 5, 2025
@marcelmamula marcelmamula changed the title collection: Refactor all Ansible Modules WORK IN PROGRESS collection: Refactor all Ansible Modules Sep 9, 2025
Copy link
Member

@rhmk rhmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@berndfinger berndfinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@berndfinger berndfinger merged commit 78b8e15 into sap-linuxlab:dev Sep 23, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants