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

handle different storage controller responses #58

Closed
wants to merge 2 commits into from

Conversation

sdemircan
Copy link
Contributor

While checking storage controller data in get_storage_controller_data function API response varies between different ILO versions and different vendors(ie. Inspur).

@sdemircan sdemircan requested review from a team, Pjack, aieri, agileshaw, jneo8 and rgildein December 5, 2023 09:56
Copy link
Contributor

@rgildein rgildein left a comment

Choose a reason for hiding this comment

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

You haven't added any unit tests, please add them. Thanks

prometheus_hardware_exporter/collectors/redfish.py Outdated Show resolved Hide resolved
prometheus_hardware_exporter/collectors/redfish.py Outdated Show resolved Hide resolved
@Pjack Pjack requested a review from chanchiwai-ray December 6, 2023 08:43
@chanchiwai-ray
Copy link
Contributor

Can you provide the iLO version and the vendor (Inspur)'s official documentation for Redfish ?

@sdemircan
Copy link
Contributor Author

sdemircan commented Dec 6, 2023

Can you provide the iLO version and the vendor (Inspur)'s official documentation for Redfish ?

ILO version is 2.99. It returns storage controller information with Controllers key.

Inspur servers have a different problem. When sending request to storage_root_uri slash suffix that appended to URI makes API call invalid. I will attach Inspur's official documentation for Redfish when I find it.

@rgildein I have made changes based on your reviews. I will push them when I complete unit tests.

Copy link
Contributor

@dashmage dashmage left a comment

Choose a reason for hiding this comment

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

Looks quite nice overall, just a few comments. Thanks for submitting this PR!

"""
if "StorageControllers" in storage_controllers:
storage_controllers_list: List[Dict] = storage_controllers.get("StorageControllers")
elif "Controllers" in storage_controllers:
Copy link
Contributor

Choose a reason for hiding this comment

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

docs: Could we leave a comment here mentioning about the ILO version/ vendor that requires the code to handle the "Controllers" key?

return cls.systems_root_uri + f"{system_id}/{storage_name}/"
return cls.systems_root_uri + f"{system_id}/{storage_name}"

def _find_storage_controller_data(self, storage_controllers: Dict) -> List[Dict]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming the parameter here storage_controllers is a bit misleading. When called like

self._find_storage_controller_data(
                    self.redfish_obj.get(curr_storage_uri).dict
                )

it would contain all the data from that particular storage id since curr_storage_uri would be /redfish/v1/Systems/s1/Storage/Stor1 for example. Maybe something along the lines of storage_data could sound more appropriate?

The if condition would also make more sense:

if "StorageControllers" in storage_data:
        storage_controllers_list: List[Dict] = storage_data.get("StorageControllers")

storage_controllers_list: List[Dict] = []
controller_list = storage_controllers.get("Controllers")
for controller in controller_list.values():
all_controller_data = self.redfish_obj.get(controller).dict
Copy link
Contributor

Choose a reason for hiding this comment

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

docs: It would also be nice to have a comment here to understand what we're expecting the controller_list to look like, to better understand why we need another nested for loop querying for the Members key.

Eg: Maybe we could mention that Controllers only returns a list of links to the storage controllers when fetched from Members. And to get individual storage controller data, we need to query via separate GET requests to the URI pointed by @odata.id?

storage_controller_data_in_curr_system.append(
{
"storage_id": storage_id,
"controller_id": data["MemberId"],
"controller_id": data["MemberId"] if data.get("MemberId", None) else data.get("Id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

docs: A comment here as well mentioning that Id is what we expect if the key being used is Controllers in the storage data would be helpful

@@ -485,7 +485,7 @@ def test__storage_root_uri(self):
@patch(
"prometheus_hardware_exporter.collectors.redfish.redfish_utilities.systems.get_system_ids"
)
def test_get_storage_controller_data_success(
def test_get_storage_controller_data_success_with_storagecontrollers(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe test_get_storage_controller_data_success and test_get_storage_controller_data_success_with_non_standard_api could be more descriptive test names?

@chanchiwai-ray
Copy link
Contributor

Thanks @sdemircan for the work, this has been superseded by #71. Feel free to report further issues if you find any !

@Pjack Pjack closed this Apr 25, 2024
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.

5 participants