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