From: Benjamin Poirier <benjamin.poirier@gmail•com>
To: Jakub Kicinski <kuba@kernel•org>
Cc: netdev@vger•kernel.org, davem@davemloft•net, edumazet@google•com,
pabeni@redhat•com, sdf@google•com, jacob.e.keller@intel•com,
vadfed@fb•com, johannes@sipsolutions•net, jiri@resnulli•us,
dsahern@kernel•org, stephen@networkplumber•org, fw@strlen•de,
linux-doc@vger•kernel.org
Subject: Re: [RFC net-next 3/4] ynl: add a sample python library
Date: Thu, 11 Aug 2022 14:48:49 +0900 [thread overview]
Message-ID: <YvSYQe58MwWh4x+q@d3> (raw)
In-Reply-To: <20220811022304.583300-4-kuba@kernel.org>
On 2022-08-10 19:23 -0700, Jakub Kicinski wrote:
> A very short and very incomplete generic python library.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel•org>
> ---
> tools/net/ynl/samples/ynl.py | 342 +++++++++++++++++++++++++++++++++++
> 1 file changed, 342 insertions(+)
> create mode 100644 tools/net/ynl/samples/ynl.py
>
> diff --git a/tools/net/ynl/samples/ynl.py b/tools/net/ynl/samples/ynl.py
> new file mode 100644
> index 000000000000..59c178e063f1
> --- /dev/null
> +++ b/tools/net/ynl/samples/ynl.py
> @@ -0,0 +1,342 @@
[...]
> +class YnlFamily:
> + def __init__(self, def_path, schema=None):
> + with open(def_path, "r") as stream:
> + self.yaml = yaml.safe_load(stream)
> +
> + if schema:
> + with open(os.path.dirname(os.path.dirname(file_name)) + '/schema.yaml', "r") as stream:
> + schema = yaml.safe_load(stream)
> +
> + jsonschema.validate(self.yaml, schema)
> +
The schema validation part was not working. I got it going with the
following changes. It then flags some problems in ethtool.yaml.
diff --git a/tools/net/ynl/samples/ethtool.py b/tools/net/ynl/samples/ethtool.py
index 63c8e29f8e5d..4c5a4629748d 100755
--- a/tools/net/ynl/samples/ethtool.py
+++ b/tools/net/ynl/samples/ethtool.py
@@ -14,7 +14,7 @@ def main():
parser.add_argument('--ifindex', dest='ifindex', type=str)
args = parser.parse_args()
- ynl = YnlFamily(args.spec)
+ ynl = YnlFamily(args.spec, args.schema)
if args.dev_name:
channels = ynl.channels_get({'header': {'dev_name': args.dev_name}})
diff --git a/tools/net/ynl/samples/ynl.py b/tools/net/ynl/samples/ynl.py
index 59c178e063f1..35c894b0ec19 100644
--- a/tools/net/ynl/samples/ynl.py
+++ b/tools/net/ynl/samples/ynl.py
@@ -247,7 +247,7 @@ class YnlFamily:
self.yaml = yaml.safe_load(stream)
if schema:
- with open(os.path.dirname(os.path.dirname(file_name)) + '/schema.yaml', "r") as stream:
+ with open(schema, "r") as stream:
schema = yaml.safe_load(stream)
jsonschema.validate(self.yaml, schema)
next prev parent reply other threads:[~2022-08-11 5:48 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 2:23 [RFC net-next 0/4] ynl: YAML netlink protocol descriptions Jakub Kicinski
2022-08-11 2:23 ` [RFC net-next 1/4] ynl: add intro docs for the concept Jakub Kicinski
2022-08-11 20:17 ` Edward Cree
2022-08-12 22:23 ` Jakub Kicinski
2022-08-15 20:09 ` Johannes Berg
2022-08-16 0:32 ` Jakub Kicinski
2022-08-16 7:07 ` Johannes Berg
2022-08-11 2:23 ` [RFC net-next 2/4] ynl: add the schema for the schemas Jakub Kicinski
2022-08-15 20:03 ` Johannes Berg
2022-08-15 20:09 ` Johannes Berg
2022-08-16 0:47 ` Jakub Kicinski
2022-08-16 7:21 ` Johannes Berg
2022-08-16 15:53 ` Jakub Kicinski
2022-08-16 19:30 ` Johannes Berg
2022-09-26 16:10 ` Rob Herring
2022-09-27 21:56 ` Jakub Kicinski
2022-09-28 12:32 ` Rob Herring
2022-08-11 2:23 ` [RFC net-next 3/4] ynl: add a sample python library Jakub Kicinski
2022-08-11 5:48 ` Benjamin Poirier [this message]
2022-08-11 15:50 ` Jakub Kicinski
2022-08-11 20:09 ` Stephen Hemminger
2022-08-12 22:53 ` Jakub Kicinski
2022-08-15 20:00 ` Johannes Berg
2022-08-12 1:04 ` Stephen Hemminger
2022-08-12 15:42 ` Edward Cree
2022-08-12 23:07 ` Jakub Kicinski
2022-08-18 21:26 ` Keller, Jacob E
2022-08-11 2:23 ` [RFC net-next 4/4] ynl: add a sample user for ethtool Jakub Kicinski
2022-08-11 16:18 ` sdf
2022-08-11 19:35 ` Jakub Kicinski
2022-08-11 22:55 ` Stanislav Fomichev
2022-08-11 23:31 ` Jakub Kicinski
2022-08-12 16:26 ` Stanislav Fomichev
2022-08-12 22:48 ` Jakub Kicinski
2022-08-14 12:27 ` Ido Schimmel
2022-08-11 4:15 ` [RFC net-next 0/4] ynl: YAML netlink protocol descriptions Stephen Hemminger
2022-08-11 4:47 ` Jakub Kicinski
2022-08-11 15:01 ` Stephen Hemminger
2022-08-11 15:34 ` Jakub Kicinski
2022-08-11 16:28 ` sdf
2022-08-11 19:42 ` Jakub Kicinski
2022-08-12 17:00 ` Florian Fainelli
2022-08-12 22:26 ` Jakub Kicinski
2022-08-19 19:56 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YvSYQe58MwWh4x+q@d3 \
--to=benjamin.poirier@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=dsahern@kernel$(echo .)org \
--cc=edumazet@google$(echo .)com \
--cc=fw@strlen$(echo .)de \
--cc=jacob.e.keller@intel$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=johannes@sipsolutions$(echo .)net \
--cc=kuba@kernel$(echo .)org \
--cc=linux-doc@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=sdf@google$(echo .)com \
--cc=stephen@networkplumber$(echo .)org \
--cc=vadfed@fb$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox