Bug 133 - Changed vnfd-connection-point-ref to leafref
[osm/SO.git] / models / plugins / yang / nsd.yang
1
2 /*
3  * 
4  *   Copyright 2016 RIFT.IO Inc
5  *
6  *   Licensed under the Apache License, Version 2.0 (the "License");
7  *   you may not use this file except in compliance with the License.
8  *   You may obtain a copy of the License at
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *   Unless required by applicable law or agreed to in writing, software
13  *   distributed under the License is distributed on an "AS IS" BASIS,
14  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *   See the License for the specific language governing permissions and
16  *   limitations under the License.
17  *
18  *
19  */
20
21 module nsd
22 {
23   namespace "urn:ietf:params:xml:ns:yang:nfvo:nsd";
24   prefix "nsd";
25
26   import rw-pb-ext {
27     prefix "rwpb";
28   }
29
30   import vld {
31     prefix "vld";
32   }
33
34   import vnfd {
35     prefix "vnfd";
36   }
37
38   import ietf-inet-types {
39     prefix "inet";
40   }
41
42   import ietf-yang-types {
43     prefix "yang";
44   }
45
46   import mano-types {
47     prefix "manotypes";
48   }
49
50   revision 2014-10-27 {
51     description
52       "Initial revision. This YANG file defines
53        the Network Service Descriptor (NSD)";
54     reference
55       "Derived from earlier versions of base YANG files";
56   }
57
58   typedef scaling-trigger {
59     type enumeration {
60       enum pre-scale-in {
61         value 1;
62       }
63       enum post-scale-in {
64         value 2;
65       }
66       enum pre-scale-out {
67         value 3;
68       }
69       enum post-scale-out {
70         value 4;
71       }
72     }
73   }
74
75   typedef scaling-policy-type {
76     type enumeration {
77       enum manual {
78         value 1;
79       }
80       enum automatic {
81         value 2;
82       }
83     }
84   }
85
86   typedef scaling-criteria-operation {
87     type enumeration {
88       enum AND {
89         value 1;
90       }
91       enum OR {
92         value 2;
93       }
94     }
95   }
96
97   grouping primitive-parameter {
98     leaf name {
99       description
100           "Name of the parameter.";
101       type string;
102     }
103
104     leaf data-type {
105       description
106           "Data type associated with the name.";
107       type manotypes:parameter-data-type;
108     }
109
110     leaf mandatory {
111       description "Is this field mandatory";
112       type boolean;
113       default false;
114     }
115
116     leaf default-value {
117       description "The default value for this field";
118       type string;
119     }
120
121     leaf parameter-pool {
122       description "NSD Parameter pool name to use for this paramter";
123       type string;
124     }
125   }
126
127   grouping ns-initial-config-primitive {
128     leaf seq {
129       description
130           "Sequence number for the configuration primitive.";
131       type uint64;
132     }
133
134     leaf name {
135       description
136           "Name of the configuration primitive.";
137       type string;
138       mandatory "true";
139     }
140
141     leaf user-defined-script {
142       description
143           "A user defined script.";
144       type string;
145     }
146
147     list parameter {
148       key "name";
149       leaf name {
150         type string;
151       }
152
153       leaf value {
154         type string;
155       }
156     }
157   }
158
159   grouping nsd-descriptor {
160     leaf id {
161       description "Identifier for the NSD.";
162       type string;
163     }
164
165     leaf name {
166       description "NSD name.";
167       mandatory true;
168       type string;
169     }
170
171     leaf short-name {
172       description "NSD short name.";
173       type string;
174     }
175
176     leaf vendor {
177       description "Vendor of the NSD.";
178       type string;
179     }
180
181     leaf logo {
182       description
183         "File path for  the vendor specific logo. For example icons/mylogo.png.
184          The logo  should be part of the network service";
185       type string;
186     }
187
188     leaf description {
189       description "Description of the NSD.";
190       type string;
191     }
192
193     leaf version {
194       description "Version of the NSD";
195       type string;
196     }
197
198     list connection-point {
199       description
200           "List for external connection points.
201           Each NS has one or more external connection
202           points. As the name implies that external
203           connection points are used for connecting
204           the NS to other NS or to external networks.
205           Each NS exposes these connection points to
206           the orchestrator. The orchestrator can
207           construct network service chains by
208           connecting the connection points between
209           different NS.";
210
211       key "name";
212       leaf name {
213         description
214             "Name of the NS connection point.";
215         type string;
216       }
217
218       leaf type {
219         description
220             "Type of the connection point.";
221         type manotypes:connection-point-type;
222       }
223     }
224
225     /* Still having issues modelling this,
226        see the comments under vnfd-connection-point-ref
227      */
228     list vld {
229       description
230           "List of Virtual Link Descriptors.";
231
232       key "id";
233
234       leaf id {
235         description
236             "Identifier for the VLD.";
237         type string;
238       }
239
240       leaf name {
241         description
242             "Virtual Link Descriptor (VLD) name.";
243         type string;
244       }
245
246       leaf short-name {
247         description
248             "Short name for VLD for UI";
249         type string;
250       }
251
252       leaf vendor {
253         description "Provider of the VLD.";
254         type string;
255       }
256
257       leaf description {
258         description "Description of the VLD.";
259         type string;
260       }
261
262       leaf version {
263         description "Version of the VLD";
264         type string;
265       }
266
267       leaf type {
268         type manotypes:virtual-link-type;
269       }
270
271       leaf root-bandwidth {
272         description
273             "For ELAN this is the aggregate bandwidth.";
274         type uint64;
275       }
276
277       leaf leaf-bandwidth {
278         description
279             "For ELAN this is the bandwidth of branches.";
280         type uint64;
281       }
282
283       list vnfd-connection-point-ref {
284         description
285             "A list of references to connection points.";
286         key "member-vnf-index-ref";
287
288         leaf member-vnf-index-ref {
289           description "Reference to member-vnf within constituent-vnfds";
290           type leafref {
291             path "../../../constituent-vnfd/member-vnf-index";
292           }
293         }
294
295         leaf vnfd-id-ref {
296           description
297               "A reference to a vnfd. This is a
298                leafref to path:
299                    ../../nsd:constituent-vnfd
300                    + [nsd:id = current()/../nsd:id-ref]
301                    + /nsd:vnfd-id-ref
302                NOTE: An issue with confd is preventing the
303                use of xpath. Seems to be an issue with leafref
304                to leafref, whose target is in a different module.
305                Once that is resovled this will switched to use
306                leafref";
307           type string;
308         }
309
310         leaf vnfd-connection-point-ref {
311           description "A reference to a connection point name";
312           type leafref {
313             path "/vnfd:vnfd-catalog/vnfd:vnfd" +
314                  "[vnfd:id = current()/../vnfd-id-ref]/" +
315                  "vnfd:connection-point/vnfd:name";
316           }
317         }
318       }
319
320       // replicate for pnfd container here
321       uses manotypes:provider-network;
322
323       choice init-params {
324         description "Extra parameters for VLD instantiation";
325
326         case vim-network-ref {
327           leaf vim-network-name {
328             description
329                 "Name of network in VIM account. This is used to indicate
330                    pre-provisioned network name in cloud account.";
331             type string;
332           }
333         }
334         case vim-network-profile {
335           leaf ip-profile-ref {
336             description "Named reference to IP-profile object";
337             type string;
338           } 
339         }   
340       }
341     }
342
343     list constituent-vnfd {
344       description
345           "List of VNFDs that are part of this
346           network service.";
347
348       key "member-vnf-index";
349
350       leaf member-vnf-index {
351         description
352           "Identifier/index for the VNFD. This separate id
353            is required to ensure that multiple VNFs can be
354            part of single NS";
355         type uint64;
356       }
357
358       leaf vnfd-id-ref {
359         description
360           "Identifier for the VNFD.";
361         type leafref {
362           path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id";
363         }
364       }
365
366       leaf start-by-default {
367         description
368           "VNFD is started as part of the NS instantiation";
369         type boolean;
370         default true;
371       }
372     }
373
374     list scaling-group-descriptor {
375       description
376           "scaling group descriptor within this network service.
377            The scaling group defines a group of VNFs,
378            and the ratio of VNFs in the network service
379            that is used as target for scaling action";
380
381       key "name";
382
383       leaf name {
384         description "Name of this scaling group.";
385         type string;
386       }
387
388       list scaling-policy {
389
390         key "name";
391
392         leaf name {
393           description
394               "Name of the scaling policy";
395           type string;
396         }
397
398         leaf scaling-type {
399           description
400               "Type of scaling";
401           type scaling-policy-type;
402         }
403
404         leaf enabled {
405           description
406             "Specifies if the scaling policy can be applied";
407           type boolean;
408           default true;
409         }
410
411         leaf scale-in-operation-type {
412           description
413               "Operation to be applied to check between scaling criterias to 
414                check if the scale in threshold condition has been met.
415                Defaults to AND";
416           type scaling-criteria-operation;
417           default AND;
418         }
419
420         leaf scale-out-operation-type {
421           description
422               "Operation to be applied to check between scaling criterias to 
423                check if the scale out threshold condition has been met.
424                Defauls to OR";
425           type scaling-criteria-operation;
426           default OR;
427         }
428
429         leaf threshold-time {
430           description
431             "The duration for which the criteria must hold true";
432           type uint32;
433           mandatory true;
434         }
435
436         leaf cooldown-time {
437           description
438             "The duration after a scaling-in/scaling-out action has been
439             triggered, for which there will be no further optional";
440           type uint32;
441           mandatory true;
442         }
443
444         list scaling-criteria {
445           description
446               "list of conditions to be met for generating scaling
447                  requests";
448           key "name";
449
450           leaf name {
451             type string;
452           }
453
454           leaf scale-in-threshold {
455             description
456                 "Value below which scale-in requests are generated";
457             type uint64;
458           }
459
460           leaf scale-out-threshold {
461             description
462                 "Value above which scale-out requests are generated";
463             type uint64;
464           }
465
466           leaf ns-monitoring-param-ref {
467             description 
468                "Reference to the NS level monitoring parameter
469                 that is aggregated";
470             type leafref {
471               path "../../../../monitoring-param/id";
472             }
473           }
474         }
475       }
476
477       list vnfd-member {
478         description "List of VNFs in this scaling group";
479         key "member-vnf-index-ref";
480
481         leaf member-vnf-index-ref {
482           description "member VNF index of this member VNF";
483           type leafref {
484             path "../../../constituent-vnfd/member-vnf-index";
485           }
486         }
487
488         leaf count {
489           description
490             "count of this member VNF  within this scaling group.
491              The count allows to define  the number of instances
492              when a scaling action targets this scaling group";
493           type uint32;
494           default 1;
495         }
496       }
497
498       leaf min-instance-count {
499         description
500           "Minimum instances of the scaling group which are allowed.
501           These instances are created by default when the network service
502           is instantiated.";
503         type uint32;
504         default 0;
505       }
506
507       leaf max-instance-count {
508         description
509           "Maximum instances of this scaling group that are allowed
510            in a single network service. The network service scaling
511            will fail, when the number of service group instances
512            exceed the max-instance-count specified.";
513         type uint32;
514         default 10;
515       }
516
517       list scaling-config-action {
518         description "List of scaling config actions";
519         key "trigger";
520
521         leaf trigger {
522           description "scaling trigger";
523           type scaling-trigger;
524         }
525
526         leaf ns-config-primitive-name-ref {
527           description "Reference to the NS config name primitive";
528           type leafref {
529             path "../../../service-primitive/name";
530           }
531         }
532       }
533     }
534
535     list placement-groups {
536       description "List of placement groups at NS level";
537
538       key "name";
539       uses manotypes:placement-group-info;
540
541       list member-vnfd {
542         description
543             "List of VNFDs that are part of this placement group";
544
545         key "member-vnf-index-ref";
546
547         leaf member-vnf-index-ref {
548           description "member VNF index of this member VNF";
549           type leafref {
550             path "../../../constituent-vnfd/member-vnf-index";
551           }
552         }
553
554         leaf vnfd-id-ref {
555           description
556               "Identifier for the VNFD.";
557           type leafref {
558             path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id";
559           }
560         }
561       }
562     }
563
564     uses manotypes:ip-profile-list;
565
566     list vnf-dependency {
567       description
568           "List of VNF dependencies.";
569       key vnf-source-ref;
570       leaf vnf-source-ref {
571         type leafref {
572           path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id";
573         }
574       }
575       leaf vnf-depends-on-ref {
576         description
577             "Reference to VNF that sorce VNF depends.";
578         type leafref {
579           path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id";
580         }
581       }
582     }
583
584     list vnffgd {
585       description
586           "List of VNF Forwarding Graph Descriptors (VNFFGD).";
587
588       key "id";
589
590       leaf id {
591         description
592             "Identifier for the VNFFGD.";
593         type string;
594       }
595
596       leaf name {
597         description
598             "VNFFGD name.";
599         type string;
600       }
601
602       leaf short-name {
603         description
604             "Short name for VNFFGD for UI";
605         type string;
606       }
607
608       leaf vendor {
609         description "Provider of the VNFFGD.";
610         type string;
611       }
612
613       leaf description {
614         description "Description of the VNFFGD.";
615         type string;
616       }
617
618       leaf version {
619         description "Version of the VNFFGD";
620         type string;
621       }
622
623       list rsp {
624         description
625             "List of Rendered Service Paths (RSP).";
626
627         key "id";
628
629         leaf id {
630           description
631               "Identifier for the RSP.";
632           type string;
633         }
634
635         leaf name {
636           description
637               "RSP name.";
638           type string;
639         }
640
641         list vnfd-connection-point-ref {
642           description
643                 "A list of references to connection points.";
644           key "member-vnf-index-ref";
645
646           leaf member-vnf-index-ref {
647             description "Reference to member-vnf within constituent-vnfds";
648             type leafref {
649               path "../../../../constituent-vnfd/member-vnf-index";
650             }
651           }
652
653           leaf order {
654             type uint8;
655             description
656                 "A number that denotes the order of a VNF in a chain";
657           }
658
659            leaf vnfd-id-ref {
660              description
661                  "A reference to a vnfd. This is a
662                   leafref to path:
663                       ../../../../nsd:constituent-vnfd
664                       + [nsd:id = current()/../nsd:id-ref]
665                       + /nsd:vnfd-id-ref
666                   NOTE: An issue with confd is preventing the
667                   use of xpath. Seems to be an issue with leafref
668                   to leafref, whose target is in a different module.
669                   Once that is resovled this will switched to use
670                   leafref";
671              type string;
672            }
673
674            leaf vnfd-connection-point-ref {
675              description
676                  "A reference to a connection point name
677                   in a vnfd. This is a leafref to path:
678                       /vnfd:vnfd-catalog/vnfd:vnfd
679                       + [vnfd:id = current()/../nsd:vnfd-id-ref]
680                       + /vnfd:connection-point/vnfd:name
681                   NOTE: An issue with confd is preventing the
682                   use of xpath. Seems to be an issue with leafref
683                   to leafref, whose target is in a different module.
684                   Once that is resovled this will switched to use
685                   leafref";
686               type string;
687           }
688         }
689       } //rsp
690
691       list classifier {
692         description
693             "List of classifier rules.";
694
695         key "id";
696
697         leaf id {
698           description
699               "Identifier for the classifier rule.";
700           type string;
701         }
702
703         leaf name {
704           description
705               "Name of the classifier.";
706           type string;
707         }
708
709         leaf rsp-id-ref {
710           description
711               "A reference to the RSP.";
712           type leafref {
713             path "../../rsp/id";
714           }
715         }
716
717         leaf member-vnf-index-ref {
718           description "Reference to member-vnf within constituent-vnfds";
719           type leafref {
720             path "../../../constituent-vnfd/member-vnf-index";
721           }
722         }
723
724         leaf vnfd-id-ref {
725           description
726               "A reference to a vnfd. This is a
727                   leafref to path:
728                       ../../../nsd:constituent-vnfd
729                       + [nsd:id = current()/../nsd:id-ref]
730                       + /nsd:vnfd-id-ref
731                   NOTE: An issue with confd is preventing the
732                   use of xpath. Seems to be an issue with leafref
733                   to leafref, whose target is in a different module.
734                   Once that is resovled this will switched to use
735                   leafref";
736           type string;
737         }
738
739         leaf vnfd-connection-point-ref {
740           description
741               "A reference to a connection point name
742                   in a vnfd. This is a leafref to path:
743                       /vnfd:vnfd-catalog/vnfd:vnfd
744                       + [vnfd:id = current()/../nsd:vnfd-id-ref]
745                       + /vnfd:connection-point/vnfd:name
746                   NOTE: An issue with confd is preventing the
747                   use of xpath. Seems to be an issue with leafref
748                   to leafref, whose target is in a different module.
749                   Once that is resovled this will switched to use
750                   leafref";
751           type string;
752         }
753
754         list match-attributes {
755           description
756               "List of match attributes.";
757
758           key "id";
759
760           leaf id {
761             description
762                 "Identifier for the classifier match attribute rule.";
763             type string;
764           }
765
766           leaf ip-proto {
767             description
768                 "IP Protocol.";
769             type uint8;
770           }
771
772           leaf source-ip-address {
773             description
774                 "Source IP address.";
775             type inet:ip-address;
776           }
777
778           leaf destination-ip-address {
779             description
780                 "Destination IP address.";
781             type inet:ip-address;
782           }
783
784           leaf source-port {
785             description
786                 "Source port number.";
787             type inet:port-number;
788           }
789
790           leaf destination-port {
791             description
792                 "Destination port number.";
793             type inet:port-number;
794           }
795           //TODO: Add more match criteria
796         } //match-attributes
797       } // classifier
798     } // vnffgd
799
800     list monitoring-param {
801       description
802         "List of monitoring parameters from VNF's that should be
803         propogated up into NSR";
804       key "id";
805
806       leaf id {
807         type string;
808       }
809
810       leaf name {
811         type string;
812       }
813
814       uses manotypes:monitoring-param-value;
815       uses manotypes:monitoring-param-ui-data;
816       uses manotypes:monitoring-param-aggregation;
817
818       list vnfd-monitoring-param {
819         description "A list of VNFD monitoring params";
820         key "vnfd-id-ref vnfd-monitoring-param-ref";
821
822         leaf vnfd-id-ref {
823           description
824              "A reference to a vnfd. This is a
825               leafref to path:
826                   ../../../../nsd:constituent-vnfd
827                   + [nsd:id = current()/../nsd:id-ref]
828                   + /nsd:vnfd-id-ref
829               NOTE: An issue with confd is preventing the
830               use of xpath. Seems to be an issue with leafref
831               to leafref, whose target is in a different module.
832               Once that is resolved this will switched to use
833               leafref";
834
835           type yang:uuid;
836         }
837
838         leaf vnfd-monitoring-param-ref {
839           description "A reference to the VNFD monitoring param";
840           type leafref {
841             path "/vnfd:vnfd-catalog/vnfd:vnfd"
842               + "[vnfd:id = current()/../vnfd-id-ref]"
843               + "/vnfd:monitoring-param/vnfd:id";
844           }
845         }
846
847         leaf-list member-vnf-index-ref {
848          description
849             "Optional reference to member-vnf within constituent-vnfds";
850          type uint64;
851         }
852       }
853     }
854
855     uses manotypes:input-parameter-xpath;
856
857     list parameter-pool {
858       description
859         "Pool of parameter values which must be
860          pulled from during configuration";
861       key "name";
862
863       leaf name {
864         description
865             "Name of the configuration value pool";
866         type string;
867       }
868
869       container range {
870         description
871             "Create a range of values to populate the pool with";
872
873         leaf start-value {
874           description
875               "Generated pool values start at this value";
876           type uint32;
877           mandatory true;
878         }
879
880         leaf end-value {
881           description
882               "Generated pool values stop at this value";
883           type uint32;
884           mandatory true;
885         }
886       }
887     }
888
889     uses manotypes:ns-service-primitive;
890
891     list initial-config-primitive {
892       rwpb:msg-new NsdInitialConfigPrimitive;
893       description
894         "Initial set of configuration primitives for NSD.";
895       key "seq";
896
897       uses ns-initial-config-primitive;
898     }
899
900     list key-pair {
901       key "name";
902       description "Used to configure the list of public keys to be injected as part
903           of ns instantiation";
904
905       leaf name {
906         description "Name of this key pair";
907         type string;
908       }
909
910       leaf key {
911         description "Key associated with this key pair";
912         type string;
913       }
914     }
915
916     list user {
917       key "name";
918       description "List of users to be added through cloud-config";
919
920       leaf name {
921         description "Name of the user ";
922         type string;
923       }
924
925       leaf user-info {
926         description "The user name's real name";
927         type string;
928       }
929
930       list key-pair {
931         key "name";
932         description "Used to configure the list of public keys to be injected as part
933             of ns instantiation";
934
935         leaf name {
936           description "Name of this key pair";
937           type string;
938         }
939
940         leaf key {
941           description "Key associated with this key pair";
942           type string;
943         }
944       }
945     }
946   }
947
948
949   container nsd-catalog {
950
951     list nsd {
952       key "id";
953
954       uses nsd-descriptor;
955     }
956   }
957
958 }