[netmod] Using augment to overwrite an existing definition?

Jiangyuanlong <jiangyuanlong@huawei.com> Tue, 10 April 2018 08:30 UTC

Return-Path: <jiangyuanlong@huawei.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 61AF31200C5 for <netmod@ietfa.amsl.com>; Tue, 10 Apr 2018 01:30:49 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 HGDC4iz1cURl for <netmod@ietfa.amsl.com>; Tue, 10 Apr 2018 01:30:44 -0700 (PDT)
Received: from huawei.com (lhrrgout.huawei.com [194.213.3.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 344371200A0 for <netmod@ietf.org>; Tue, 10 Apr 2018 01:30:44 -0700 (PDT)
Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id ADCD72EF03530 for <netmod@ietf.org>; Tue, 10 Apr 2018 09:30:40 +0100 (IST)
Received: from DGGEML424-HUB.china.huawei.com (10.1.199.41) by LHREML711-CAH.china.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.382.0; Tue, 10 Apr 2018 09:30:41 +0100
Received: from DGGEML507-MBS.china.huawei.com ([169.254.1.253]) by dggeml424-hub.china.huawei.com ([10.1.199.41]) with mapi id 14.03.0361.001; Tue, 10 Apr 2018 16:30:33 +0800
From: Jiangyuanlong <jiangyuanlong@huawei.com>
To: "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: Using augment to overwrite an existing definition?
Thread-Index: AdPQpjB2E1tfx0O3TOmjVHxd8wcniA==
Date: Tue, 10 Apr 2018 08:30:33 +0000
Message-ID: <3B0A1BED22CAD649A1B3E97BE5DDD68BBB6CBE12@dggeml507-mbs.china.huawei.com>
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.74.202.215]
Content-Type: multipart/alternative; boundary="_000_3B0A1BED22CAD649A1B3E97BE5DDD68BBB6CBE12dggeml507mbschi_"
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/jsSB412KsfxcSfzC-jpKv9HLF3w>
Subject: [netmod] Using augment to overwrite an existing definition?
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, 10 Apr 2018 08:30:49 -0000

Folks,

We are developing a YANG module for IEEE 1588, which is already a WG draft, please see https://tools.ietf.org/html/draft-ietf-tictoc-1588v2-yang-07.
The base module defines a leaf node ‘two-step-flag’ and tags it as read-write, but some applications may want to remodel it as read-only.
The following is the codes I tried:
module ptp-augment {
    namespace "urn:example:ptp-augment";
    prefix ptp-ag;

    import ietf-ptp {
        prefix ptp;
    }

    augment /ptp:ptp/ptp:instance-list/ptp:default-ds {
           leaf two-step-flag {
             config false;
             type boolean;
             description
               "When set, the clock is a two-step clock; otherwise,
                the clock is a one-step clock.";
           }

}
}
The codes are validated to be right by http://www.yangvalidator.com/validator.
My question is: By using ‘augment’, two leaf nodes are defined successfully with the same YANG identifier but with different behaviors (also applicable to different types), does the new definition take the precedence and overwrite its old definition?
If the answer is yes, I will be glad to use this YANG feature, but perhaps it makes sense that a YANG compiler emits a warning that a new definition overrides an existing one.
Or, are two leaf nodes defined exactly? How do we distinguish them?

I also tried to use ‘deviation’ instead, the following is the codes:

     module ptp-deviations {
       namespace "urn:example:ptp-deviations";
       prefix ptpd;

       import ietf-ptp {
         prefix ptp;
       }

       deviation /ptp:ptp/ptp:instance-list/ptp:default-ds/ptp:two-step-flag {
           deviate replace {
             config false;
           }
       }

     }
The codes are also validated to be right by http://www.yangvalidator.com/validator.
My concern is, it cannot add new leaf nodes, so inevitably, another augment will always be used.

Any thoughts?

Thanks,
Yuanlong