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

Need clarification on Control Board numbering #94

Closed
Kattasr opened this issue Nov 3, 2023 · 5 comments
Closed

Need clarification on Control Board numbering #94

Kattasr opened this issue Nov 3, 2023 · 5 comments
Assignees

Comments

@Kattasr
Copy link

Kattasr commented Nov 3, 2023

From Bootz perspective, is slot "0" considered as invalid control board slot number?

When I dump JSON content of Bootz request in python script as shown below, it prints slot-1 number as "1" as expected.
But it doesnt print slot-0 number. So, suspecting that "0" is considered as invalid index.

json_obj = MessageToJson(request)
print(json_obj)

@gmacf
Copy link
Contributor

gmacf commented Nov 6, 2023

Could you also provide the JSON dump and the input request?

@gmacf gmacf self-assigned this Nov 6, 2023
@kattasrao
Copy link

I am not sure on how to provide "input request".
But providing JSON details.
In Juniper software, control board slot numbering starts from 0. When I encode slot number "0" on client, JSON dump on server skips printing slot number.


{
"chassisDescriptor": {
"manufacturer": "Juniper Networks",
"partNumber": "EH022",
"controlCards": [
{
"partNumber": "750-145341",
"serialNumber": "BCCV8646"
},
{
"partNumber": "750-145341",
"serialNumber": "BCCV8634",
"slot": 1
}
]
},
"controlCardState": {
"serialNumber": "BCCV8634",
"status": "CONTROL_CARD_STATUS_NOT_INITIALIZED"
},
"nonce": "x4vb5QUyDednzBhM"
}


So, to check, I changed client code to send slot numbers as 1 and 2 instead of slot 0 and 1.
Then JSON dump prints both slot numbers correctly.
So, looks like the JSON print function treats int value 0 for slot as invalid slot number.


{
"chassisDescriptor": {
"manufacturer": "Juniper Networks",
"partNumber": "EH022",
"controlCards": [
{
"partNumber": "750-145341",
"serialNumber": "BCCV8646",
"slot": 1
},
{
"partNumber": "750-145341",
"serialNumber": "BCCV8634",
"slot": 2
}
]
},
"controlCardState": {
"serialNumber": "BCCV8634",
"status": "CONTROL_CARD_STATUS_NOT_INITIALIZED"
},
"nonce": "nTjZc1hJqixCixOG"
}


@gmacf
Copy link
Contributor

gmacf commented Nov 6, 2023

Yeah, this seems like an issue with the JSON dump function you're using. The Bootz code doesn't do any validation on the slot number passed by the client.

@kattasrao
Copy link

I was concerned that Bootz may be treating "0" as invalid slot. Thanks for clarification that it is not the case.
After a bit of searching, found that the JSON dump function from protobuf utils doesn't print default values by default.

But could override default dump behavior by forcing to print default values.

from google.protobuf.json_format import MessageToJson
json_obj = MessageToJson(request, including_default_value_fields=True)

Will close the issue as resolved.

@Kattasr
Copy link
Author

Kattasr commented Nov 16, 2023

Closing as per details provided in previous comment.

@Kattasr Kattasr closed this as completed Nov 16, 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

No branches or pull requests

3 participants