Skip to content

OpenShift introduction#147

Closed
aschumann-virtualcable wants to merge 10 commits into
masterfrom
dev/andres/master-req
Closed

OpenShift introduction#147
aschumann-virtualcable wants to merge 10 commits into
masterfrom
dev/andres/master-req

Conversation

@aschumann-virtualcable
Copy link
Copy Markdown
Contributor

This pull request refactors the OpenShift client in openshift/client.py to centralize and standardize HTTP request handling, improve error management, and simplify the code. Most direct uses of the requests library and manual header construction have been replaced with a unified do_request method. This change enhances maintainability, reduces code duplication, and ensures consistent authentication and error handling across all API interactions. Additionally, some unused code and redundant methods have been removed.

Key changes include:

Refactoring HTTP Requests and API Calls

  • Replaced all direct requests.get, requests.post, requests.patch, and requests.delete calls with the do_request method, ensuring consistent use of authentication, error handling, and SSL verification throughout the client (openshift/client.py). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Error Handling Improvements

  • Improved error handling by wrapping API calls in try/except blocks and logging exceptions, leading to more robust and informative error reporting. [1] [2] [3] [4] [5] [6]

Code Cleanup and Simplification

  • Removed unused imports and redundant code, such as the token import and the clone_vm_instance and validate_vm_id methods, to streamline the client class. [1] [2]

Behavioral Adjustments

  • Changed the VM start/stop logic to fetch the VM object, update its runStrategy, and perform a PUT request instead of a patch, aligning with the new request handling approach.

Minor Enhancements

  • Improved the VM name sanitization logic in provider.py for better RFC 1123 compliance and clarity in documentation and implementation.

…onality

- Implemented unit tests for OpenShift client, provider, publication, and service functionalities.
- Added serialization tests for user services and providers to ensure data integrity during serialization and deserialization.
- Created tests for VM lifecycle operations, including creation, deletion, and state checks.
- Enhanced test coverage for service availability and error handling scenarios.
- Introduced fixed user service tests to validate assignment and operational methods.
- Ensured all tests are structured to handle various edge cases and provide meaningful assertions.
- Updated serialization tests for OpenshiftProvider to ensure correct method behavior after serialization.
- Enhanced publication serialization tests, adding checks for autoserializable fields and marshaling.
- Reorganized service tests to group by functionality, including configuration, utility methods, availability, VM operations, and exception handling.
- Added detailed tests for VM creation, deletion, and cancellation operations in the deployment context.
- Introduced fixed user service tests to validate lifecycle and operation behaviors.
- Removed outdated user service fixed tests and consolidated relevant functionality into new structured tests.
- Added serialization tests for fixed user service to ensure data integrity during serialization and deserialization.
@aschumann-virtualcable aschumann-virtualcable deleted the dev/andres/master-req branch November 5, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants