Re: [netmod] WHEN statement within mandatory objects doesn't ensure presence of the mandatory object
Robert Wilton <rwilton@cisco.com> Wed, 10 October 2018 15:33 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 87E8B130E9A for <netmod@ietfa.amsl.com>; Wed, 10 Oct 2018 08:33:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.957
X-Spam-Level:
X-Spam-Status: No, score=-14.957 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.456, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-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 NYSZoSBtwIsE for <netmod@ietfa.amsl.com>; Wed, 10 Oct 2018 08:33:04 -0700 (PDT)
Received: from aer-iport-2.cisco.com (aer-iport-2.cisco.com [173.38.203.52]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 00732130DD9 for <netmod@ietf.org>; Wed, 10 Oct 2018 08:33:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5761; q=dns/txt; s=iport; t=1539185584; x=1540395184; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=eJVed1uNSE5HGIH0owAju+Eggi+iEC48Od3pVGd6n5A=; b=mPU4o7XGjRzVHAf7k7EsKRqlRXnIgBKLI7ks1aKYv241PTylRTzvadfX Sqp/kR3Qj84EM+7uvSLySrTRUzweJnZZ5GhT0J8L/6KNHGudnM5LTpz// xuY9Vjq4Jw9qA7Pa6rGdC7PiZ6LcVEk/pjy56n7p4Zy11OOEESU0KvRa8 s=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0CjAAAiG75b/xbLJq1jGQEBAQEBAQEBAQEBAQcBAQEBAQGBZYJsbRIog3WIdIsmghgllxKBZg0YC4QDRgKEcTgWAQMBAQIBAQJtHAyFOQEBAQEDAQEhDwEFNgsMBAsRBAEBAQICHwQDAgInHwkIBgEMBgIBAYMdAYIBD6R9gS6Ed4UYBYELikeBQT+BEicMgl+CNmUBAQGBLQELBgIBgx+CVwKdNFIJkEsGF4kihmmPWIY0gVkhZHEzGggbFTuCbIJOiEmFPz4wAYoQAiQHgiABAQ
X-IronPort-AV: E=Sophos;i="5.54,364,1534809600"; d="scan'208";a="7138284"
Received: from aer-iport-nat.cisco.com (HELO aer-core-2.cisco.com) ([173.38.203.22]) by aer-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 15:33:02 +0000
Received: from [10.63.23.158] (dhcp-ensft1-uk-vla370-10-63-23-158.cisco.com [10.63.23.158]) by aer-core-2.cisco.com (8.15.2/8.15.2) with ESMTP id w9AFX1Yk004076; Wed, 10 Oct 2018 15:33:01 GMT
To: Michael Rehder <Michael.Rehder@Amdocs.com>, Ladislav Lhotka <lhotka@nic.cz>, "netmod@ietf.org" <netmod@ietf.org>
Cc: "Walker, Jason (Jason_Walker2@comcast.com)" <Jason_Walker2@comcast.com>
References: <AM0PR06MB4083426FA0F1D3F6515F2ECFE7E70@AM0PR06MB4083.eurprd06.prod.outlook.com> <87zhvlvpts.fsf@nic.cz> <AM0PR06MB40833D8AED0744BB597394E7E7E00@AM0PR06MB4083.eurprd06.prod.outlook.com>
From: Robert Wilton <rwilton@cisco.com>
Message-ID: <d322e012-2767-a045-767a-ddf57649f36e@cisco.com>
Date: Wed, 10 Oct 2018 16:33:01 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
MIME-Version: 1.0
In-Reply-To: <AM0PR06MB40833D8AED0744BB597394E7E7E00@AM0PR06MB4083.eurprd06.prod.outlook.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-Outbound-SMTP-Client: 10.63.23.158, dhcp-ensft1-uk-vla370-10-63-23-158.cisco.com
X-Outbound-Node: aer-core-2.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/AFMRatTJ0oTdheR7XNOsQzmvDuI>
Subject: Re: [netmod] WHEN statement within mandatory objects doesn't ensure presence of the mandatory object
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
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, 10 Oct 2018 15:33:07 -0000
Hi Mike, I think that the YANG below already enforces what you want, or otherwise I don't follow your issue. The YANG below is valid in two cases: (1) AssignmentMechanism = DHCP, and IPAddresses is not present in the config (due to the when statement). (2) AssignmentMechanism = Static, IPAddresses exists and has at least one element (due to min-elements 1). Thanks, Rob On 10/10/2018 16:23, Michael Rehder wrote: > Container "foo" would be mandatory if not for the "when" child element. > With the "when" child element, the logic becomes "inverted" and the constraint is a negative one of "disallowed under certain condition". > > The UC is for enforcement in REST API payloads. > For a practical example: > > leaf AssignmentMechanism { > type enumeration { > enum "DHCP"; > enum "Static"; > } > mandatory true; > description "The address assignment mechanism."; > } > list IPAddresses { > when "../AssignmentMechanism = 'Static'"; > key Address; > min-elements 1; > > leaf Address { > type capit:IPv4Address; > description "An ipv4 address."; > } > } > > There is no way in the IPAddresses list to enforce that there is at least one IP Address when the assignment method is "Static". > One could put a "must" on "AssignmentMechanism" to ensure at least one element of the IPAddresses list when "Static", but I don't see this as a good schema design, to have the controlling attribute check controlled attributes. > > I appreciate that this semantic can't be changed in YANG at this point. > Could the "when" statement have a modifying child element to state that the mandatory status of the element is to be enforced? > Like > container foo { > when "condition" { > enforce-mandatory-status; > } > > There is already back-end for existential checks for mandatory choice so this seems reasonably consistent to me. > I appreciate there are existing issues for "when" but I don't see why this would make things any worse. > In fact by promoting a better dependency "direction" between schema elements, think it could simplify things (so I naively think :) ). > > Thanks > Mike >> -----Original Message----- >> From: Ladislav Lhotka [mailto:lhotka@nic.cz] >> Sent: Wednesday, October 10, 2018 10:28 AM >> To: Michael Rehder <Michael.Rehder@Amdocs.com>; netmod@ietf.org >> Subject: Re: [netmod] WHEN statement within mandatory objects doesn't >> ensure presence of the mandatory object >> >> Michael Rehder <Michael.Rehder@Amdocs.com> writes: >> >>> I have a question about “when” and mandatory objects. >>> >>> It seems to me that the implemented semantics of “when” are really >> “optional when”, in that the enclosing object can be absent even though it is >> mandatory and the “when” clause holds true. >>> The RFC could be clearer about this. >>> >>> Example >>> >>> leaf color { >>> enumeration { >>> enum “blue”; >>> enum “black”; >>> } >>> mandatory true; >>> } >>> container foo { >>> when ../color = ‘blue’; >>> etc. >>> } >>> >>> “foo” is optional due to the presence of the “when” statement even >>> though the object is mandatory (same is true for mandatory leaf, >>> min-elements=1 list etc.). >> Maybe you intended to have, e.g., a "mandatory true" leaf inside "container >> foo"? >> >>> This is considered valid XML for the above >>> <color>blue</color> >> Yes, it is, under current YANG rules, no matter what "etc." stands for. Note that >> evaluation of the XPath expression in this case (with "foo" missing) requires the >> peculiar procedure of sec. 7.21.5 in RFC 7950. >> >>> In my view this makes conditionally variant schemas “loose” in their >>> enforcement (some scenarios can use choice but it doesn’t cover >>> everything). >>> >>> I think that mandatory should be respected for the enclosing objects >>> of a “when” statement. That is, a mandatory object must be present >>> when its “when” clause holds true and a Schematron statement should >>> enforce that. >> In fact, this is one case where the DSDL mapping (RFC 6110) deviates from >> YANG 1.0. Nodes that mandatory aren't enclosed in the RELAX NG <optional> >> pattern, and are then required no matter what any "when" >> statements say (because RELAX NG validation comes before Schematron). >> >>> What is the rationale behind the current YANG rules behavior, that the >>> “when” Schematron mapping doesn’t check for presence of the enclosing >>> mandatory object? >> FWIW, I have been repeatedly protesting against this behaviour but without >> much luck. See for example >> >> https://www.ietf.org/mail-archive/web/netmod/current/msg14012.html >> >> As a result, "when" is the trickiest feature in YANG by far. >> >> Lada >> >>> thanks >>> Mike Rehder >> -- >> Ladislav Lhotka >> Head, CZ.NIC Labs >> PGP Key ID: 0xB8F92B08A9F76C67 > “Amdocs’ email platform is based on a third-party, worldwide, cloud-based system. Any emails sent to Amdocs will be processed and stored using such system and are accessible by third party providers of such system on a limited basis. Your sending of emails to Amdocs evidences your consent to the use of such system and such processing, storing and access”. > _______________________________________________ > netmod mailing list > netmod@ietf.org > https://www.ietf.org/mailman/listinfo/netmod
- [netmod] WHEN statement within mandatory objects … Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] WHEN statement within mandatory obje… Ladislav Lhotka
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Robert Wilton
- Re: [netmod] WHEN statement within mandatory obje… Ladislav Lhotka
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Juergen Schoenwaelder
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Ladislav Lhotka
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Robert Wilton
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Robert Wilton
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Juergen Schoenwaelder
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Robert Wilton
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Robert Wilton
- Re: [netmod] WHEN statement within mandatory obje… Ladislav Lhotka
- Re: [netmod] WHEN statement within mandatory obje… Michael Rehder
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Alex Campbell
- Re: [netmod] WHEN statement within mandatory obje… Andy Bierman
- Re: [netmod] WHEN statement within mandatory obje… Alex Campbell