module org-openroadm-routing-policy { namespace "http://org/openroadm/routing-policy"; prefix rt-pol; import ietf-inet-types { prefix inet; } import ietf-yang-types { prefix yang; } import org-openroadm-device { prefix org-openroadm-device; revision-date 2025-05-30; } organization "Open ROADM MSA"; contact "OpenROADM.org"; description "This model defines Yang model for routing policy. This model reuses data items defined in the IETF YANG model for routing policy by RFC9067. Some attributes which are not required in Open ROADM MSA are removed. Yang file included are changed to fit into Open ROADM MSA yang structure. IETF code is subject to the following copyright and license: Copyright (c) IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, is permitted pursuant to, and subject to the license terms contained in, the Simplified BSD License set forth in Section 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info)."; revision 2025-05-30 { description "Version 17.1.0"; } revision 2025-03-28 { description "Version 17.0"; } /* Type definition */ typedef policy-result-type { type enumeration { enum accept-route { description "Policy accepts the route and evaluation of the current policy definition stops."; } enum reject-route { description "Policy rejects the route and evaluation of the current policy definition stops."; } } description "Type used to specify route disposition in a policy chain"; } typedef tag-type { type union { type uint32; type yang:hex-string; } description "Type for expressing route tags on a local system; may be expressed as either decimal or hexadecimal integer."; reference "RFC 2328: OSPF Version 2"; } /* Set definition */ grouping prefix-set-top { description "Top-level data definitions for a list of IPv4 or IPv6 prefixes which are matched as part of a policy"; container prefix-sets { description "Enclosing container "; list prefix-set { key "name"; description "List of the defined prefix sets"; leaf name { type string; description "Name of the prefix set"; } leaf mode { type enumeration { enum ipv4 { description "Prefix set contains IPv4 prefixes only."; } enum ipv6 { description "Prefix set contains IPv6 prefixes only."; } } description "Indicates the mode of the prefix set in terms of which address families (IPv4 or IPv6) are present. The mode provides a hint; all prefixes MUST be of the indicated type. The device MUST validate all prefixes and reject the configuration if there is a discrepancy."; } list prefix { key "ip-prefix masklength-range"; description "List of prefixes in the prefix set"; leaf ip-prefix { type inet:ip-prefix; mandatory true; description "The IP prefix represented as an IPv6 or IPv4 network number followed by a prefix length with an intervening slash character as a delimiter. All members of the prefix-set MUST be of the same address family as the prefix-set mode."; } leaf masklength-range { type string { pattern '(([0-9]+\.\.[0-9]+)|exact)'; } description "Defines a range for the masklength, or 'exact' if the prefix has an exact length. Example: 192.0.2.0/24 through 192.0.2.0/26 would be expressed as prefix: 192.0.2.0/24, masklength-range: 24..26. Example: 2001:DB8::/32 through 2001:DB8::/64 would be expressed as prefix: 2001:DB8::/32, masklength-range: 32..64 Example: 10.3.192.0/21 would be expressed as prefix: 10.3.192.0/21, masklength-range: exact"; } } } } } grouping tag-set-top { description "Top-level data definitions for a list of tags which can be matched in policies"; container tag-sets { description "Data definitions for a list of tags that can be matched in policies."; list tag-set { key "name"; description "List of tag set definitions."; leaf name { type string; description "Name of the tag set; this is used as a label to reference the set in match conditions."; } leaf-list tag-value { type tag-type; description "Value of the tag set member."; } } } } grouping match-set-options-group { description "Grouping containing options relating to how a particular set will be matched."; leaf match-set-options { type enumeration { enum any { description "Match is true if given value matches any member of the defined set."; } enum all { description "Match is true if given value matches all members of the defined set."; } enum invert { description "Match is true if given value does not match any member of the defined set."; } } default "any"; description "Optional parameter that governs the behavior of the match operation."; } } grouping match-set-options-restricted-group { description "Grouping for a restricted set of match operation modifiers."; leaf match-set-options { type enumeration { enum any { description "Match is true if given value matches any member of the defined set."; } enum invert { description "Match is true if given value does not match any member of the defined set."; } } default "any"; description "Optional parameter that governs the behavior of the match operation. This leaf only supports the 'any' and 'invert' match options. Matching on 'all' is not supported."; } } grouping policy-conditions-top { description "Top-level grouping for policy conditions"; container match-prefix-set { leaf prefix-set { type leafref { path "../../../../../../../defined-sets/" + "prefix-sets/prefix-set/name"; } description "References a defined prefix set."; } uses match-set-options-restricted-group; description "Match a referenced prefix-set according to the logic defined in the match-set-options leaf."; } container match-tag-set { leaf tag-set { type leafref { path "../../../../../../../defined-sets/" + "tag-sets/tag-set/name"; } description "References a defined tag set."; } uses match-set-options-group; description "Match a referenced tag set according to the logic defined in the match-set-options leaf."; } } grouping policy-actions-top { description "Top-level grouping for policy actions"; leaf policy-result { type policy-result-type; description "Select the final disposition for the route, either accept or reject."; } leaf set-tag { type tag-type; description "Set the tag for the route."; } } grouping routing-policy-top { description "Top level container for OpenConfig routing policy"; container routing-policy { description "Top-level container for all routing policy configuration"; container defined-sets { description "Predefined sets of attributes used in policy match statements"; uses prefix-set-top; uses tag-set-top; } container policy-definitions { description "Enclosing container for the list of top-level policy definitions"; list policy-definition { key "name"; description "List of top-level policy definitions, keyed by unique name. These policy definitions are expected to be referenced (by name) in policy chains specified in import or export configuration statements."; leaf name { type string; description "Name of the top-level policy definition; this name is used in references to the current policy."; } container statements { description "Enclosing container for policy statements."; list statement { key "name"; ordered-by user; description "Policy statements group conditions and actions within a policy definition. They are evaluated in the order specified."; leaf name { type string; description "Name of the policy statement."; } container conditions { description "Condition statements for the current policy statement."; uses policy-conditions-top; } container actions { description "Top-level container for policy action statements."; uses policy-actions-top; } } } } } } } augment "/org-openroadm-device:org-openroadm-device" { uses routing-policy-top; } }