[ONOS-4842] Leafref implementation for augment and uses
Change-Id: I919553a64d683aff65a8f16e2de783702dd5a45f
diff --git a/plugin/src/test/resources/interfileietf/ietf-network-topology.yang b/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
index 10c8fb9..4c57482 100644
--- a/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
@@ -103,7 +103,11 @@
description
"References a link in a specific network.";
leaf link-ref {
- type link-id;
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/lnk:link/lnk:link-id";
+ require-instance false;
+ }
description
"A type for an absolute reference a link instance.
(This type should not be used for relative references.
@@ -116,7 +120,12 @@
description
"References a termination point in a specific node.";
leaf tp-ref {
- type tp-id;
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/lnk:termination-point/lnk:tp-id";
+ require-instance false;
+ }
description
"A type for an absolute reference to a termination point.
(This type should not be used for relative references.
@@ -150,13 +159,18 @@
"This container holds the logical source of a particular
link.";
leaf source-node {
- type nd:node-id;
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
mandatory true;
description
"Source node identifier, must be in same topology.";
}
leaf source-tp {
- type tp-id;
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "source-node]/termination-point/tp-id";
+ }
description
"Termination point within source node that terminates
the link.";
@@ -167,14 +181,19 @@
"This container holds the logical destination of a
particular link.";
leaf dest-node {
- type nd:node-id;
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
mandatory true;
description
"Destination node identifier, must be in the same
network.";
}
leaf dest-tp {
- type tp-id;
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "dest-node]/termination-point/tp-id";
+ }
description
"Termination point within destination node that
terminates the link.";
@@ -192,13 +211,20 @@
"Identifies the link, or links, that this link
is dependent on.";
leaf network-ref {
- type nd:network-id;
+ type leafref {
+ path "../../../nd:supporting-network/nd:network-ref";
+ require-instance false;
+ }
description
"This leaf identifies in which underlay topology
supporting link is present.";
}
leaf link-ref {
- type link-id;
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/link/link-id";
+ require-instance false;
+ }
description
"This leaf identifies a link which is a part
of this link's underlay. Reference loops, in which
@@ -237,19 +263,30 @@
The corresponding information is simply provided by the
implementing system.";
leaf network-ref {
- type nd:network-id;
+ type leafref {
+ path "../../../nd:supporting-node/nd:network-ref";
+ require-instance false;
+ }
description
"This leaf identifies in which topology the
supporting termination point is present.";
}
leaf node-ref {
- type nd:node-id;
+ type leafref {
+ path "../../../nd:supporting-node/nd:node-ref";
+ require-instance false;
+ }
description
"This leaf identifies in which node the supporting
termination point is present.";
}
leaf tp-ref {
- type tp-id;
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/termination-point/tp-id";
+ require-instance false;
+ }
description
"Reference to the underlay node, must be in a
different topology";
diff --git a/plugin/src/test/resources/interfileietf/ietf-network.yang b/plugin/src/test/resources/interfileietf/ietf-network.yang
index 9dbe38f..60c47ce 100644
--- a/plugin/src/test/resources/interfileietf/ietf-network.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-network.yang
@@ -87,7 +87,10 @@
"Contains the information necessary to reference a network,
for example an underlay network.";
leaf network-ref {
- type network-id;
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
description
"Used to reference a network, for example an underlay
network.";
@@ -98,7 +101,11 @@
description
"Contains the information necessary to reference a node.";
leaf node-ref {
- type node-id;
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
description
"Used to reference a node.
Nodes are identified relative to the network they are
@@ -135,7 +142,10 @@
"An underlay network, used to represent layered network
topologies.";
leaf network-ref {
- type network-id;
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
description
"References the underlay network.";
}
@@ -157,13 +167,19 @@
this node is supported by. Used to represent layering
structure.";
leaf network-ref {
- type network-id;
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
description
"References the underlay network that the
underlay node is part of.";
}
leaf node-ref {
- type node-id;
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
description
"References the underlay node itself.";
}
diff --git a/plugin/src/test/resources/interfileietf/ietf-te-topology.yang b/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
index 5b65dff..582ba9e 100644
--- a/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -515,14 +515,14 @@
"A container controlling performance metric throttle.";
container performance-metric-throttle {
if-feature te-performance-metric;
- /*must "suppression-interval >= measure-interval" {
+ must "suppression-interval >= measure-interval" {
error-message
"suppression-interval cannot be less then
measure-interval.";
description
"Constraint on suppression-interval and
measure-interval.";
- }*/
+ }
description
"Link performance information in real time.";
reference
@@ -549,7 +549,7 @@
}
leaf suppression-interval {
type uint32 {
- range "1..max";
+ range "1 .. max";
}
default 120;
description
@@ -633,13 +633,25 @@
"Identify the sequence in the bundle.";
}
leaf src-tp-ref {
- type nt:tp-id;
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:source/"
+ + "nt:source-node]/"
+ + "nt:termination-point/nt:tp-id";
+ require-instance true;
+ }
description
"Reference to another TE termination point on the
same souruce node.";
}
leaf des-tp-ref {
- type nt:tp-id;
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:destination/"
+ + "nt:dest-node]/"
+ + "nt:termination-point/nt:tp-id";
+ require-instance true;
+ }
description
"Reference to another TE termination point on the
same destination node.";
@@ -682,7 +694,9 @@
leaf-list te-link-template {
if-feature template;
- type te-template-name;
+ type leafref {
+ path "../../../../../te/templates/link-template/name";
+ }
description
"The reference to a TE link template.";
}
@@ -862,12 +876,16 @@
RFC4203: OSPF Extensions in Support of Generalized
Multi-Protocol Label Switching (GMPLS).";
leaf switching-capability {
- type string;
+ type identityref {
+ base te-types:switching-capabilities;
+ }
description
"Switching Capability for this interface.";
}
leaf encoding {
- type string;
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
description
"Encoding supported by this interface.";
}
@@ -929,12 +947,16 @@
"RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
for Multi-Layer and Multi-Region Networks (MLN/MRN).";
leaf upper-sc {
- type string;
+ type identityref {
+ base te-types:switching-capabilities;
+ }
description
"Switching Capability for this interface.";
}
leaf upper-encoding {
- type string;
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
description
"Encoding supported by this interface.";
}
@@ -1140,13 +1162,17 @@
uses te-node-tunnel-termination-capability;
leaf switching-capability {
- type string;
+ type identityref {
+ base te-types:switching-capabilities;
+ }
mandatory true;
description
"Switching Capability.";
}
leaf encoding {
- type string;
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
mandatory true;
description
"Encoding type.";
@@ -1162,7 +1188,9 @@
leaf-list te-node-template {
if-feature template;
- type te-template-name;
+ type leafref {
+ path "../../../../../te/templates/node-template/name";
+ }
description
"The reference to a TE node template.";
}
@@ -1231,7 +1259,9 @@
}
container from {
leaf tp-ref {
- type nt:tp-id;
+ type leafref {
+ path "../../../../../../nt:termination-point/nt:tp-id";
+ }
description
"Relative reference to source termination point.";
}
@@ -1240,7 +1270,9 @@
}
container to {
leaf tp-ref {
- type nt:tp-id;
+ type leafref {
+ path "../../../../../../nt:termination-point/nt:tp-id";
+ }
description
"Relative reference to destination termination point.";
}
@@ -1402,7 +1434,9 @@
The capability information can be used to compute
the tunnel path.";
leaf link-tp {
- type nt:tp-id;
+ type leafref {
+ path "../../../../../nt:termination-point/nt:tp-id";
+ }
description
"Link termination point.";
}
@@ -1562,22 +1596,37 @@
description
"References a TE topology.";
leaf provider-id-ref {
- type te-global-id;
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:provider-id";
+ require-instance false;
+ }
description
"A reference to a provider-id.";
}
leaf client-id-ref {
- type te-global-id;
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:client-id";
+ require-instance false;
+ }
description
"A reference to a client-id.";
}
leaf te-topology-id-ref {
- type tet:te-topology-id;
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
+ require-instance false;
+ }
description
"A reference to a te-topology-id.";
}
leaf network-id-ref {
- type nw:network-id;
+ type leafref {
+ path "/nw:networks/nw:network/nw:network-id";
+ require-instance false;
+ }
description
"A reference to a network-id in base ietf-network module.";
}
diff --git a/plugin/src/test/resources/interfileietf/ietf-te-types.yang b/plugin/src/test/resources/interfileietf/ietf-te-types.yang
index 4b9d3be..9347f26 100644
--- a/plugin/src/test/resources/interfileietf/ietf-te-types.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-te-types.yang
@@ -580,7 +580,7 @@
typedef admin-group {
type binary {
- length 32;
+ length 32;
}
description
"Administrative group/Resource class/Color.";
@@ -680,12 +680,18 @@
"The tunnel path hop limit.";
}
leaf metric-type {
- type string;
+ type identityref {
+ base path-metric-type;
+ }
+ default path-metric-te;
description
"The tunnel path metric type.";
}
leaf tiebreaker-type {
- type string;
+ type identityref {
+ base path-tiebreaker-type;
+ }
+ default path-tiebreaker-maxfill;
description
"The tunnel path computation tie breakers.";
}
@@ -729,7 +735,9 @@
list constraints {
key "usage";
leaf usage {
- type string;
+ type identityref {
+ base resource-affinities-type;
+ }
description "Affinities usage";
}
container constraint {
@@ -765,7 +773,9 @@
"Type of SRLG representation";
case values {
leaf usage {
- type string;
+ type identityref {
+ base route-exclude-srlg;
+ }
description "SRLG usage";
}
leaf-list values {
@@ -777,7 +787,9 @@
list constraints {
key "usage";
leaf usage {
- type string;
+ type identityref {
+ base route-exclude-srlg;
+ }
description "SRLG usage";
}
container constraint {
@@ -829,12 +841,17 @@
source.";
}
leaf type {
- type string;
+ type identityref {
+ base bidir-association-type;
+ }
+ default bidir-assoc-non-corouted;
description
"The TE tunnel association type.";
}
leaf provisioing {
- type string;
+ type identityref {
+ base bidir-provisioning-mode;
+ }
description
"Describes the provisioning model of the
associated bidirectional LSP";