Policy OOF HPA¶
Contents
Background¶
The OOF(ONAP Optimization Framework) 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 uploaded module. Below is an example using HPA (Hardware Platform Awareness).
Updating Policy Models¶
The following HPA TOSCA policy models need to be uploaded as a dictionary during the deployment-time of an optimization application. Currently, the model uploading process is manual since the policy system does not offer an interface to upload models programmatical. 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.
1 tosca_definitions_version: tosca_simple_yaml_1_0_0
2 node_types:
3 policy.nodes.hpaPolicy:
4 derived_from: policy.nodes.Root
5 properties:
6 policyScope:
7 type: list
8 description: scope where the policy is applicable
9 required: true
10 matchable: true
11 entry_schema:
12 type: string
13 policyType:
14 type: list
15 description: type of a policy
16 required: true
17 matchable: true
18 entry_schema:
19 type: string
20 consraints:
21 - valid_values:
22 - hpaPolicy
23 resource:
24 type: string
25 required: true
26 identity:
27 type: string
28 required: true
29 flavorFeatures:
30 type: list
31 required: true
32 entry_schema:
33 - type: policy.data.flavorFeatures_properties
34 data_types:
35 policy.data.flavorFeatures_properties:
36 derived_from: tosca.nodes.Root
37 properties:
38 flavorLabel:
39 type: string
40 required: true
41 flavorProperties:
42 type: list
43 required: true
44 entry_schema:
45 - type: policy.data.flavorProperties_properties
46 policy.data.flavorProperties_properties:
47 derived_from: tosca.nodes.Root
48 properties:
49 hpa-feature:
50 type: string
51 required: true
52 mandatory:
53 type: string
54 required: true
55 score:
56 type: string
57 required: true
58 architecture:
59 type: string
60 required: true
61 hpa-version:
62 type: string
63 required: true
64 hpa-feature-attributes:
65 type: list
66 required: true
67 entry_schema:
68 - type: policy.data.hpa-feature-attributes_properties
69 policy.data.hpa-feature-attributes_properties:
70 derived_from: tosca.nodes.Root
71 properties:
72 hpa-attribute-key:
73 type: string
74 required: true
75 hpa-attribute-value:
76 type: string
77 required: true
78 operator:
79 type: list
80 required: true
81 entry_schema:
82 type: string
83 constraints:
84 - valid_values:
85 - '<'
86 - '<='
87 - '>'
88 - '>='
89 - '='
90 - '!='
91 - 'any'
92 - 'all'
93 - 'subset'
94 unit:
95 type: string
96 required: true
The POLICY Dictionary tab is used to create and manage attributes in the dictionaries.
Access to the POLICY GUI via the ONAP Portal. Select Dictionary on the left side.
Select Policy Type Dictionary. you need choose the Optimization Policy.
Select Dictionary. you need Select ONAP Optimization Models.
Click Import Dictionary’s button, upload the HPA Policy file.
The image below shows an example of an uploaded policy.
Creating HPA Policies¶
There are two options for creating policies: (1) through the GUI and (2) through the restful API.
GUI Method¶
From the POLICY GUI:
Select editor, right click a scope and choose create policy
Choose Config under Policy Type
Choose Optimization under Optimization
Enter all required fields I for common Config Policy Type:
Policy Name
Onap Name - Name of the source of the requests
Guard
Risk Type
Risk Level
Priority
Optimization Model: choose hpaPolicy
Optimization Model Version: CSIT
Enter all required fields II about specified Optimization Config Policy Type:
Click validate, then save
Below is an example of a policy that uses the HPA feature: hpaPolicy_vGmuxInfra.
API Method¶
To create the policy, use the PUT /createPolicy API. The request should be in the following form for the Optimization policy:
1 {
2 "service": "hpaPolicy",
3 "policyName": "hpaPolicy_vGMuxInfra",
4 "description": "HPA policy for vGMuxInfra",
5 "templateVersion": "0.0.1",
6 "version": "1.0",
7 "priority": "3",
8 "riskType": "SampleRiskType",
9 "riskLevel": "2",
10 "guard": "False",
11 "Optimization Model" : "hpaPolicy",
12 "Optimization Model Version": "CSIT",
13 "content": {
14 "resources": "vGMuxInfra",
15 "identity": "hpaPolicy_vGMuxInfra",
16 "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra"],
17 "policyType": "hpaPolicy",
18 "flavorFeatures": [
19 {
20 "flavorLabel": "flavor_label_vm_01",
21 "flavorProperties":[
22 {
23 "hpa-feature" : "cpuTopology",
24 "mandatory" : "True",
25 "architecture": "generic",
26 "score": 3,
27 "hpa-feature-attributes": [
28 {"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "2","operator": ">=", "unit": ""}
29 ]
30 }
31 ]
32 }
33 ]
34 }
35 }
Push Policy¶
Use the Push tab to push the policy and make it active on the pdp-x.
From the web, select Push tab
Select the polices
Select the PDP
Click the Push Polices button
A message will be displayed indicatng a successful push.
Semantics of Policy attributes¶
"hpa-feature-attributes": [
{
"hpa-attribute-key": "{attribute name}",
"hpa-attribute-value": "{attribute value}",
"operator": "{comparison operator}",
"unit": "{the unit of an attribute}"
}
]
# An Example
"hpa-feature-attributes": [
{"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "2","operator": ">=", "unit": ""},
{"hpa-attribute-key":"numCpuSockets", "hpa-attribute-value": "4","operator": "<=", "unit": ""},
{"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "2", "operator":">=", "unit": ""},
{"hpa-attribute-key":"numCpuCores", "hpa-attribute-value": "4", "operator":"<=", "unit": ""},
{"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "4", "operator":">=", "unit": ""},
{"hpa-attribute-key":"numCpuThreads", "hpa-attribute-value": "8", "operator":"<=", "unit": ""}
]
End of Document