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