Subject: Re: [RFC net-next 3/4] ynl: add a sample python library

From: Jakub Kicinski <[email-masked]>
Date: Thu, 11 Aug 2022 08:50:22 -0700

On Thu, 11 Aug 2022 14:48:49 +0900 Benjamin Poirier wrote:
> 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)

Hah, thanks! Looks like I also changed my mind between 'val' and 'value'
for the explicit value of the enum item. I'll correct those.