p4-utils icon indicating copy to clipboard operation
p4-utils copied to clipboard

a table without keys

Open yhx-coder opened this issue 2 years ago • 4 comments

I have a table without keys, and I try to down some entries for it through sswitch_thrift_API.SimpleSwitchThriftAPI.table_add.Unfortunately, thrift_API.SwitchInfo.load_json_str could not load the table. Could you give me some advice? Thanks a lot!

yhx-coder avatar Jun 01 '22 04:06 yhx-coder

What do you want to add if there are no keys? You can only have a default action no? Or can you explain a bit more what are you trying to do?

edgar-costa avatar Jun 17 '22 13:06 edgar-costa

This is my definition of table. table swid { actions = { set_swid; NoAction; } default_action=NoAction(); } the action set_swid tries to set switch id for each device. And I want to down the switch id.

yhx-coder avatar Jun 17 '22 14:06 yhx-coder

But if you have no keys, the only way to make that action to be "executed" is by setting it as default. Thus, table_add can not be used with keyless tables, you need to match to something.

edgar-costa avatar Jun 17 '22 14:06 edgar-costa

Thanks for your reply. I made some fixes in my thrift_API.SwitchInfo.load_json_str to make it work for this case. I think it is reasonable. Because even if I set it as default, I need the control plane to add parameters. But at this time, the key is redundant. This behavior is supported in CLI. So if the official will support this kind of table in the future? By the way, I think you are right. I do need to modify my definition of table.

yhx-coder avatar Jun 17 '22 15:06 yhx-coder