summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Moreno <amorenoz@redhat.com>2022-12-19 17:13:43 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-12-21 18:36:02 +0100
commit3648fec08f15b3f2cc37cd4b85eaccb773d1f444 (patch)
treeac91b430b3122df9508e5b913139c4b06fa000b4
parentc627cfd9cb630c052285a540cd65dd809be0ea95 (diff)
downloadopenvswitch-3648fec08f15b3f2cc37cd4b85eaccb773d1f444.tar.gz
python: Include aliases in ofp_fields.py.
We currently auto-generate a dictionary of field names and decoders. However, sometimes fields can be specified by their cannonical NXM or OXM names. Modify gen_ofp_field_decoders to also generate a dictionary of aliases so it's easy to map OXM/NXM names to their fields and decoding information. Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rwxr-xr-xbuild-aux/gen_ofp_field_decoders15
1 files changed, 15 insertions, 0 deletions
diff --git a/build-aux/gen_ofp_field_decoders b/build-aux/gen_ofp_field_decoders
index 96f99e860..0b797ee8c 100755
--- a/build-aux/gen_ofp_field_decoders
+++ b/build-aux/gen_ofp_field_decoders
@@ -22,12 +22,16 @@ def main():
fields = extract_fields.extract_ofp_fields(args.metaflow)
field_decoders = {}
+ aliases = {}
for field in fields:
decoder = get_decoder(field)
field_decoders[field.get("name")] = decoder
if field.get("extra_name"):
field_decoders[field.get("extra_name")] = decoder
+ for nxm in field.get("OXM", []):
+ aliases[nxm[1]] = field.get("name")
+
code = """
# This file is auto-generated. Do not edit!
@@ -35,14 +39,25 @@ from ovs.flow import decoders
field_decoders = {{
{decoders}
+}}
+
+field_aliases = {{
+{aliases}
}}""".format(
decoders="\n".join(
[
" '{name}': {decoder},".format(name=name, decoder=decoder)
for name, decoder in field_decoders.items()
]
+ ),
+ aliases="\n".join(
+ [
+ " '{alias}': '{name}',".format(name=name, alias=alias)
+ for alias, name in aliases.items()
+ ]
)
)
+
print(code)