Documentation OOF Spec
[policy/engine.git] / docs / platform / oofSpec.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 ******************************************
5 Policy Specification and Retrieval for OOF
6 ******************************************
7
8 .. contents::
9     :depth: 2
10
11 Introduction
12 ^^^^^^^^^^^^
13
14 The OOF retrieves applicable constraints and objective functions as policies from the policy platform. These policies are retrieved at runtime, thus allowing an operator to change policies as and when needed. These policies are specified using policy models that are on-boarded during the OOF application deployment-time in the policy platform. The OOF-related policy models are typically derived from the constraints and objective functions of an OOF-application. Currently, for R2, these models will be pushed into the policy platform manually using the OOF policy uploader module.
15
16 Policy Platform
17 ^^^^^^^^^^^^^^^
18
19 The OOF currently relies on the following features of the policy platform: 
20
21 * **Policy specification:** Optimization constraints and objective functions can be specified in terms of policies by service providers and operators.
22 * **Policy prioritization:** Policies capturing constraints and objectives can be prioritized.
23 * **Policy searching and filtering:** OOF policies can be searched and filtered based on different criteria; by scope or by name patterns
24
25 OOF-HAS Service Design Policies
26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27
28 Service design policies are typically defined as a part of a service design model and evaluated/enforced prior to the service instantiation phase. For example, Hardware Platform Enablement (HPA) policies are defined in an SDC service model and evaluated/enforced during the homing optimization process in ONAP. 
29
30 The HPA requirements are captured in a VNF descriptor provided by a vendor. During the service-design phase, these requirements are extracted out from the VNF descriptor and captured in a service model. Some of the HPA requirements cannot be changed during the lifecycle of a service; while other optional requirements can be changed by a service designer or operator over time (e.g. the use of SR-IOV may be preferred by an operator if the SR-IOV capability is optionally provided by a vendor). Once a service model is designed and uploaded into the SDC repository, SDC notifies the policy service about the distribution of a new service model. The policy service then fetches the service model and extracts out the HPA requirements through model decomposition. Next, the policy service creates HPA policies for the homing service (OOF-HAS) by populating the HPA requirements in policy models provided by OOF, and stores the policies in a repository. When the homing service receives a homing request from SO, the homing service asks for the associated HPA policies from the policy platform. Finally, the homing service finds homing solutions based on the evaluation of the received HPA policies and returns the solutions to SO.
31
32 Note that all HPA requirements for a given VM can be put in one policy or across different policies. Also, each HPA capability can be enhanced to include mandatory and score attributes. Keeping this in mind, HPA capabilities are defined here. As indicated, policy can have multiple capabilities.
33
34
35 .. code-block:: bash
36    :caption: Template for the HPA policies
37    :linenos:
38
39     {
40         "service": "{the model name of a policy}",
41         "policyName": "{policy scope folder}.{policy name; must be unique}",
42         "description": "{description of a policy}",
43         "templateVersion": "{policy model version}",
44         "version": "{policy version}",
45         "priority": "{priority in 1-10; larger the number higher the priority is}",
46         "riskType": "{the type of risk}",
47         "riskLevel": "{the level of risk}",
48         "guard": "{True/False flag to indicate whether guard is applicable or not}",
49         "content": { 
50           "resource": "{resource name}",
51           "identity": "{policy identity}",
52           "policyScope": ["{a tag representing policy scope}"],
53           "policyType": "{policy type}",
54           "flavorFeatures": [
55             {
56               "flavorLabel": "{VM/VFC id}",
57               "flavorProperties":[
58                 {
59                   "hpa-feature" : "{HPA feature type}",
60                   "mandatory" : "{mandatoriness of the feature}",
61                   "score" : "{priority of this feature if the feature is not mandatory for VM}"
62                   "architecture": "{supported architecuture}",
63                   "hpa-version": "{version for hpa capability}",
64                   "hpa-feature-attributes": [
65                     {
66                       "hpa-attribute-key": "{attribute name}", 
67                       "hpa-attribute-value": "{attribute value}",
68                       "operator": "{comparison operator}", 
69                       "unit": "{the unit of an attribute}"}
70                   ]
71                 }
72               ] 
73             }
74           ]
75         }
76     }
77
78
79 .. code-block:: bash
80    :caption: HPA Policy Example
81    :linenos:
82     
83     # NOTE:
84     #
85     # The fields in this example policy are typically generated from a TOSCA service model specified by VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
86     #
87     # CPUTHREADPOLICY = prefer, isolate, require
88     # CPUPOLICY = shared, dedicated
89     # PCIETYPEVALUE: SRIOV, PCI-PASSTHROUGH
90     # CPUINST = aes, avx, sha_ni, mpx, adcx, mpx, pclmulqdq, rdrand,sse, etc
91     # MEMORYPAGESIZE = 4KB (unit=KB), 2MB (unit=MB), 1GB(unit=GB), ANY, Other explicit Page size
92
93     {
94         "service": "hpaPolicy",
95         "policyName": "oofBeijing.hpaPolicy_vGMuxInfra",
96         "description": "HPA policy for vGMuxInfra",
97         "templateVersion": "0.0.1",
98         "version": "1.0",
99         "priority": "3",
100         "riskType": "test",
101         "riskLevel": "2",
102         "guard": "False",
103         "content": { 
104           "resources": "vGMuxInfra",
105           "identity": "hpaPolicy_vGMuxInfra",
106           "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
107           "policyType": "hpaPolicy",
108           "flavorFeatures": [
109             {
110               "flavorLabel": "flavor_label_vm_01",
111               "flavorProperties":[
112                 {
113                   "hpa-feature" : "cpuTopology",
114                   "mandatory" : "True",
115                   "architecture": "generic",
116                   "hpa-version": "v1",
117                   "hpa-feature-attributes": [
118                     {"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "2","operator": ">=", "unit": ""},
119                     {"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "4","operator": "<=", "unit": ""},
120                     {"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "2", "operator":">=", "unit": ""},
121                     {"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "4", "operator":"<=", "unit": ""},
122                     {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "4", "operator":">=", "unit": ""},
123                     {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "8", "operator":"<=", "unit": ""}
124                   ]
125                 },
126                 {
127                   "hpa-feature" : "basicCapabilities",
128                   "mandatory" : "True",
129                   "architecture": "generic",
130                   "hpa-version": "v1",
131                   "hpa-feature-attributes": [
132                     {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
133                     {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
134                   ]
135                 },
136                 {
137                   "hpa-feature" : "ovsDpdk",
138                   "mandatory" : "False",
139                   "score" : "3",
140                   "architecture": "generic",
141                   "hpa-version": "v1",
142                   "hpa-feature-attributes": [
143                      {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""}
144                   ]
145                 },
146                 {
147                   "hpa-feature" : "cpuInstructionSetExtensions",
148                   "mandatory" : "True",
149                   "architecture": "INTEL-64",
150                   "hpa-version": "v1",
151                   "hpa-feature-attributes": [
152                     {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"] "operator": "ALL", "unit":""}
153                   ]
154                 }
155               ] 
156             },
157             {
158               "flavorLabel": "flavor_label_vm_02",
159               "flavorProperties":[
160                 {
161                   "hpa-feature" : "cpuPinningy",
162                   "mandatory" : "True",
163                   "architecture": "generic",
164                   "hpa-version": "v1",
165                   "hpa-feature-attributes": [
166                     {"hpa-attribute-key":"logicalCpuThreadPinningPolicy", "hpa-attribute-value":"<CPUTHREADPOLICY>", "operator": "=", "unit":""},
167                     {"hpa-attribute-key":"logicalCpuPinningPolicy", "hpa-attribute-value": "<CPUPOLICY>","operator": "=", "unit":""},
168                   ]
169                 },
170                 {
171                   "hpa-feature" : "basicCapabilities",
172                   "mandatory" : "True",
173                   "architecture": "generic",
174                   "hpa-version": "v1",
175                   "hpa-feature-attributes": [
176                     {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
177                     {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
178                   ]
179                 },
180                 {
181                   "hpa-feature" : "localStorage",
182                   "mandatory" : "False",
183                   "score" : "5",
184                   "architecture": "generic",
185                   "hpa-version": "v1",
186                   "hpa-feature-attributes": [
187                     {"hpa-attribute-key": "diskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},   
188                     {"hpa-attribute-key": "ephemeralDiskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},
189                     {"hpa-attribute-key": "swapMemSize", "hpa-attribute-value":"16", "operator": "=", "unit": "MB"},
190                   ]
191                 },
192                 {
193                   "hpa-feature" : "pcie",
194                   "mandatory" : "True",
195                   "architecture": "generic",
196                   "hpa-version": "v1",
197                   "hpa-feature-attributes": [
198                     {"hpa-attribute-key": "pciCount", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
199                     {"hpa-attribute-key": "pciVendorId", "hpa-attribute-value":"8086", "operator": "=", "unit": ""},
200                     {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""} 
201                     {"hpa-attribute-key": "functionType", "hpa-attribute-value": "<PCITYPEVALUE>","operator": "=", "unit": ""} 
202                   ]
203                 }
204               ] 
205             },
206             {
207               "flavorLabel": "flavor_label_vm_03",
208               "flavorProperties":[
209                 {
210                   "hpa-feature" : "numa",
211                   "mandatory" : "False",
212                   "score" : "5",
213                   "architecture": "generic",
214                   "hpa-version": "v1",
215                   "hpa-feature-attributes": [
216                     {"hpa-attribute-key": "numaNodes", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
217                     {"hpa-attribute-key": "numaCpu-0", "hpa-attribute-value":"2", "operator": "=", "unit": ""},
218                     {"hpa-attribute-key": "numaMem-0", "hpa-attribute-value": "2048", "operator": "=", "unit": "MB"}
219                     {"hpa-attribute-key": "numaCpu-1", "hpa-attribute-value":"4", "operator": "=", "unit": ""},
220                     {"hpa-attribute-key": "numaMem-1", "value": "4096", "operator": "=", "unit": "MB"}
221                   ]
222                 },
223                 {
224                   "hpa-feature" : "basicCapabilities",
225                   "mandatory" : "True",
226                   "architecture": "generic",
227                   "hpa-version": "v1",
228                   "hpa-feature-attributes": [
229                     {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
230                     {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
231                   ]
232                 },
233                 {
234                   "hpa-feature" : "hugePages",
235                   "mandatory" : "False",
236                   "score" : "7",
237                   "architecture": "generic",
238                   "hpa-version": "v1",
239                   "hpa-feature-attributes": [
240                      {"hpa-attribute-key": "memoryPageSize", "hpa-attribute-value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""}
241                   ]
242                 }
243               ] 
244             }
245           ]
246         }
247     }
248     
249
250 .. code-block:: bash
251    :caption: Distance Policy Example
252    :linenos:
253         
254     # NOTE:
255     #
256     # The fields in this example policy are typically generated from a TOSCA service model specified by VNF vendors 
257     # or service designers. However, the policy can be updated over time by operators.
258
259     {
260       "service": "distancePolicy",
261       "policyName": "oofBeijing.distancePolicy_vGMuxInfra",
262       "description": "Distance Policy for vGMuxInfra",
263       "templateVersion": "0.0.1",
264       "version": "oofBeijing",
265       "priority": "3",
266       "riskType": "test",
267       "riskLevel": "2",
268       "guard": "False",
269       "content": {
270         "distanceProperties": {
271           "locationInfo": customer_location",
272           "distance": { "value": "500", "operator": "<", "unit": "km" }
273         },
274         "resources": ["vGMuxInfra", "vG"],
275         "applicableResources": "any",
276         "identity": "distance-vGMuxInfra",
277         "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
278         "policyType": "distancePolicy"
279       }
280     }
281     
282
283 .. code-block:: bash
284    :caption: HPA Basic Capabilities Policy Example
285    :linenos:
286             
287     # NOTE:
288     #
289     # The fields in this example policy are typically generated from a TOSCA service model specified by 
290     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
291
292     {
293         "hpa-feature" : "basicCapabilities",
294         "mandatory" : "False",
295         "score" : "5",
296         "architecture": "generic",
297         "hpa-version": "v1",
298         "hpa-feature-attributes": [
299            {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
300            {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
301         ]
302     }
303     
304
305 .. code-block:: bash
306    :caption: HPA OVS DPDK Policy Example
307    :linenos:
308     
309     # NOTE:
310     #
311     # The fields in this example policy are typically generated from a TOSCA service model specified by 
312     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
313     #
314     # For this policy others architectures are also applicable.
315
316     {
317         "hpa-feature" : "ovsDpdk",
318         "mandatory" : "False",
319         "score" : "5",
320         "architecture": "INTEL-64",
321         "hpa-version": "v1",
322         "hpa-feature-attributes": [
323           {"hpa-attribute-key":"dataProcessingAccelerationLibrary", "hpa-attribute-value":"ovsDpdk_version", "operator": "=", "unit":""}
324          ]
325     }
326     
327
328 .. code-block:: bash
329    :caption: HPA CPU Pinning Policy Example
330    :linenos:
331         
332     # NOTE:
333     #
334     # The fields in this example policy are typically generated from a TOSCA service model specified by 
335     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
336
337     {
338        "hpa-feature" : "cpuPinning",
339        "mandatory" : "False",
340        "score" : "5",
341        "architecture": "generic",
342        "hpa-version": "v1",
343        "hpa-feature-attributes": [
344          {"hpa-attribute-key":"logicalCpuThreadPinningPolicy", "hpa-attribute-value":"<CPUTHREADPOLICY>", "operator": "=", "unit":""},
345          {"hpa-attribute-key":"logicalCpuPinningPolicy", "hpa-attribute-value": "<CPUPOLICY>","operator": "=", "unit":""},
346         ]
347     }
348     
349
350 .. code-block:: bash
351    :caption: HPA NUMA Policy Example
352    :linenos:
353             
354     # NOTE:
355     #
356     # The fields in this example policy are typically generated from a TOSCA service model specified by 
357     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
358
359     {
360         "hpa-feature" : "numa",
361         "mandatory" : "False",
362         "score" : "5",
363         "architecture": "generic",
364         "hpa-version": "v1",
365         "hpa-feature-attributes": [
366            {"hpa-attribute-key": "numaNodes", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
367            {"hpa-attribute-key": "numaCpu-0", "hpa-attribute-value":"2", "operator": "=", "unit": ""},
368            {"hpa-attribute-key": "numaMem-0", "hpa-attribute-value": "2048", "operator": "=", "unit": "MB"},
369            {"hpa-attribute-key": "numaCpu-1", "hpa-attribute-value":"4", "operator": "=", "unit": ""},
370            {"hpa-attribute-key": "numaMem-1", "hpa-attribute-value": "4096", "operator": "=", "unit": "MB"}
371         ]
372     }
373     
374
375 .. code-block:: bash
376    :caption: HPA CPU Topology Policy Example
377    :linenos:
378     
379     # NOTE:
380     #
381     # The fields in this example policy are typically generated from a TOSCA service model specified by 
382     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
383
384     {
385        "hpa-feature" : "cpuTopology",
386        "mandatory" : "False",
387        "score" : "5",
388        "architecture": "generic",
389        "hpa-version": "v1",
390        "hpa-feature-attributes": [
391           {"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "2","operator": ">=", "unit": ""},
392           {"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "4","operator": "<=", "unit": ""},
393           {"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "2", "operator":">=", "unit": ""},
394           {"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "4", "operator":"<=", "unit": ""},
395           {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "4", "operator":">=", "unit": ""},
396           {"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "8", "operator":"<=", "unit": ""}
397        ]
398     }
399     
400
401 .. code-block:: bash
402    :caption: Affinity Policy Example
403    :linenos:
404         
405     # NOTE:
406     #
407     # The fields in this example policy are typically generated from a TOSCA service model specified by 
408     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
409
410     {
411         "service": "affinityPolicy",
412         "policyName": "oofBeijing.affinityPolicy_vcpe",
413         "description": "Affinity policy for vCPE",
414         "templateVersion": "1702.03",
415         "version": "oofBeijing",
416         "priority": "5",
417         "riskType": "test",
418         "riskLevel": "2",
419         "guard": "False",
420         "content": {
421             "identity": "affinity_vCPE",
422             "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
423             "affinityProperties": {
424                 "qualifier": "different",
425                 "category": "complex"
426             },
427             "policyType": "affinityPolicy",
428             "resources": ["vGMuxInfra", "vG"],
429             "applicableResources": "all"
430         }
431     }
432     
433
434 .. code-block:: bash
435    :caption: Capacity Policy Example
436    :linenos:
437             
438     # NOTE:
439     #
440     # The fields in this example policy are typically generated from a TOSCA service model specified by 
441     # VNF vendors or service designers. This policy cannot be changed during the life-cycle of a service.
442
443     {
444         "service": "capacityPolicy",
445         "policyName": "oofBeijing.capacityPolicy_vGMuxInfra",
446         "description": "Capacity policy for vGMuxInfra",
447         "templateVersion": "1702.03",
448         "version": "oofBeijing",
449         "priority": "5",
450         "riskType": "test",
451         "riskLevel": "2",
452         "guard": "False",
453         "content": {
454             "identity": "capacity_vGMuxInfra",
455             "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
456             "controller": "multicloud",
457             "capacityProperties": {
458                 "cpu": {"value": 2, "operator": ">"},
459                 "memory": {"value": 4, "operator": ">", "unit": "GB"}
460                 "storage": {"value": 80, "operator": ">", "unit": "GB"}
461             },
462             "policyType": "vim_fit",
463             "resources": ["vGMuxInfra"],
464             "applicableResources": "any"
465         }
466     }
467     
468
469 .. code-block:: bash
470    :caption: Min Guarantee Policy Example
471    :linenos:
472                 
473     # NOTE:
474     #
475     # The fields in this example policy are typically generated from a TOSCA service model specified by 
476     # VNF vendors or service designers.  This policy cannot be changed during the life-cycle of a service. 
477     # A min-guarantee policy can be specified using the HPA policy model.
478
479     {
480         "service": "minGuaranteePolicy",
481         "policyName": "oofBeijing.minGuaranee_vGMuxInfra",
482         "description": "Min guarantee policy for vGMuxInfra",
483         "templateVersion": "1702.03",
484         "version": "oofBeijing",
485         "priority": "5",
486         "riskType": "test",
487         "riskLevel": "2",
488         "guard": "False",
489         "content": {
490             "identity": "minGuarantee_vGMuxInfra",
491             "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
492             "minGuaranteeProperty": {
493                 "cpu": "true",
494                 "memory": "false",
495             },
496             "type": "minGuaranteePolicy",
497             "resources": ["vGMuxInfra"],
498             "applicableResources": "any"
499         }
500     }
501     
502
503 .. code-block:: bash
504    :caption: Optimization Policy Example
505    :linenos:
506                 
507     # NOTE:
508     #
509     # The fields in this example policy are typically generated from a TOSCA service model specified by 
510     # VNF vendors or service designers.  This policy cannot be changed during the life-cycle of a service. 
511                     
512     {
513         "service": "PlacementOptimizationPolicy",
514         "policyName": "oofBeijing.PlacementOptimizationPolicy_vGMuxInfra",
515         "description": "Placement Optimization Policy for vGMuxInfra",
516         "templateVersion": "1702.03",
517         "version": "oofBeijing",
518         "priority": "5",
519         "riskType": "test",
520         "riskLevel": "3",
521         "guard": "False",
522         "content": {
523             "objectiveParameter": {
524                 "parameterAttributes": [
525                     {
526                         "resources": ["vGMuxInfra"],
527                         "customerLocationInfo": "customer_loc",
528                         "parameter": "distance",
529                         "weight": "1",
530                         "operator": "product"=
531                     },
532                     {
533                         "resources": ["vG"],
534                         "customerLocationInfo": "customer_loc",
535                         "parameter": "distance",
536                         "weight": "1",
537                         "operator": "product"
538                     }
539                 ],
540                 "operator": "sum"
541             },
542             "identity": "optimization",
543             "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
544             "policyType": "placementOptimization",
545             "objective": "minimize"
546         }
547     }
548
549
550 .. code-block:: bash
551    :caption: HPA PCIe Policy Example
552    :linenos:
553     
554     # NOTE:
555     #
556     # PCIETYPEVALUE: SRIOV, PCI-PASSTHROUGH
557
558     {
559         "hpa-feature" : "pcie",
560         "mandatory" : "False",
561         "score" : "5",
562         "architecture": "generic",
563         "hpa-version": "v1",
564         "hpa-feature-attributes": [
565           {"hpa-attribute-key": "pciCount", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
566           {"hpa-attribute-key": "pciVendorId", "hpa-attribute-value":"8086", "operator": "=", "unit": ""},
567           {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""} 
568           {"hpa-attribute-key": "functionType", "hpa-attribute-value": "<PCIETYPEVALUE>","operator": "=", "unit": ""} 
569          ]
570     }
571     
572
573 .. code-block:: bash
574    :caption: HPA Local Storage Policy Example
575    :linenos:
576                 
577     # NOTE:
578     #
579     # The fields in this example policy are typically generated from a TOSCA service model specified by 
580     # VNF vendors or service designers.  This policy cannot be changed during the life-cycle of a service. 
581
582     {
583         "hpa-feature" : "localStorage",
584         "mandatory" : "False",
585         "score" : "5",
586         "architecture": "generic",
587         "hpa-version": "v1",
588         "hpa-feature-attributes": [
589            {"hpa-attribute-key": "diskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},   
590            {"hpa-attribute-key": "ephemeralDiskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},
591            {"hpa-attribute-key": "swapMemSize", "hpa-attribute-value":"16", "operator": "=", "unit": "MB"},
592          ]
593     }
594     
595
596 .. code-block:: bash
597    :caption: HPA CPU Instruction Set Extensions Policy Example
598    :linenos:
599                 
600     # NOTE:
601     #
602     # instructionSetExtensions attribute has a list of all instruction set extensions required. 
603     # CPUINST = aes, avx, sha_ni, mpx, adcx, mpx, pclmulqdq, rdrand, sse, etc
604                     
605     {
606         "hpa-feature" : "cpuInstructionSetExtensions",
607         "mandatory" : "False",
608         "score" : "5",
609         "architecture": "INTEL-64",
610         "hpa-version": "v1",
611         "hpa-feature-attributes": [
612           {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"] "operator": "ALL", "unit":""}
613          ]
614     }
615     
616
617 .. code-block:: bash
618    :caption: HPA Huge Pages Policy Example
619    :linenos:
620                 
621     # NOTE:
622     #
623     # MEMORYPAGESIZE = 4KB (unit=KB), 2MB (unit=MB), 1GB(unit GB), ANY, Other explicit Page size
624                     
625     {
626         "hpa-feature" : "hugePages",
627         "mandatory" : "False",
628         "score" : "5",
629         "architecture": "generic",
630         "hpa-version": "v1",
631         "hpa-feature-attributes": [
632           {"hpa-attribute-key": "memoryPageSize", "hpa-attribute-value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""}
633         ]
634     }
635     
636
637 .. code-block:: bash
638    :caption: VNF Policy Example
639    :linenos:
640                 
641     # NOTE:
642     #
643     # VNF policy captures the location of inventories and customer information.
644                     
645     {
646         "service": "vnfPolicy",
647         "policyName": "oofBeijing.vnfPolicy_vGMuxInfra",
648         "description": "vnfPolicy",
649         "templateVersion": "1702.03",
650         "version": "oofBeijing",
651         "priority": "6",
652         "riskType": "test",
653         "riskLevel": "3",
654         "guard": "False",
655         "content": {
656             "identity": "vnf_vGMuxInfra",
657             "policyScope": ["vCPE", "INTERNATIONAL", "ip", "vGMuxInfra"],
658             "policyType": "vnf_policy",
659             "resources": ["vGMuxInfra"],
660             "applicableResources": "any",
661             "vnfProperties": [
662                 {
663                     "inventoryProvider": "aai",
664                     "serviceType": "",
665                     "inventoryType": "cloudRegionId",
666                     "customerId": ""
667                 },
668                 {
669                     "inventoryProvider": "multicloud",
670                     "serviceType": "HNGATEWAY",
671                     "inventoryType": "serviceInstanceId",
672                     "customerId": "21014aa2-526b-11e6-beb8-9e71128cae77"
673                 }
674             ]
675         }
676     }
677     
678
679 .. code-block:: bash
680    :caption: Subscriber Role Policy Example
681    :linenos:
682                 
683     # NOTE:
684     #
685     # Subscriber role policy to capture the role of a subscriber and related provisioning states.
686     
687     {
688      "service": "SubscriberPolicy",
689      "policyName": "oofBeijing.SubscriberPolicy_v1",
690      "description": "Subscriber Policy",
691      "templateVersion": "0.0.1",
692      "version": "oofBeijing",
693      "priority": "1",
694      "riskType": "test",
695      "riskLevel": "3",
696      "guard": "False",
697      "content": {
698             "identity": "subscriber",
699             "policyScope": ["vCPE", "subscriber_x", "subscriber_y"],
700             "properties": {
701                     "subscriberName": ["subscriber_x", "subscriber_y"],
702                     "subscriberRole": ["Test"],
703                     "provStatus": ["CAPPED"]
704             },
705             "policyType": "SubscriberPolicy"
706      }
707     }
708     
709
710 Modes for Fetching Policies
711 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
712
713 OOF can fetch optimzation policies using the getConfig API of the policy system. The policies can be searched and filtered in two different modes; by-name and by-scope from the policy system.
714
715 **By-name**: OOF can send an explicite policy name or a regular expression matching a set of policy names as a part of the getConfig API payload. In return, OOF expects to receive a specific policy or a set of policies with name matching to the regular expression.
716
717 **By-scope**: A scope is the domain to which a policy is applicable. Scope information can be captured as a set of attribute-value pairs, which can be sent as a part of the getConfig API payload. In response, the policy system is expected to return a set of policies with the matching attribute-value pairs. A policy can only be included in the response if all the matching attribute-value pairs exist.
718
719 OOF can requerst prioritization by enabling a prioritization flag in the getConfig API call to the policy system, and expects to receive a single policy with the highest priority policy among the set of policies meeting the search criteria.
720
721
722 TOSCA Policy Models
723 ^^^^^^^^^^^^^^^^^^^
724
725 The following TOSCA policy models need to be uploaded as a dictionary during the deployment-time of an optimization application. Currently, the model uploading porcess is manual since the policy system does not offer an interface to upload models programatically. Once the models are uploaded, policy templates are created in the policy portal/GUI using which optimization policies can be created. Alternatively, the policy system offers CRUD REST APIs using which the policies can be managed by the application.
726
727 * HPA Policy
728 * Affinity Policy
729 * Distance Policy
730 * Capacity Policy
731 * VNF Policy
732 * Optimization Policy
733 * Query Policy
734 * Subscriber Policy
735
736
737 End of Document
738
739 .. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Policy+Specification+and+Retrieval+for+OOF
740
741