Merge "Integration build failure fix:"
[vpnservice.git] / vpnmanager / vpnmanager-api / src / main / yang / l3vpn.yang
1 module l3vpn {
2   namespace "urn:huawei:params:xml:ns:yang:l3vpn";
3 // replace with IANA namespace when assigned
4   prefix "l3vpn";
5
6   import bgp {
7     prefix bgp;
8     //draft-zhdankin-netmod-bgp-cfg
9   }
10   import ietf-interfaces {
11     prefix if;
12     //rfc7223-YANG Interface Management
13   }
14
15   import ietf-inet-types {
16     prefix inet;
17     //RFC6991
18   }
19
20   import ietf-yang-types {
21     prefix yang;
22     //RFC6991
23   }
24
25   description
26     "This YANG module defines the generic configuration data for L3VPN service.
27
28      Terms and Acronyms
29
30      BGP (bgp): Border Gateway Protocol
31      IPv4 (ipv4):Internet Protocol Version 4
32      IPv6 (ipv6): Internet Protocol Version 6
33
34     ";
35
36   revision 2014-08-15 {
37     description
38       "Initial revision.";
39       reference "RFC4271, RFC4364, RFC4760";
40   }
41
42   grouping augment-bgp-af-vpn-config {
43     description
44       "A set of configuration parameters that is applicable to both BGP-VPNv4
45       and BGP-VPNv6 address family.";
46
47     leaf apply-label-per-nexthop {
48       description
49         "The apply-label per-nexthop command enables the ASBR to allocate
50          labels for IPv4 VPN routes or IPv6 VPN routes based on the next hop.";
51
52
53
54       config "true";
55       type boolean;
56       default "false";
57     }
58
59     leaf upeEnable {
60       description
61         "Specify peer as UPE.";
62
63       config "true";
64       type boolean;
65       default "false";
66     }
67
68   }
69
70
71   grouping bgp-af-vpn-instance-config {
72
73     container router-id {
74       description
75         "The router-id command configures router ID for BGP VPN instance IPv4
76         or IPv6 address family.
77         By default, no router ID is configured for BGP VPN instance IPv4 or
78         IPv6 address family, and the BGP router ID is used as the router ID.";
79
80       leaf enable {
81         type boolean;
82       }
83
84       choice config-type {
85         case static {
86           leaf ip-address {
87             description
88               "Specifies the router ID of a BGP VPN instance IPv4 address
89                family. The router ID is expressed in the IPv4 address format.
90                ";
91
92             config "true";
93             type inet:ip-address;
94           }
95         }
96         case auto-select {
97           leaf enable-auto-select {
98             description
99               "Configures automatic route ID selection for the current BGP VPN
100                instance address family.";
101
102
103             config "true";
104             type boolean;
105           }
106         }
107       }
108     }
109
110     leaf auto-frr {
111       description
112         "The auto-frr command enables BGP Auto FRR.";
113
114       config "true";
115       type boolean;
116       default "false";
117     }
118
119     container bgpPeers {
120       list bgpPeer {
121       key "peerAddr";
122       max-elements "unbounded";
123       min-elements "0";
124         description
125           "BGP Peer configure class";
126
127         leaf peerAddr {
128           description
129             "The nerighbor address";
130             config "true";
131             type inet:ip-address;
132             mandatory true;
133         }
134
135           leaf groupName {
136             description "peerGroupName";
137             config "true";
138             type string {
139               length "1..47";
140             }
141           }
142           leaf remoteAs {
143             description "Specifies the AS number of the peer.";
144             config "true";
145             type string {
146               length "1..11";
147             }
148           }
149
150           leaf description {
151
152             description
153               "specifies the description. The description is a string of letters
154                or figures. The value ranges from 1 to 80 characters without
155                spaces.";
156           config "true";
157             type string {
158               length "1..80";
159               pattern "([^?]*)";
160             }
161           }
162
163           leaf soo {
164             description
165               "The peer soo command configures the Site of Origin (SoO)
166                attribute for an EBGP peer in a BGP VPN instance. Format is ASN:nn
167                or IP-address:nn.";
168
169           config "true";
170           type string {
171             length "3..21";
172           }
173         }
174
175         leaf substituteAsEnable {
176           description
177             "Using the peer substitute-as command, you can substitute the AS
178              number of the specified peer in the as-path with the local AS
179              number.";
180
181           config "true";
182           type boolean;
183             default "false";
184         }
185
186       }
187     }
188
189   }
190
191   grouping vpn-af-config {
192     description
193       "A set of configuration parameters that is applicable to both IPv4 and
194        IPv6 address family for a VPN instance .";
195
196     leaf route-distinguisher {
197       description
198         "The route-distinguisher command configures a route distinguisher (RD)
199          for the IPv4 or IPv6 address family of a VPN instance.
200
201          Format is ASN:nn or IP-address:nn.";
202
203       config "true";
204       type string {
205         length "3..21";
206       }
207     }
208
209     container vpnTargets {
210       description
211         "The vpn-target command configures the export or import VPN target
212          extended community attribute for the VPN instance IPv4/IPv6 address
213          family.
214          Format is ASN:nn or IP-address:nn.";
215
216       list vpnTarget {
217         key "vrfRTValue";
218         max-elements "unbounded";
219         min-elements "0";
220         description
221           "L3vpn vpntarget configure class";
222
223         leaf vrfRTValue {
224
225           description
226             "Vpn-target: adds VPN target extended community attribute to the
227              export or import VPN target extended community list. The
228              vpn-target can be expressed in either of the following formats:
229              (1)16-bit AS number:32-bit user-defined number
230                  For example, 1:3. The AS number ranges from 0 to 65535. The
231                  user-defined number ranges from 0 to 4294967295. The AS number
232                  and the user-defined number cannot be 0s at the same time.
233                  That is, a VPN target cannot be 0:0.
234              (2)32-bit IP address:16-bit user-defined number
235                 For example, 192.168.122.15:1. The IP address ranges from
236                 0.0.0.0 to 255.255.255.255. The user-defined number ranges from
237                 0 to 65535.
238              (3)32-bit IP address:16-bit user-defined number
239                 For example, 192.168.122.15:1. An IP address ranges from
240                 0.0.0.0 to 255.255.255.255. A user-defined number ranges from 0
241                 to 65535.";
242
243           config "true";
244           mandatory "true";
245           type string {
246             length "3..21";
247           }
248         }
249
250         leaf vrfRTType {
251           description
252             "Specifies the vpn target type, export-extcommunity:
253              specifies the extended community attributes carried in routing
254              information to be sent. import-extcommunity: receives routing
255              information carrying specified extended community attributes.";
256
257             mandatory "true";
258             type enumeration {
259             enum export_extcommunity {
260               value "0";
261               description "export-extcommunity:";
262             }
263             enum import_extcommunity {
264               value "1";
265               description "import-extcommunity:";
266             }
267             enum both {
268               value "2";
269               description "export-extcommunity & import-extcommunity:";
270             }
271           }
272         }
273       }
274     }
275
276     container apply-label {
277       description
278         "Apply one label mode for the VPN instance route.";
279
280       choice apply-label-mode {
281         case per-route {
282           description
283             "The apply-label per-route command enables the one-label-per-route
284              mode. The VPN instance IPv4/IPv6 address family assigns a unique
285              label to each route to be sent to the peer PE.";
286
287           leaf apply-label-per-route {
288             type boolean;
289             default "true";
290           }
291         }
292         case per-instance {
293           description
294             "The apply-label per-instance command applies one label to all VPN
295              instance IPv4 address family or IPv6 address family routes to a
296              peer PE.";
297
298         leaf apply-label-per-instance {
299             type boolean;
300             default "false";
301           }
302         }
303       }
304     }//End of "container apply-label"
305
306     leaf import-route-policy {
307       description
308         "The import route-policy command associates a VPN instance enabled
309          with the IPv4 or IPv6 address family with an import routing policy.
310          Only one import routing policy can be associated with a VPN instance
311          enabled with the IPv4 or IPv6 address family. If the import
312          route-policy command is run more than once, the latest configuration
313          overrides the previous ones.";
314
315         config "true";
316         type string {
317           length "1..40";
318         }
319     }
320
321     leaf export-route-policy {
322       description
323         "The export route-policy command associates a VPN instance enabled
324          with the IPv4 or IPv6 address family with an export routing policy.
325          Only one export routing policy can be associated with a VPN instance
326          enabled with the IPv4 or IPv6 address family. If the export
327          route-policy command is run more than once, the latest configuration
328          overrides the previous ones.";
329
330       config "true";
331       type string {
332         length "1..40";
333       }
334     }
335
336
337     container prefix-limit {
338       description
339         "The prefix limit command sets a limit on the maximum number of
340          prefixes supported in the existing VPN instance, preventing the
341          PE from importing excessive VPN route prefixes.";
342
343       leaf prefix-limit-number {
344         description
345           "Specifies the maximum number of prefixes supported in the VPN
346
347
348            instance IPv4 or IPv6 address family.";
349
350         type uint32 {
351           range "1..4294967295";
352         }
353       }
354
355       choice prefix-limit-action {
356         case enable-alert-percent {
357           leaf alert-percent-value {
358             description
359               "Specifies the proportion of the alarm threshold to the maximum
360                number of prefixes.";
361             type uint8 {
362               range "1..100";
363             }
364           }
365           leaf route-unchanged {
366             description
367               "Indicates that the routing table remains unchanged. By default,
368                route-unchanged is not configured. When the number of prefixes
369                in the routing table is greater than the value of the parameter
370                number, routes are processed as follows:
371                (1)If route-unchanged is configured, routes in the routing table
372                   remain unchanged.
373                (2)If route-unchanged is not configured, all routes in the
374                   routing table are deleted and then re-added.";
375
376             config "true";
377             type boolean;
378             default "false";
379           }
380         }
381         case enable-simple-alert {
382           leaf simple-alert {
383             description
384               "Indicates that when the number of VPN route prefixes exceeds
385                number, prefixes can still join the VPN routing table and
386                alarms are displayed.";
387
388             config "true";
389             type boolean;
390             default "false";
391           }
392         }
393       }
394     }
395
396
397
398    container routing-table-limit {
399       description
400         "The routing-table limit command sets a limit on the maximum number of
401         routes that the IPv4 or IPv6 address family of a VPN instance can
402         support.
403         By default, there is no limit on the maximum number of routes that the
404         IPv4 or IPv6 address family of a VPN instance can support, but the
405         total number of private network and public network routes on a device
406         cannot exceed the allowed maximum number of unicast routes.";
407
408       leaf routing-table-limit-number {
409         description
410           "Specifies the maximum number of routes supported by a VPN instance.
411           ";
412
413         config "true";
414         type uint32 {
415           range "1..4294967295";
416         }
417       }
418       choice routing-table-limit-action {
419         case enable-alert-percent {
420           leaf alert-percent-value {
421             description
422               "Specifies the percentage of the maximum number of routes. When
423                the maximum number of routes that join the VPN instance is up
424                to the value (number*alert-percent)/100, the system prompts
425                alarms. The VPN routes can be still added to the routing table,
426                but after the number of routes reaches number, the subsequent
427                routes are dropped.";
428
429             config "true";
430             type uint8 {
431               range "1..100";
432             }
433           }
434         }
435         case enable-simple-alert {
436           leaf simple-alert {
437             description
438               "Indicates that when VPN routes exceed number, routes can still
439                be added into the routing table, but the system prompts alarms.
440                However, after the total number of VPN routes and network public
441                routes reaches the unicast route limit specified in the License,
442                the subsequent VPN routes are dropped.";
443
444             config "true";
445             type boolean;
446             
447           }
448         }
449       }
450     }
451
452     leaf vpn-frr {
453       description
454         "Enable VPN FRR in the VPN instance address family view.
455          If a PE is connected to two other PEs, running the vpn frr command in
456          the VPN instance address family view of the PE enables VPN FRR and
457          improves network reliability. After VPN FRR is configured, traffic can
458          switch to the secondary LSP immediately after the primary LSP becomes
459          faulty.";
460
461       type boolean;
462       default "false";
463     }
464
465
466    /*
467     * VPN QoS.
468     */
469     container l3vpnVrfPipe {
470       description
471         "The diffserv-mode command configures the mode of the MPLS
472         differentiated service (Diff-Serv) for ensuring end-to-end QoS.";
473
474       leaf pipeMode {
475         description
476           "Pipe mode";
477
478     type enumeration {
479       enum pipe {
480         value "0";
481         description
482           "pipe: Indicates that the Pipe MPLS Diff-Serv mode is adopted.";
483       }
484       enum shortPipe {
485         value "1";
486         description
487           "shortPipe: Indicates that the Short-pipe MPLS Diff-Serv mode
488           is adopted.";
489       }
490       enum uniform {
491         value "2";
492         description
493           "uniform: Indicates that the Uniform MPLS Diff-Serv mode is
494           adopted.";
495    }
496     }
497     default "uniform";
498
499       }
500
501       leaf serviceClass {
502         description
503           "Service Class, Specifies the service type when the packet enters the
504           public network from the private network. The values are cs7, cs6, ef,
505           af4, af3, af2, af1, be.";
506
507           type enumeration {
508             enum be {
509               value "0";
510               description "be:";
511             }
512             enum af1 {
513               value "1";
514               description "af1:";
515             }
516             enum af2 {
517               value "2";
518               description "af2:";
519             }
520             enum af3 {
521               value "3";
522               description "af3:";
523             }
524             enum af4 {
525               value "4";
526               description "af4:";
527             }
528             enum ef {
529               value "5";
530               description "ef:";
531             }
532             enum cs6 {
533               value "6";
534               description "cs6:";
535             }
536             enum cs7 {
537               value "7";
538               description "cs7:";
539             }
540           }
541           default "be";
542       }
543
544
545       leaf color {
546         description
547           "Specifies a color for marking the discard priority of a packet
548           transferred from a private network to a public network. The values
549           are green, yellow, and red.";
550
551         type enumeration {
552           enum green {
553             value "0";
554             description "green:";
555           }
556           enum yellow {
557             value "1";
558             description "yellow:";
559           }
560           enum red {
561             value "2";
562             description "red:";
563           }
564         }
565         default "green";
566       }
567
568       leaf dsName {
569         description
570           "Specifies the DS domain name of the specified Per-Hop Behavior (PHB)
571           applied to the egress in Short pipe mode. It is a string of 1 to 31
572           characters.";
573
574         type string;
575         default "default";
576       }
577     }
578
579     container l3vpnTtlMode {
580       description
581         "The ttl-mode command enables MPLS to process the TTL in a specified
582         mode. By default, MPLS processes the TTL in pipe mode.";
583
584       leaf ttlMode {
585         description "TTL mode";
586         default "pipe";
587         type enumeration {
588           enum pipe {
589             value "0";
590             description
591               "pipe: Enables MPLS to process the TTL in pipe mode.";
592           }
593
594
595           enum uniform {
596             value "1";
597             description
598               "uniform: Enables MPLS to process the TTL in uniform mode.";
599           }
600         }
601       }
602     }
603
604     leaf tunnel-policy {
605       description
606         "The tnl-policy command associates the IPv4 or IPv6 address family of
607          a VPN instance with a tunnel policy.";
608
609       type string {
610         length "1..39";
611       }
612     }
613
614     container importRibs {
615       description
616         "Import route class";
617
618       leaf protocol {
619         description
620           "Specifies the protocol from which routes are imported.
621           At present, In the IPv4 unicast address family view, the protocol
622           can be IS-IS,static, direct and BGP.";
623
624         type enumeration {
625           enum ALL {
626             value "0";
627             description "ALL:";
628           }
629           enum Direct {
630             value "1";
631             description "Direct:";
632           }
633           enum OSPF {
634             value "2";
635             description "OSPF:";
636           }
637           enum ISIS {
638             value "3";
639             description "ISIS:";
640           }
641           enum Static {
642             value "4";
643
644
645             description "Static:";
646           }
647           enum RIP {
648             value "5";
649             description "RIP:";
650           }
651           enum BGP {
652             value "6";
653             description "BGP:";
654           }
655           enum OSPFV3 {
656             value "7";
657             description "OSPFV3:";
658           }
659           enum RIPNG {
660             value "8";
661             description "RIPNG:";
662           }
663           enum INVALID {
664             value "9";
665             description "INVALID:";
666           }
667         }
668       }
669
670       leaf processId {
671         description
672           "Specifies the process ID if the protocol from routes are imported is
673            IS-IS.";
674
675         default "0";
676         type uint32 {
677           range "0..4294967295";
678         }
679       }
680
681       leaf bgp-valid-route {
682         type boolean;
683       }
684
685       leaf policyName {
686         description
687           "Policy Id for import routes";
688         type string {
689         }
690       }
691
692     }
693
694
695     leaf traffic-statistics {
696       description
697         "The traffic-statistics enable command enables traffic statistics
698          for a VPN instance.";
699
700       type boolean;
701       default "false";
702     }
703
704   }
705
706
707   /*
708    * VPN instance view.
709    */
710   container vpn-instances {
711     description
712       "VPN instances configuration parameters.
713        VPN instances support both the IPv4 and IPv6 address families.";
714
715     list vpn-instance {
716       max-elements "unbounded";
717       min-elements "0";
718       key "vpn-instance-name";
719       description
720         "Specifies the name of the VPN instance. It is a string of 1 to 31
721          case-sensitive characters.";
722
723       leaf vpn-instance-name {
724         mandatory "true";
725         type string {
726           length "1..31";
727         }
728         description
729           "The name of the vpn-instance.";
730       }
731
732       leaf description {
733         description
734           "A textual description of VPN instance, the VPN instance description
735           helps users memorize the VPN instance.";
736
737         type string {
738           length "1..242";
739           pattern "([^?]*)";
740         }
741       }
742
743
744
745
746       container ipv4-family {
747         description
748           "The IPv4 address family is enabled for the VPN instance.";
749
750         uses vpn-af-config;
751       }
752
753       container ipv6-family {
754         description
755           "The IPv6 address family is enabled for the VPN instance.";
756
757         uses vpn-af-config;
758       }
759
760
761     }
762   }
763
764
765
766   /*
767    * Binding Interfaces to a VPN Instance.
768    */
769
770   container vpn-interfaces {
771     description
772       "VPN is enabled on interfaces.";
773
774     list vpn-interface  {
775       key "name";
776       max-elements "unbounded";
777       min-elements "0";
778       leaf name {
779         type leafref {
780           path "/if:interfaces/if:interface/if:name";
781         }
782       }
783       leaf vpn-instance-name {
784         type string {
785           length "1..40";
786         }
787       }
788     }
789   }
790
791   container vrfInfo {
792     description
793       "Display the information of the vrf.
794
795
796       It is intended that this container may be augmented by vendors to
797       reflect the vendor-specific operational state parameters.";
798
799     leaf vrfCreateTime {
800       description
801         "CreateTime of the vrf.";
802       config "false";
803       type yang:timestamp;
804     }
805
806     leaf vrfUpTime {
807       description
808         "UpTime period of the vrf.";
809       config "false";
810       type yang:timeticks;
811     }
812
813     leaf label {
814       description
815         "Label of the vrf.";
816       config "false";
817       type uint32 {
818         range "16..1048574";
819       }
820     }
821
822     leaf vrfStatus {
823       description
824         "vrf status.";
825       config "false";
826       type enumeration {
827         enum up {
828           value "0";
829           description "vrf up.";
830         }
831         enum down {
832           value "1";
833           description "vrf down.";
834         }
835       }
836     }
837   }
838
839
840   /*
841    * augment some bgp vpn functions in bgp module.
842    */
843   augment "/bgp:bgp-router/bgp:vpnv4/bgp:unicast" {
844
845     uses augment-bgp-af-vpn-config;
846
847   }
848
849   augment "/bgp:bgp-router/bgp:vpnv6/bgp:unicast" {
850     uses augment-bgp-af-vpn-config;
851
852   }
853
854   augment "/bgp:bgp-router" {
855
856     container bgp-af-ipv4-vpn-instances {
857       description
858         "vpn-instances ipv4 address family.";
859       list bgp-af-ipv4-vpn-instance {
860         key "vpn-instance-name";
861         max-elements "unbounded";
862         min-elements "0";
863         leaf vpn-instance-name {
864           type string;
865         }
866         uses bgp-af-vpn-instance-config;
867       }
868     }
869
870     container bgp-af-ipv6-vpn-instances {
871       description
872         "vpn-instances ipv6 address family.";
873       list bgp-af-ipv6-vpn-instance {
874         key "vpn-instance-name";
875         max-elements "unbounded";
876         min-elements "0";
877         leaf vpn-instance-name {
878           type string;
879         }
880         uses bgp-af-vpn-instance-config;
881       }
882     }
883
884   }
885
886
887 }