Re: [netmod] xpath for must statements

"Acee Lindem (acee)" <acee@cisco.com> Wed, 08 August 2018 13:34 UTC

Return-Path: <acee@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 C678E12785F for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 06:34:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.511
X-Spam-Level:
X-Spam-Status: No, score=-14.511 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_DKIMWL_WL_MED=-0.01, 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 qBAwsG3of5cj for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 06:34:57 -0700 (PDT)
Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id BD07A1277C8 for <netmod@ietf.org>; Wed, 8 Aug 2018 06:34:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=6392; q=dns/txt; s=iport; t=1533735297; x=1534944897; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=ZJSrEtTwEVvCEf3J5eTYapHeNBK5WmcGvdYtw17AS3k=; b=BFQO/Uj/8DehyMUrkDCBHJVIQrOx+0LOurCM2CiP1c44bwUFoGCzK+n/ rRJfx/UMj/1OEyI95CZbzt6EsShyZyIJNs+f/lh/XPcwbXMEPlADus0jh NWk9i9YoDCcuPi+36Rv3SS1ojMyize5n/jcaTy5dy/gQCyLqOGgopG9gT 8=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0BiAQBT8Gpb/4ENJK1cGgEBAQEBAgEBAQEIAQEBAYMgLmN/KAqDdIgKjECCDYM8kjWBegsjhEkCF4J6ITQYAQIBAQIBAQJtHAyFNwEBAQECASMRRRACAQgOCgICJgICAjAVEAIEDgWDIAGBeAgPqn+BLoQoAT2FbQWBC4gJF4IAgTkfgkyDGwICgS4xgwExgiQCjHiNTQkChhqCboY/jiyKdYdZAhEUgSQdOIFScBU7KgGCPoYBilJvAYtzgS2BGwEB
X-IronPort-AV: E=Sophos;i="5.51,457,1526342400"; d="scan'208";a="424899486"
Received: from alln-core-9.cisco.com ([173.36.13.129]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 13:34:56 +0000
Received: from XCH-RTP-011.cisco.com (xch-rtp-011.cisco.com [64.101.220.151]) by alln-core-9.cisco.com (8.15.2/8.15.2) with ESMTPS id w78DYuXh010126 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL); Wed, 8 Aug 2018 13:34:56 GMT
Received: from xch-rtp-015.cisco.com (64.101.220.155) by XCH-RTP-011.cisco.com (64.101.220.151) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 8 Aug 2018 09:34:55 -0400
Received: from xch-rtp-015.cisco.com ([64.101.220.155]) by XCH-RTP-015.cisco.com ([64.101.220.155]) with mapi id 15.00.1320.000; Wed, 8 Aug 2018 09:34:55 -0400
From: "Acee Lindem (acee)" <acee@cisco.com>
To: Martin Bjorklund <mbj@tail-f.com>
CC: "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: [netmod] xpath for must statements
Thread-Index: AQHULpoKt9x7V9xDM0K8KDBrtthF9aS1vKmA///78QCAAEQFgP//31yA
Date: Wed, 08 Aug 2018 13:34:55 +0000
Message-ID: <39C9167F-F484-4F53-A6F2-2144C26A2C9F@cisco.com>
References: <3FBE6E06-3C42-4CFE-9A4C-FAC55572901C@cisco.com> <20180808.094249.655098716605272274.mbj@tail-f.com> <6BAF8353-6863-4B26-AB65-88CFBFC85E77@cisco.com> <20180808.133145.603038015628507205.mbj@tail-f.com>
In-Reply-To: <20180808.133145.603038015628507205.mbj@tail-f.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.116.152.201]
Content-Type: text/plain; charset="utf-8"
Content-ID: <22C2B2E1DA239942980322D7CD3514E3@emea.cisco.com>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-Outbound-SMTP-Client: 64.101.220.151, xch-rtp-011.cisco.com
X-Outbound-Node: alln-core-9.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/jNs-tyUgncRqn5W8kKe1fe2Uyp4>
Subject: Re: [netmod] xpath for must statements
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.27
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: Wed, 08 Aug 2018 13:35:00 -0000

Hi Martin, 

On 8/8/18, 7:31 AM, "Martin Bjorklund" <mbj@tail-f.com> wrote:

    "Acee Lindem (acee)" <acee@cisco.com> wrote:
    > Thanks Martin - see inline. 
    > 
    > On 8/8/18, 3:43 AM, "Martin Bjorklund" <mbj@tail-f.com> wrote:
    > 
    >     Hi,
    >     
    >     "Acee Lindem \(acee\)" <acee=40cisco.com@dmarc.ietf.org> wrote:
    >     > Is it possible to indicate that choice statement must be specified
    >     > in a YANG 1.1 “must” clause w/o specifying every case?
    >     
    >     Do you mean that you to ensure that a case is always configured?  If
    >     so, mark the choice as "mandatory true".  It can't be done with an
    >     XPath expression.
    > 
    > It's not that easy since at the least the choice or another leaf
    > must be specified.
    
    Maybe you can share the model (or a simplified version) in order to
    illustrate the problem?

This is from one of the Cisco IOS-XE native models available on GitHub - https://github.com/YangModels/yang/tree/master/vendor/cisco/xe/1691

+--rw service* [name]
       +--rw name                     string
       +--rw description?             string
       +--rw group-object?            string
       +--rw (protocol-choice)?
          +--:(protocol-number-case)
          |  +--rw protocol-number?   uint8
          +--:(protocol-name-case)
             +--rw ahp?               empty
             +--rw eigrp?             empty
             +--rw esp?               empty
             +--rw gre?               empty
             +--rw icmp!
             |  +--rw port-number?            uint8
             |  +--rw alternate-address?      empty
             |  +--rw conversion-error?       empty
             |  +--rw echo?                   empty
             |  +--rw echo-reply?             empty
             |  +--rw information-reply?      empty
             |  +--rw information-request?    empty
             |  +--rw mask-reply?             empty
             |  +--rw mask-request?           empty
             |  +--rw mobile-redirect?        empty
             |  +--rw parameter-problem?      empty
             |  +--rw redirect?               empty
             |  +--rw router-advertisement?   empty
             |  +--rw router-solicitation?    empty
             |  +--rw source-quench?          empty
             |  +--rw time-exceeded?          empty
             |  +--rw timestamp-reply?        empty
             |  +--rw timestamp-request?      empty
             |  +--rw traceroute?             empty
             |  +--rw unreachable?            empty
             +--rw igmp?              empty
             +--rw ip?                empty
             +--rw ipinip?            empty
             +--rw nos?               empty
             +--rw ospf?              empty
             +--rw pcp?               empty
             +--rw pim?               empty
             +--rw tcp!
             |  +--rw tcp-port-list* [tcp-port]
             |     +--rw tcp-port        ios-types:acl-tcp-port-type
             |     +--rw operator?       enumeration
             |     +--rw max-tcp-port?   ios-types:acl-tcp-port-type
             +--rw tcp-udp!
             |  +--rw udp-port-list* [udp-port]
             |     +--rw udp-port        ios-types:acl-udp-port-type
             |     +--rw operator?       enumeration
             |     +--rw max-udp-port?   ios-types:acl-udp-port-type
             +--rw udp!
                +--rw udp-port-list* [udp-port]
                   +--rw udp-port        ios-types:acl-udp-port-type
                   +--rw operator?       enumeration
                   +--rw max-udp-port?   ios-types:acl-udp-port-type

Prior to YANG I certainly didn't have a lot of experience with Xpath. However, I had to learn thru trial and error that protocol-choice, protocol-number-case, and protocol-name-case are not part of the Xpath. I guess RFC 7950 section 7.9 does indicate that these two statements are not present in the data tree but it wasn't obvious to me that this also means it isn't in the Xpath.

Thanks,
Acee 

    
    
    
    /martin
    
    
    > I found that the choice and case identifiers are
    > not part of the Xpath. Even after rereading some sections of
    > RFC7950, this wasn't intuitive.
    > 
    > Thanks,
    > Acee 
    >     
    >     
    >     /martin
    >     
    >     
    >     
    >     > Similarly, it is there a way specify that a container cannot be empty in “must” clause?
    >     > Thanks,
    >     > Acee
    >     
    >