Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #163: Optional Connection upon Client Instantiation #164

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

jpavlav
Copy link
Contributor

@jpavlav jpavlav commented Sep 12, 2024

This allows a user to create a client without knowing the IP they are connecting to up front. It gives the user the ability to create and pass around a client object as needed. Additionally, the default behavior is preserved.

  • Added check_connectivity keyword arg to RestClientBase.
  • Added check_connectivity keyword arg to HTTPClient.
  • Added check_connectivity keyword arg to redfish_client function.
  • Conditionally execute get_root_object during client instantiation based on the value of check_connectivity.
  • Catch the resultant AttributeError in the case that self.root was not set due to check_connectivity being set to False.
  • Small test refactor, added setUp method to TestRedFishClient class to make commonly used attributes members of the test case.
  • Added new test for this functionality.
  • Ensure that the root data/response added as attributes by the
    get_root_object method are cached when login is called.
  • Added new test to cover this case.

Test results:

python tests/rest/test_v1.py
...
----------------------------------------------------------------------
Ran 3 tests in 11.384s

OK

#163

This allows a user to create a client without _knowing_ the IP they are
connecting to up front. It gives the user the ability to create and pass
around a client object as needed. Additionally, the default behavior is
preserved.

* Added `check_connectivity` keyword arg to `RestClientBase`.
* Added `check_connectivity` keyword arg to `HTTPClient`.
* Added `check_connectivity` keyword arg to `redfish_client` function.
* Conditionally execute `get_root_object` during client instantiation
based on the value of `check_connectivity`.
* Catch the resultant `AttributeError` in the case that `self.root` was
not set due to `check_connectivity` being set to `False`.
* Small test refactor, added `setUp` method to `TestRedFishClient` class
to make commonly used attributes members of the test case.
* Added new test for this functionality.

Signed-off-by: Justin Palmer <jpavlav@gmail.com>
@jpavlav jpavlav force-pushed the jpavlav/optional_get_root_object branch from abf1571 to ef8ec2a Compare September 12, 2024 14:38
@mraineri
Copy link
Contributor

Only comments I have right now are we need to update the comment blocks that document parameters with the new check_connection parameter.

We also need to add documentation to the README here for it: https://github.com/DMTF/python-redfish-library/blob/main/README.rst?plain=1#L93

Still looking over other things, but otherwise looks good so far

@jpavlav
Copy link
Contributor Author

jpavlav commented Sep 12, 2024

Good callout on the docstrings! I can't believe I forgot to do that. I'll get those updated and the README as well.

* Ensure that the `root` data/response added as attributes by the
`get_root_object` method are cached when `login` is called.
* Added new test to cover this case.

Signed-off-by: Justin Palmer <jpavlav@gmail.com>
* Updated docstrings to describe `check_connectivity` parameter.
* Updated `README.rst` to call it out as an optional parameter.

Signed-off-by: Justin Palmer <jpavlav@gmail.com>
@jpavlav jpavlav force-pushed the jpavlav/optional_get_root_object branch from 957421e to 72a23d7 Compare September 12, 2024 19:00
@jpavlav
Copy link
Contributor Author

jpavlav commented Sep 13, 2024

@mraineri Hey there! Addressed your comments. Should be ready for review.

@mraineri
Copy link
Contributor

It all looks good to me! It'll be reviewed by the rest of the group today.

@mraineri
Copy link
Contributor

Approved 9/13

@mraineri mraineri merged commit 1f978b5 into DMTF:main Sep 13, 2024
2 checks passed
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.

2 participants