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

Update smartctl.py #50

Merged
merged 6 commits into from
Feb 4, 2025
Merged

Update smartctl.py #50

merged 6 commits into from
Feb 4, 2025

Conversation

gthvn1
Copy link
Contributor

@gthvn1 gthvn1 commented Jan 24, 2025

It superseded #46

@gthvn1 gthvn1 self-assigned this Jan 24, 2025
@gthvn1 gthvn1 requested review from stormi and benjamreis January 24, 2025 13:45
@stormi
Copy link
Member

stormi commented Jan 27, 2025

This change in behaviour requires:

Also, since the plugin now supports new cases, would it be appropriate to add a new test case that checks explicitly the new cases?

stormi
stormi previously requested changes Jan 27, 2025
Copy link
Member

@stormi stormi left a comment

Choose a reason for hiding this comment

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

(see previous comments)

@gthvn1 gthvn1 force-pushed the gtn-pr-46 branch 2 times, most recently from 400c6d7 to 09469f8 Compare January 27, 2025 19:08
@gthvn1
Copy link
Contributor Author

gthvn1 commented Jan 27, 2025

(see previous comments)

Yes I saw them... I'm waiting for an xcpng 8.3 with megaraid to be able to test it for real and I will update the tests. I will also ping XO team.

@gthvn1
Copy link
Contributor Author

gthvn1 commented Jan 27, 2025

I pinged the XO team about the modification: vatesfr/xen-orchestra#8272

@gthvn1
Copy link
Contributor Author

gthvn1 commented Jan 28, 2025

@stormi & @benjamreis about adding new tests for megaraid. The problem I have is that currently the plugin is looping through devices and run the command for each of them. Like:

        for device in devices:
            cmd = run_command(["smartctl", "-j", "-a", "-d", device['type'], device['name']], check=False)
            results[device['name'] + ":" + device['type']] = json.loads(cmd['stdout'])

As the command cannot be run for unit test I mocked it. It is fine because I currently have only one device. But how can I mock the run_command to return a different output for each devices ? If I add megaraid devices I will have three different outputs to return.
I guess there should be kind of yield but I don't know the syntax and how to use it for now. I will look in the pytest doc but if you already know :)

EDITED: it looks like we can have iterable side_effect... let's try that :)

1234Erwan and others added 6 commits January 28, 2025 13:04
This patch adds supports for megaraid devices by processing the output
of the smartctl command regarding this type of hardware. It was
previously ignored.

Signed-off-by: 1234Erwan <[email protected]>
The `-d` parameter expects the type of the device and not its name. This
patch fixes the issue.

Signed-off-by: Guillaume <[email protected]>
The function `_list_disks` is now `_list_devices`.

Signed-off-by: Guillaume <[email protected]>
This patch improves tests to include the newly supported megaraid
devices. To achieve this we rewrite the tests and use iterable side
effects. As the modifications are significants this is the first
commit with new structure but we will extend them in the future.

Signed-off-by: Guillaume <[email protected]>
@gthvn1
Copy link
Contributor Author

gthvn1 commented Jan 28, 2025

Note: I squashed all commit from @1234Erwan into one commit to cleanup the tree. So I think it is more readable and this allows the work that has done to be preserved.

@gthvn1 gthvn1 requested a review from stormi January 28, 2025 12:11
@gthvn1 gthvn1 dismissed stormi’s stale review January 29, 2025 14:08

I updated the Readme and the tests so I think it is ok now

@stormi stormi mentioned this pull request Jan 30, 2025
@gthvn1
Copy link
Contributor Author

gthvn1 commented Feb 3, 2025

@stormi @benjamreis no hurry but it is ok to review it now since XO team verified that there was no impact on their side 👍

Copy link
Member

@stormi stormi left a comment

Choose a reason for hiding this comment

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

It looks good to me. I only had a quick overview of the code and mostly focused on the described functional changes. I'm counting on @benjamreis (or someone else if that's not his responsibility anymore) to review the code in detail if needed.

@benjamreis
Copy link
Contributor

It looks good to me. I only had a quick overview of the code and mostly focused on the described functional changes. I'm counting on @benjamreis (or someone else if that's not his responsibility anymore) to review the code in detail if needed.

I'll review it this afternoon - since I already took a look I think its okay for me to re-review it 👍

@gthvn1 gthvn1 merged commit 9e6280e into master Feb 4, 2025
4 checks passed
@gthvn1 gthvn1 deleted the gtn-pr-46 branch February 4, 2025 08:42
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.

4 participants