Re: [netmod] Fwd: Re: How to grep through a YANG? With grepyang

Robert Wilton <rwilton@cisco.com> Tue, 03 April 2018 15:09 UTC

Return-Path: <rwilton@cisco.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 46FB4127876 for <netmod@ietfa.amsl.com>; Tue, 3 Apr 2018 08:09:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.51
X-Spam-Level:
X-Spam-Status: No, score=-14.51 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XASFhrLO24N7 for <netmod@ietfa.amsl.com>; Tue, 3 Apr 2018 08:09:19 -0700 (PDT)
Received: from aer-iport-3.cisco.com (aer-iport-3.cisco.com [173.38.203.53]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 571F9120724 for <netmod@ietf.org>; Tue, 3 Apr 2018 08:09:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=4381; q=dns/txt; s=iport; t=1522768159; x=1523977759; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=veduU31Zc43Rsqyq1XteSrOcbRAl8nd2F3a3z+pAAVU=; b=UOPgU+je5+xl+Ys5ZlEjHvzD83twc221BKm2oTI5qSXhoMADJiexIt07 JsxYPBsdH3zA4vfbmtuwUQXT9DIE1TdmuPoEtQjRbRiDjhxTO/DO16pql Kg2ZPLVgLAf5YcFCDXPQn+B7zEI4b8B46ZPaoBkdyBYTs+9fSb3I9YBdk 4=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0CTAACbmMNa/xbLJq1ZBBkBAQEBAQEBAQEBAQEHAQEBAQGEI28og1+IAF6NcwghgQ+LEodDgXoLGA2EE0sChGI0GAECAQEBAQEBAmsohSMBAQEDAQEhDwEFNgsQCQIYAgImAgInMBMGAgEBhQkPkTybPIIchFWDb4IlgQmILD+BLgyCKC6CZisBAYFSgwqCVAKHIpAZCIVSgk2GCgaBMDqDH4I3IoRViRWBS4UdgSUcOIFSMxoIGxU6gkMJkEU+MI49AQE
X-IronPort-AV: E=Sophos;i="5.48,401,1517875200"; d="scan'208";a="2929337"
Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 15:09:15 +0000
Received: from [10.63.23.169] (dhcp-ensft1-uk-vla370-10-63-23-169.cisco.com [10.63.23.169]) by aer-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id w33F9F6r024271; Tue, 3 Apr 2018 15:09:15 GMT
To: otilibil@eurecom.fr
Cc: netmod@ietf.org
References: <20180330164544.pazut2dfxc08840w@webmail.eurecom.fr> <40e7e93c-c112-78a1-647c-1f30b95cd689@cisco.com> <20180403165605.2c9o1mru8ssg0w4c@webmail.eurecom.fr>
From: Robert Wilton <rwilton@cisco.com>
Message-ID: <acfdbe46-bb75-7ad1-2876-57e81c69cd21@cisco.com>
Date: Tue, 03 Apr 2018 16:09:13 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0
MIME-Version: 1.0
In-Reply-To: <20180403165605.2c9o1mru8ssg0w4c@webmail.eurecom.fr>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 8bit
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/H3133he84jOKMPaR7DbibSN8qNk>
Subject: Re: [netmod] Fwd: Re: How to grep through a YANG? With grepyang
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 03 Apr 2018 15:09:26 -0000

Hi Ariel,

Please see inline ...

On 03/04/2018 15:56, otilibil@eurecom.fr wrote:
> Hi Rob,
>
> My answers inline.
>
> Regards,
> Ariel
>
> Quoting Robert Wilton <rwilton@cisco.com>:
>
>> Hi Ariel,
>>
>> This looks like an interesting/useful tool.
>>
>> Have you considered hooking into pyang as a pyang extension?
> Till today, no; grpeyang is still a rush, needing improvements and 
> cleanups. You suggested a nice idea, indeed.
>> pyang is one of the defacto standard tools that folks interacting with
>> yang often use.  If your aim to get widespread usage of your tool
>> making it a pyang extension may be one way to achieve that. E.g. this
>> would then allow your tool to generate tree output for selected yang
>> subtree(s) nodes that you find, or other nice things.
> Thanks for your feedback, Rob. Then, I will read through the code of 
> pyang, and check the dependencies, if they are any. Who manages the 
> Github repository?
Martin Bjorklund - he is also the author.

Extensions (actually called plugins) don't have to go in the same repro, 
they can be loaded dynamically.

If you want to see an example of a plugin that walks the tree (modifying 
it as it goes) then you could take a look at:
https://github.com/rgwilton/pyang/blob/master/pyang/plugins/ietf_to_state_module.py

This takes a pyang tree and generates an extra legacy  "-state" tree 
from it.

Thanks,
Rob


>>
>> Thanks,
>> Rob
>>
>>
>> On 30/03/2018 15:45, otilibil@eurecom.fr wrote:
>>> Hi all,
>>> grepyang has got a new feature: it could grep for a node through a 
>>> module:
>>>
>>> # ./grepyang cancel-commit ietf-netconf@2011-06-01.yang
>>> 853:  rpc cancel-commit {
>>> 854:    if-feature confirmed-commit;
>>> 855:    description
>>> 856:      "This operation is used to cancel an ongoing confirmed 
>>> commit.
>>> 857:       If the confirmed commit is persistent, the parameter
>>> 858:       'persist-id' must be given, and it must match the value 
>>> of the
>>> 859:       'persist' parameter.";
>>> 860:    reference "RFC 6241, Section 8.4.4.1";
>>> 861:
>>> 862:    input {
>>> 863:      leaf persist-id {
>>> 864:        type string;
>>> 865:        description
>>> 866:          "This parameter is given in order to cancel a persistent
>>> 867:           confirmed commit.  The value must be equal to the value
>>> 868:           given in the 'persist' parameter to the <commit> 
>>> operation.
>>> 869:           If it does not match, the operation fails with an
>>> 870:          'invalid-value' error.";
>>> 871:      }
>>> 872:    }
>>> 873:  }
>>>
>>> Now it can grep for a node with a greped node:
>>>
>>> # ./grepyang input cancel-commit ietf-netconf@2011-06-01.yang
>>> 853:  rpc cancel-commit {
>>> 862:    input {
>>> 863:      leaf persist-id {
>>> 864:        type string;
>>> 865:        description
>>> 866:          "This parameter is given in order to cancel a persistent
>>> 867:           confirmed commit.  The value must be equal to the value
>>> 868:           given in the 'persist' parameter to the <commit> 
>>> operation.
>>> 869:           If it does not match, the operation fails with an
>>> 870:          'invalid-value' error.";
>>> 871:      }
>>> 872:    }
>>> 873:  }
>>>
>>> pyang lacks such features; that's why I have been working on grepyang.
>>>
>>> It is out on Github (https://github.com/ariel-anieli/grepyang);  
>>> feel free to play around with it.
>>>
>>> If you find it of any interest, have some remarks, or see it needs  
>>> enhancements; please,  do so: I will work on the issues.
>>>
>>> Regards,
>>> Ariel
>>>
>>> ------------------------------------------------------------------------------- 
>>> This message was sent using EURECOM Webmail: http://webmail.eurecom.fr
>>>
>>> _______________________________________________
>>> netmod mailing list
>>> netmod@ietf.org
>>> https://www.ietf.org/mailman/listinfo/netmod
>>> .
>>>
>
>
>
> ------------------------------------------------------------------------------- 
>
> This message was sent using EURECOM Webmail: http://webmail.eurecom.fr
>
> .
>