Skip to content

Commit

Permalink
python: ovs: flow: Add sample to nested actions.
Browse files Browse the repository at this point in the history
Add the sample action to those that can be called in nested actions
(such as clone).

Signed-off-by: Adrian Moreno <[email protected]>
[simon: resolved conflict]
Signed-off-by: Simon Horman <[email protected]>
  • Loading branch information
amorenoz authored and Simon Horman committed Jan 18, 2024
1 parent 24991c6 commit 10d4898
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
29 changes: 15 additions & 14 deletions python/ovs/flow/odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,28 @@ def _action_decoders_args():
**ODPFlow._tnl_action_decoder_args(),
}

_decoders["sample"] = nested_kv_decoder(
KVDecoders(
{
"sample": (lambda x: float(x.strip("%"))),
"actions": nested_kv_decoder(
KVDecoders(
decoders=_decoders,
default_free=decode_free_output,
),
is_list=True,
),
}
)
)

_decoders["clone"] = nested_kv_decoder(
KVDecoders(decoders=_decoders, default_free=decode_free_output),
is_list=True,
)

return {
**_decoders,
"sample": nested_kv_decoder(
KVDecoders(
{
"sample": (lambda x: float(x.strip("%"))),
"actions": nested_kv_decoder(
KVDecoders(
decoders=_decoders,
default_free=decode_free_output,
),
is_list=True,
),
}
)
),
"check_pkt_len": nested_kv_decoder(
KVDecoders(
{
Expand Down
14 changes: 14 additions & 0 deletions python/ovs/tests/test_ofp.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,20 @@ def do_test_section(input_string, section, expected):
),
],
),
(
"actions=LOCAL,clone(sample(probability=123))",
[
KeyValue("output", {"port": "LOCAL"}),
KeyValue(
"clone",
[
{"sample": {
"probability": 123,
}},
]
),
],
),
(
"actions=doesnotexist(1234)",
ParseError,
Expand Down

0 comments on commit 10d4898

Please sign in to comment.