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

Add cmd error code descr #155

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Conversation

canteuni
Copy link
Contributor

This PR aims to add some command-specific completion code descriptions.

Some descriptions were already written but never used, so I add the corresponding dictionary to the CompletionCodeError implementation. This dictionary also needs the corresponding command ID in order to find the description so I add a reference to the command ID in places where check_completion_code is called and where I'm sure the specific CC descriptions exist for this command.

@coveralls
Copy link

coveralls commented Jun 29, 2023

Coverage Status

coverage: 69.362% (+0.05%) from 69.315% when pulling 17decdb on canteuni:add_cmd_error_code_descr into 218f141 on kontron:master.

@hthiery
Copy link
Contributor

hthiery commented Jun 29, 2023

Hi, very good idea.

But I think it is not thought far enough. We have to take into account that there are netfn and group ids which have commands with the same id and have to be distinguished between them.

Have a look here: https://github.com/kontron/python-ipmi/blob/master/pyipmi/msgs/registry.py#L48C8-L48C73

what do you think

@canteuni
Copy link
Contributor Author

canteuni commented Jun 29, 2023

Oh you're right, I thought that the command id was globally unique but that's not the case. Then I must use a tuple (netfn, cmdid, group_extension) as identifier, I'll make the changes

check_completion_code(rsp.completion_code)
check_completion_code(
rsp.completion_code,
req.cmdid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you do use the req here? Above you use rsp.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the other hand, would'nt it be better to have a new function like check_rsp_completion_code(rsp)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow that's my bad again, didn't sleep enough I guess. Sorry for this.

Yes I was asking myself the same thing but wasn't sure, if you think a function check_rsp_completion_code(rsp) comes handy too I will add it !

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a new function it will reduce the linses when checking the cc and you only have to pass the rsp parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Apart from that it looks good!

@canteuni canteuni force-pushed the add_cmd_error_code_descr branch 2 times, most recently from d45b91c to b9d4fe8 Compare July 13, 2023 18:56
@@ -383,6 +385,48 @@
0x86: 'requested maximum privilege level exceeds user and/or channel'
' privilege limit',
},
(NETFN_APP | 1, CMDID_SET_SESSION_PRIVILEGE_LEVEL, None): {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I choose to set NefFn | 1 as the key in the description dictionary rather than just NetFn because we use the dictionary only for IPMI Responses, but the choice can be debated.

pyipmi/utils.py Outdated
raise CompletionCodeError(
rsp.completion_code,
cmdid=rsp.cmdid,
netfn=rsp.netfn,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think doing 'cmdid=rsp.cmdid & 0xfe' would be a better solution than adding the 1 in the dict. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes seems good to me

Signed-off-by: canteuni <21243338+canteuni@users.noreply.github.com>
Signed-off-by: canteuni <21243338+canteuni@users.noreply.github.com>
@hthiery
Copy link
Contributor

hthiery commented Jul 17, 2023

Looks good to me. Thank you!

@hthiery hthiery merged commit cb4474d into kontron:master Jul 17, 2023
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