Requirement:
As an ONAP developer, I need to support policy_type_impl as an entity in Policy Framework.
Currently only APEX-PDP is using policy_type_impl in Policy framework, but other PDPs could use it too.
The policy_type_impl itself is contained within the ToscaPolicy in case of APEX.
The intention of this Jira is to decouple the policy_type_impl from ToscaPolicy definition itself.
policy_type_impl could be stored in a database say with a name and version, and then in the ToscaPolicy,
only this name and version need to be specified instead of the whole policy_type_impl content.
Current approach:
Existing Policy Tosca:
Code Block | ||
---|---|---|
| ||
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "operational.apex.decisionMaker": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "derived_from": "tosca.policies.Root", "name": "operational.apex.decisionMaker", "version": "1.0.0", "properties": { "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561, "policy_type_impl": { .... .... } } } } } ] } } |
Proposed solution:
The existing structure of Tosca policy template is preserved and works as it is today. Additionally the following support will also be included.
- The policy_type_impl entity can be inferred as a metadataSet required for the policy engine.
- The metadataSets can be represented as node_templates in the Tosca mapped to a specific node type. It can be independently stored and retrieved from the db
- The metadataSet can also be passed as a referenceId in policy definition under metadata field.
- Rest endpoints will be introduced in the policy api to for metadataSet CRUD in to the database.
- PAP checks for the metadataSet reference in tosca policy.
- PAP fetches the corresponding metadataSet definition from the db if required before passing on the ToscaPolicy to the Pdps.
The following cases are proposed to be supported in Jakarta supporting the backward compatibility of Istanbul:
In policy tosca , "metadataSet reference" (or) "metadataSet" or neither can be provided, providing both together is an error.
Case 1
Reference provided only
API→PAP
Code Block | ||
---|---|---|
| ||
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "operational.apex.decisionMaker": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "derived_from": "tosca.policies.Root", "name": "operational.apex.decisionMaker", "version": "1.0.0", "metadata": { "metadataSetName": "apexMetadata_decisionMaker", "metadataSetVersion": 1.0.0" }, "properties": { "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561 } } } } ] } } |
PAP->PDP
Code Block |
---|
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "operational.apex.decisionMaker": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "derived_from": "tosca.policies.Root", "name": "operational.apex.decisionMaker", "version": "1.0.0", "metadata" : { "metadataSetName": "apexMetadata_decisionMaker", "metadataSetVersion": 1.0.0", "metadata": "The rule set read from the DB" }, "properties": { "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561 } } } } ] } } |
Case 2
Rule set provided in Policy
API-> PAP
Code Block | ||
---|---|---|
| ||
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "operational.apex.decisionMaker": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "derived_from": "tosca.policies.Root", "name": "operational.apex.decisionMaker", "version": "1.0.0", "metadata": { "metadataSet": "My Rule Set for some PDP" }, "properties": { "policy_type_impl": "My Rule Set for some PDP", "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561 } } } } ] } } |
PAP->PDP just forward same policy, no DB lookup
Case 3: APEX Backward Compatibility
API → PAP
Code Block |
---|
{ "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { "operational.apex.decisionMaker": { "type": "onap.policies.native.Apex", "type_version": "1.0.0", "derived_from": "tosca.policies.Root", "name": "operational.apex.decisionMaker", "version": "1.0.0", "properties": { "engineServiceParameters": { "name": "MyApexEngine", "version": "0.0.1", "id": 45, "instanceCount": 4, "deploymentPort": 12561, "policy_type_impl": { } } } } } ] } } |
PAP->PDP just forward same policy, no DB lookup
For APEX, if the metadataSet is not in the engine service parameters and is in the policy metadata, just copy
it from the metadata and forward to the APEX core.
Yaml representation of sample metadataSets that can be persisted to db:
View file | ||||
---|---|---|---|---|
|
The 'metadataSet' entity is represented as a node template in Tosca mapped to a specific node type under the topology template: The following parameters are specified in tosca under the node templates:
parameters | Type | Description |
---|---|---|
<metadataSetName> | String (key) | The name of the metadataSet |
version | String (key) | The version of the metadataSet |
type | String | Node type |
type_version | String | Node type version |
description | String | Description of the metadataSet |
metadata | Map | A map of <String object> that contains the policy Metadata |