-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP:
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- operational.restart:
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
+++ /dev/null
-{
- "policy-id" : "guard.frequency.scaleout",
- "policy-version" : "1",
- "content" : {
- "actor": "SO",
- "recipe": "VF Module Create",
- "targets": ".*",
- "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
- "limit": "1",
- "timeWindow": "10",
- "timeUnits": "minute",
- "guardActiveStart": "00:00:01-05:00",
- "guardActiveEnd": "23:59:59-05:00"
- }
-}
+++ /dev/null
-{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
- "topology_template": {
- "policies": [
- {
- "guard.frequency.scaleout": {
- "type": "onap.policies.controlloop.guard.FrequencyLimiter",
- "version": "1.0.0",
- "metadata": {
- "policy-id" : "guard.frequency.scaleout"
- },
- "properties": {
- "actor": "SO",
- "recipe": "VF Module Create",
- "targets": ".*",
- "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
- "limit": "1",
- "timeWindow": "10",
- "timeUnits": "minute",
- "guardActiveStart": "00:00:01-05:00",
- "guardActiveEnd": "23:59:59-05:00"
- }
- }
- }
- ]
- }
-}
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-topology_template:
- policies:
- -
- guard.frequency.scaleout:
- type: onap.policies.controlloop.guard.FrequencyLimiter
- version: 1.0.0
- metadata:
- policy-id : guard.frequency.scaleout
- properties:
- actor: SO
- recipe: VF Module Create
- targets: .*
- clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
- limit: 1
- timeWindow: 10
- timeUnits: minute
- guardActiveStart: 00:00:01-05:00
- guardActiveEnd: 23:59:59-05:00
+++ /dev/null
-{
- "guard.frequency.scaleout": {
- "type": "onap.policies.controlloop.guard.FrequencyLimiter",
- "version": "1.0.0",
- "metadata": {
- "policy-id": "guard.frequency.scaleout",
- "policy-version": 1
- },
- "properties": {
- "content": {
- "actor": "SO",
- "recipe": "VF Module Create",
- "targets": ".*",
- "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
- "limit": "1",
- "timeWindow": "10",
- "timeUnits": "minute",
- "guardActiveStart": "00:00:01-05:00",
- "guardActiveEnd": "23:59:59-05:00"
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-topology_template:
- policies:
- -
- guard.frequency.scaleout:
- type: onap.policies.controlloop.guard.FrequencyLimiter
- version: 1.0.0
- metadata:
- policy-id : guard.frequency.scaleout
- policy-version: 1
- properties:
- actor: SO
- recipe: VF Module Create
- targets: .*
- clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
- limit: 1
- timeWindow: 10
- timeUnits: minute
- guardActiveStart: 00:00:01-05:00
- guardActiveEnd: 23:59:59-05:00
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+topology_template:
+ policies:
+ -
+ guard.frequency.scaleout:
+ type: onap.policies.controlloop.guard.common.FrequencyLimiter
+ type_version: 1.0.0
+ version: 1.0.0
+ metadata:
+ policy-id : guard.frequency.scaleout
+ properties:
+ actor: SO
+ operation: VF Module Create
+ id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
+ timeWindow: 10
+ timeUnits: minute
+ limit: 1
\ No newline at end of file
+++ /dev/null
-{
- "policy-id" : "guard.minmax.scaleout",
- "policy-version" : "1",
- "content" : {
- "actor": "SO",
- "recipe": "VF Module Create",
- "targets": ".*",
- "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
- "min": "1",
- "max": "5",
- "guardActiveStart": "00:00:01-05:00",
- "guardActiveEnd": "23:59:59-05:00"
- }
-}
\ No newline at end of file
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-topology_template:
- policies:
- -
- guard.minmax.scaleout:
- type: onap.policies.controlloop.guard.MinMax
- version: 1.0.0
- metadata:
- policy-id : guard.minmax.scaleout
- properties:
- actor: SO
- recipe: VF Module Create
- targets: .*
- clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
- min: 1
- max: 5
- guardActiveStart: 00:00:01-05:00
- guardActiveEnd: 23:59:59-05:00
+++ /dev/null
-{
- "guard.minmax.scaleout": {
- "type": "onap.policies.controlloop.guard.MinMax",
- "version": "1.0.0",
- "metadata": {
- "policy-id": "guard.minmax.scaleout",
- "policy-version": 1
- },
- "properties": {
- "content": {
- "actor": "SO",
- "recipe": "VF Module Create",
- "targets": ".*",
- "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
- "min": "1",
- "max": "5",
- "guardActiveStart": "00:00:01-05:00",
- "guardActiveEnd": "23:59:59-05:00"
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-topology_template:
- policies:
- -
- guard.minmax.scaleout:
- type: onap.policies.controlloop.guard.MinMax
- version: 1.0.0
- metadata:
- policy-id : guard.minmax.scaleout
- policy-version: 1
- properties:
- actor: SO
- recipe: VF Module Create
- targets: .*
- clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
- min: 1
- max: 5
- guardActiveStart: 00:00:01-05:00
- guardActiveEnd: 23:59:59-05:00
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+topology_template:
+ policies:
+ -
+ guard.minmax.scaleout:
+ type: onap.policies.controlloop.guard.common.MinMax
+ type_version: 1.0.0
+ version: 1.0.0
+ metadata:
+ policy-id : guard.minmax.scaleout
+ properties:
+ actor: SO
+ operation: VF Module Create
+ id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
+ min: 1
+ max: 2
\ No newline at end of file
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template":
{
"policies":
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- operational.scaleout:
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- operational.scaleout:
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template":
{
"policies":
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
"topology_template": {
"policies": [
{
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- operational.modifyconfig:
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
-
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
topology_template:
policies:
- operational.modifyconfig.cds:
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Naming:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Optimization:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.controlloop.Operational:
derived_from: tosca.policies.Root
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.Blacklist:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports blacklist of VNF's from performing control loop actions on.
- properties:
- blacklist_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.Blacklist
-data_types:
- onap.datatypes.guard.Blacklist:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the blacklist is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- blacklist:
- type: list
- description: List of VNF's
- required: true
\ No newline at end of file
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ This is the base Policy Type for Guard policies that guard the execution of Operational
+ Policies.
+ properties:
+ actor:
+ type: string
+ description: Specifies the Actor the guard applies to.
+ required: true
+ operation:
+ type: string
+ description: Specified the operation that the actor is performing the guard applies to.
+ required: true
+ timeRange:
+ type: tosca.datatypes.TimeInterval
+ description: |
+ An optional range of time during the day the guard policy is valid for.
+ required: false
+ id:
+ type: string
+ description: The Control Loop id this applies to.
+ required: false
\ No newline at end of file
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.FrequencyLimiter:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports limiting the frequency of actions being taken by a Actor.
- properties:
- frequency_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.FrequencyLimiter
-data_types:
- onap.datatypes.guard.FrequencyLimiter:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_window:
- type: scalar-unit.time
- description: The time window to count the actions against.
- required: true
- limit:
- type: integer
- description: The limit
- required: true
- constraints:
- - greater_than: 0
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the frequency is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- target:
- type: string
- description: An optional specific VNF to apply this guard to.
- required: false
\ No newline at end of file
+++ /dev/null
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.MinMax:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports Min/Max number of VF Modules
- properties:
- minmax_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.MinMax
-data_types:
- onap.datatypes.guard.MinMax:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the Min/Max limit is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- min_vf_module_instances:
- type: integer
- required: true
- description: The minimum instances of this VF-Module
- max_vf_module_instances:
- type: integer
- required: false
- description: The maximum instances of this VF-Module
\ No newline at end of file
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.Blacklist:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports blacklist of entity id's from performing control loop actions on.
+ properties:
+ blacklist:
+ type: list
+ description: List of entity id's
+ required: true
+ entry_schema:
+ type: string
\ No newline at end of file
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.FrequencyLimiter:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports limiting the frequency of actions being taken by a Actor.
+ properties:
+ timeWindow:
+ type: integer
+ description: The time window to count the actions against.
+ required: true
+ timeUnits:
+ type: string
+ description: The units of time the window is counting.
+ constraints:
+ - valid_values: ["second", "minute", "hour", "day", "week", "month", "year"]
+ limit:
+ type: integer
+ description: The limit
+ required: true
+ constraints:
+ - greater_than: 0
\ No newline at end of file
--- /dev/null
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.common.MinMax:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports Min/Max number of entity for scaling operations
+ properties:
+ min:
+ type: integer
+ required: true
+ description: The minimum instances of this entity
+ max:
+ type: integer
+ required: false
+ description: The maximum instances of this entity
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.controlloop.Guard:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.controlloop.operational.Common:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.controlloop.operational.common.Apex:
derived_from: onap.policies.controlloop.operational.Common
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.controlloop.operational.common.Drools:
derived_from: onap.policies.controlloop.operational.Common
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Monitoring:
derived_from: tosca.policies.Root
tca_policy:
type: onap.datatypes.monitoring.tca_policy
description: TCA Policy JSON
+ required: true
data_types:
onap.datatypes.monitoring.metricsPerEventName:
derived_from: tosca.datatypes.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Monitoring:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Native:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Native:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Native:
derived_from: tosca.policies.Root
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.Resource:
derived_from: onap.policies.Optimization
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.Service:
derived_from: onap.policies.Optimization
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.AffinityPolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.DistancePolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.HpaPolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.OptimizationPolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.PciPolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.Vim_fit:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.resource.VnfPolicy:
derived_from: onap.policies.optimization.Resource
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.service.QueryPolicy:
derived_from: onap.policies.optimization.Service
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.optimization.service.SubscriberPolicy:
derived_from: onap.policies.optimization.Service
import java.util.Date;
import java.util.List;
-import java.util.Map;
import lombok.NonNull;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId,
@NonNull final String policyVersion) throws PfModelException;
- /**
- * Get legacy guard policy.
- *
- * @param policyId ID of the policy
- * @param policyVersion version of the policy, set to null to get the latest policy
- * @return the policies found
- * @throws PfModelException on errors getting policies
- */
- public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId,
- final String policyVersion) throws PfModelException;
-
- /**
- * Create legacy guard policy.
- *
- * @param legacyGuardPolicy the definition of the policy to be created.
- * @return the created policy
- * @throws PfModelException on errors creating policies
- */
- public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
-
- /**
- * Update legacy guard policy.
- *
- * @param legacyGuardPolicy the definition of the policy to be updated
- * @return the updated policy
- * @throws PfModelException on errors updating policies
- */
- public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
-
- /**
- * Delete legacy guard policy.
- *
- * @param policyId ID of the policy.
- * @param policyVersion version of the policy
- * @return the deleted policy
- * @throws PfModelException on errors deleting policies
- */
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId,
- @NonNull final String policyVersion) throws PfModelException;
-
/**
* Get PDP groups.
*
import java.util.Base64;
import java.util.Date;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import javax.ws.rs.core.Response;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
import org.onap.policy.models.tosca.legacy.provider.LegacyProvider;
import org.slf4j.Logger;
return new LegacyProvider().deleteOperationalPolicy(pfDao, policyId, policyVersion);
}
- @Override
- public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId,
- final String policyVersion) throws PfModelException {
- assertInitialized();
- return new LegacyProvider().getGuardPolicy(pfDao, policyId, policyVersion);
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput>
- createGuardPolicy(@NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
- assertInitialized();
- return new LegacyProvider().createGuardPolicy(pfDao, legacyGuardPolicy);
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput>
- updateGuardPolicy(@NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
- assertInitialized();
- return new LegacyProvider().updateGuardPolicy(pfDao, legacyGuardPolicy);
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId,
- @NonNull final String policyVersion) throws PfModelException {
- assertInitialized();
-
- assertPolicyNotDeployedInPdpGroup(
- new ToscaPolicyIdentifier(policyId, policyVersion + LegacyProvider.LEGACY_MINOR_PATCH_SUFFIX));
-
- return new LegacyProvider().deleteGuardPolicy(pfDao, policyId, policyVersion);
- }
-
@Override
public List<PdpGroup> getPdpGroups(final String name) throws PfModelException {
assertInitialized();
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
return new LegacyOperationalPolicy();
}
- @Override
- public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(final String policyId, final String policyVersion)
- throws PfModelException {
- return new HashMap<>();
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(final LegacyGuardPolicyInput legacyGuardPolicy)
- throws PfModelException {
- return new HashMap<>();
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(final LegacyGuardPolicyInput legacyGuardPolicy)
- throws PfModelException {
- return new HashMap<>();
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(final String policyId, final String policyVersion)
- throws PfModelException {
- return new HashMap<>();
- }
-
@Override
public List<PdpGroup> getPdpGroups(final String name) throws PfModelException {
return new ArrayList<>();
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
databaseProvider.deleteOperationalPolicy("", null);
}).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
- assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy(null, null);
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy(null, "");
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy("", null);
- }).hasMessage("no policy found for policy: :null");
-
- assertThatThrownBy(() -> {
- databaseProvider.createGuardPolicy(null);
- }).hasMessageMatching("^legacyGuardPolicy is marked .*on.*ull but is null$");
-
- assertThatThrownBy(() -> {
- databaseProvider.updateGuardPolicy(null);
- }).hasMessageMatching("^legacyGuardPolicy is marked .*on.*ull but is null$");
-
- assertThatThrownBy(() -> {
- databaseProvider.deleteGuardPolicy(null, null);
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- databaseProvider.deleteGuardPolicy(null, "");
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- databaseProvider.deleteGuardPolicy("", null);
- }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
-
assertThatThrownBy(() -> {
databaseProvider.getFilteredPdpGroups(null);
}).hasMessageMatching(FILTER_IS_NULL);
databaseProvider.deleteOperationalPolicy(POLICY_ID, "55");
}).hasMessage("no policy found for policy: policy_id:55");
- assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy(POLICY_ID, null);
- }).hasMessage("no policy found for policy: policy_id:null");
-
- assertThatThrownBy(() -> {
- databaseProvider.getGuardPolicy(POLICY_ID, "6");
- }).hasMessage("no policy found for policy: policy_id:6");
-
- assertThatThrownBy(() -> {
- databaseProvider.createGuardPolicy(new LegacyGuardPolicyInput());
- }).hasMessage("policy type for guard policy \"null\" unknown");
-
- assertThatThrownBy(() -> {
- databaseProvider.updateGuardPolicy(new LegacyGuardPolicyInput());
- }).hasMessage("policy type for guard policy \"null\" unknown");
-
- assertThatThrownBy(() -> {
- databaseProvider.deleteGuardPolicy(POLICY_ID, "33");
- }).hasMessage("no policy found for policy: policy_id:33");
-
assertEquals(0, databaseProvider.getPdpGroups(NAME).size());
assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size());
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
return null;
}
- @Override
- public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull String policyId, final String policyVersion)
- throws PfModelException {
- return null;
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(@NonNull LegacyGuardPolicyInput legacyGuardPolicy)
- throws PfModelException {
- return null;
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(@NonNull LegacyGuardPolicyInput legacyGuardPolicy)
- throws PfModelException {
- return null;
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull String policyId,
- @NonNull final String policyVersion) throws PfModelException {
- return null;
- }
-
@Override
public List<PdpGroup> getPdpGroups(String name) throws PfModelException {
return Collections.emptyList();
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
assertNotNull(dummyProvider.updateOperationalPolicy(new LegacyOperationalPolicy()));
assertNotNull(dummyProvider.deleteOperationalPolicy(POLICY_ID, "1"));
- assertNotNull(dummyProvider.getGuardPolicy(POLICY_ID, "1"));
- assertNotNull(dummyProvider.createGuardPolicy(new LegacyGuardPolicyInput()));
- assertNotNull(dummyProvider.updateGuardPolicy(new LegacyGuardPolicyInput()));
- assertNotNull(dummyProvider.deleteGuardPolicy(POLICY_ID, "1"));
-
assertTrue(dummyProvider.getPdpGroups("name").isEmpty());
assertTrue(dummyProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).isEmpty());
assertTrue(dummyProvider.createPdpGroups(new ArrayList<>()).isEmpty());
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.provider.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.net.URISyntaxException;
-import java.util.Base64;
-import java.util.Map;
-import java.util.Set;
-
-import lombok.NonNull;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test persistence of monitoring policies to and from the database.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-public class PolicyLegacyGuardPersistenceTest {
- private StandardCoder standardCoder;
-
- private PolicyModelsProvider databaseProvider;
-
- // @formatter:off
- private String[] policyInputResourceNames = {
- "policies/vDNS.policy.guard.frequency.input.json",
- "policies/vDNS.policy.guard.minmax.input.json"
- };
-
- private String[] policyOutputResourceNames = {
- "policies/vDNS.policy.guard.frequency.output.json",
- "policies/vDNS.policy.guard.minmax.output.json"
- };
- // @formatter:on
-
- /**
- * Initialize provider.
- *
- * @throws PfModelException on exceptions in the tests
- * @throws CoderException on JSON encoding and decoding errors
- */
- @Before
- public void setupParameters() throws Exception {
- // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
-
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseDriver("org.h2.Driver");
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
- parameters.setPersistenceUnit("ToscaConceptTest");
-
- databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
-
- createPolicyTypes();
- }
-
- /**
- * Set up standard coder.
- */
- @Before
- public void setupStandardCoder() {
- standardCoder = new StandardCoder();
- }
-
- @After
- public void teardown() throws Exception {
- databaseProvider.close();
- }
-
- @Test
- public void testLegacyGuardPolicyPersistence() throws Exception {
- for (int i = 0; i < policyInputResourceNames.length; i++) {
- String policyInputString = ResourceUtils.getResourceAsString(policyInputResourceNames[i]);
- String policyOutputString = ResourceUtils.getResourceAsString(policyOutputResourceNames[i]);
- testJsonStringPolicyPersistence(policyInputString, policyOutputString);
- }
- }
-
- /**
- * Check persistence of a policy.
- *
- * @param policyInputString the policy as a string
- * @param policyOutputString the expected output string
- * @throws Exception any exception thrown
- */
- public void testJsonStringPolicyPersistence(@NonNull final String policyInputString,
- final String policyOutputString) throws Exception {
- LegacyGuardPolicyInput gip = standardCoder.decode(policyInputString, LegacyGuardPolicyInput.class);
-
- assertNotNull(gip);
-
- Map<String, LegacyGuardPolicyOutput> createdGopm = databaseProvider.createGuardPolicy(gip);
- assertEquals(gip.getPolicyId(), createdGopm.keySet().iterator().next());
- assertEquals(gip.getContent(), createdGopm.get(gip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotGopm = databaseProvider.getGuardPolicy(gip.getPolicyId(), null);
- assertEquals(gip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(gip.getContent(), gotGopm.get(gip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> updatedGopm = databaseProvider.updateGuardPolicy(gip);
- assertEquals(gip.getPolicyId(), updatedGopm.keySet().iterator().next());
- assertEquals(gip.getContent(), updatedGopm.get(gip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> deletedGopm = databaseProvider.deleteGuardPolicy(gip.getPolicyId(), "1");
- assertEquals(gip.getPolicyId(), deletedGopm.keySet().iterator().next());
- assertEquals(gip.getContent(), deletedGopm.get(gip.getPolicyId()).getProperties().values().iterator().next());
-
- String actualRetrievedJson = standardCoder.encode(gotGopm);
-
- // All of this dash/underscore stuff is to avoid a checkstyle error around escaping unicode characters
- assertEquals(policyOutputString.replaceAll("\\s+", ""), actualRetrievedJson.replaceAll("\\s+", ""));
- }
-
- private void createPolicyTypes() throws CoderException, PfModelException, URISyntaxException {
- Set<String> policyTypeResources = ResourceUtils.getDirectoryContents("policytypes");
-
- for (String policyTyoeResource : policyTypeResources) {
- Object yamlObject = new Yaml().load(ResourceUtils.getResourceAsString(policyTyoeResource));
- String yamlAsJsonString = new StandardCoder().encode(yamlObject);
-
- ToscaServiceTemplate toscaServiceTemplatePolicyType =
- standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
-
- assertNotNull(toscaServiceTemplatePolicyType);
- databaseProvider.createPolicyTypes(toscaServiceTemplatePolicyType);
- }
- }
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.concepts;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import lombok.Data;
-
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.legacy.mapping.LegacyGuardPolicyMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Content object of a Legacy Guard Policy.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-@Data
-public class LegacyGuardPolicyContent {
- private static final Logger LOGGER = LoggerFactory.getLogger(LegacyGuardPolicyMapper.class);
-
- private String actor;
- private String recipe;
- private String targets;
- private String clname;
- private String limit;
- private String timeWindow;
- private String timeUnits;
- private String min;
- private String max;
- private String guardActiveStart;
- private String guardActiveEnd;
-
- /**
- * Get contents as a property map.
- *
- * @return the contents as a map.
- */
- public Map<String, String> getAsPropertyMap() {
- final Map<String, String> propertyMap = new HashMap<>();
-
- final StandardCoder coder = new StandardCoder();
-
- try {
- for (Field field : this.getClass().getDeclaredFields()) {
- if (field.get(this) != null && field.getType().equals(String.class)) {
- propertyMap.put(field.getName(), coder.encode(field.get(this)));
- }
- }
- } catch (Exception exc) {
- String errorMessage = "could not convert content to a property map";
- LOGGER.warn(errorMessage, exc);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage, exc);
-
- }
-
- return propertyMap;
- }
-
- /**
- * Set the contents from a property map.
- *
- * @param propertyMap the incoming property map
- */
- public void setContent(final Map<String, String> propertyMap) {
- final StandardCoder coder = new StandardCoder();
-
- try {
- // @formatter:off
- setActor( coder.decode(propertyMap.get("actor"), String.class));
- setClname( coder.decode(propertyMap.get("clname"), String.class));
- setGuardActiveEnd( coder.decode(propertyMap.get("guardActiveEnd"), String.class));
- setGuardActiveStart(coder.decode(propertyMap.get("guardActiveStart"), String.class));
- setLimit( coder.decode(propertyMap.get("limit"), String.class));
- setMax( coder.decode(propertyMap.get("max"), String.class));
- setMin( coder.decode(propertyMap.get("min"), String.class));
- setRecipe( coder.decode(propertyMap.get("recipe"), String.class));
- setTargets( coder.decode(propertyMap.get("targets"), String.class));
- setTimeUnits( coder.decode(propertyMap.get("timeUnits"), String.class));
- setTimeWindow( coder.decode(propertyMap.get("timeWindow"), String.class));
- // @formatter:on
- } catch (Exception exc) {
- String errorMessage = "could not convert content to a property map";
- LOGGER.warn(errorMessage, exc);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage, exc);
- }
- }
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.concepts;
-
-import com.google.gson.annotations.SerializedName;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * Definition of a legacy guard policy stored as a TOSCA policy.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-@Data
-public class LegacyGuardPolicyInput {
-
- @ApiModelProperty(name = "policy-id")
- @SerializedName("policy-id")
- private String policyId;
-
- @ApiModelProperty(name = "policy-version")
- @SerializedName("policy-version")
- private String policyVersion;
-
- private LegacyGuardPolicyContent content;
-
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.concepts;
-
-import java.util.Map;
-
-import lombok.Data;
-
-/**
- * Body of a legacy guard policy output.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-@Data
-public class LegacyGuardPolicyOutput {
- private String type;
- private String version;
- private Map<String, Object> metadata;
- private Map<String, LegacyGuardPolicyContent> properties;
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.mapping;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.Response;
-
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyContent;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate;
-import org.onap.policy.models.tosca.simple.mapping.JpaToscaServiceTemplateMapper;
-import org.onap.policy.models.tosca.utils.ToscaUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class maps a legacy guard policy to and from a TOSCA service template.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-public class LegacyGuardPolicyMapper
- implements JpaToscaServiceTemplateMapper<LegacyGuardPolicyInput, Map<String, LegacyGuardPolicyOutput>> {
- private static final Logger LOGGER = LoggerFactory.getLogger(LegacyGuardPolicyMapper.class);
-
- // Tag for metadata fields
- private static final String POLICY_ID = "policy-id";
- private static final String POLICY_VERSION = "policy-version";
-
- private static final Map<String, PfConceptKey> GUARD_POLICY_TYPE_MAP = new LinkedHashMap<>();
-
- static {
- GUARD_POLICY_TYPE_MAP.put("guard.frequency.",
- new PfConceptKey("onap.policies.controlloop.guard.FrequencyLimiter:1.0.0"));
- GUARD_POLICY_TYPE_MAP.put("guard.minmax.", new PfConceptKey("onap.policies.controlloop.guard.MinMax:1.0.0"));
- GUARD_POLICY_TYPE_MAP.put("guard.blacklist.",
- new PfConceptKey("onap.policies.controlloop.guard.Blacklist:1.0.0"));
- }
-
- @Override
- public JpaToscaServiceTemplate toToscaServiceTemplate(final LegacyGuardPolicyInput legacyGuardPolicyInput) {
- PfConceptKey guardPolicyType = getGuardPolicyType(legacyGuardPolicyInput);
- if (guardPolicyType == null) {
- String errorMessage =
- "policy type for guard policy \"" + legacyGuardPolicyInput.getPolicyId() + "\" unknown";
- LOGGER.warn(errorMessage);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
- }
-
- String version = legacyGuardPolicyInput.getPolicyVersion();
- if (version != null) {
- version = version + ".0.0";
- } else {
- version = guardPolicyType.getVersion();
- }
-
- PfConceptKey policyKey = new PfConceptKey(legacyGuardPolicyInput.getPolicyId(), version);
-
- final JpaToscaPolicy toscaPolicy = new JpaToscaPolicy(policyKey);
- toscaPolicy.setType(guardPolicyType);
- toscaPolicy.setProperties(legacyGuardPolicyInput.getContent().getAsPropertyMap());
-
- final Map<String, String> metadata = new LinkedHashMap<>();
- metadata.put(POLICY_ID, toscaPolicy.getKey().getName());
- metadata.put(POLICY_VERSION, Integer.toString(toscaPolicy.getKey().getMajorVersion()));
- toscaPolicy.setMetadata(metadata);
-
- final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
- serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0_0");
-
- serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
-
- serviceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
- serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, toscaPolicy);
-
- return serviceTemplate;
- }
-
- @Override
- public Map<String, LegacyGuardPolicyOutput>
- fromToscaServiceTemplate(final JpaToscaServiceTemplate serviceTemplate) {
- ToscaUtils.assertPoliciesExist(serviceTemplate);
-
- final Map<String, LegacyGuardPolicyOutput> legacyGuardPolicyOutputMap = new LinkedHashMap<>();
-
- for (JpaToscaPolicy toscaPolicy : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap()
- .values()) {
-
- final LegacyGuardPolicyOutput legacyGuardPolicyOutput = new LegacyGuardPolicyOutput();
- legacyGuardPolicyOutput.setType(toscaPolicy.getType().getName());
- legacyGuardPolicyOutput.setVersion(toscaPolicy.getKey().getVersion());
-
- if (toscaPolicy.getMetadata() == null) {
- String errorMessage = "no metadata defined on TOSCA policy";
- LOGGER.warn(errorMessage);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
- }
-
- final Map<String, Object> metadata = new LinkedHashMap<>(toscaPolicy.getMetadata());
-
- // if version exists, convert it to int
- metadata.computeIfPresent(POLICY_VERSION, (key, val) -> Integer.parseInt(val.toString()));
-
- legacyGuardPolicyOutput.setMetadata(metadata);
-
- if (toscaPolicy.getProperties() == null) {
- String errorMessage = "no properties defined on TOSCA policy";
- LOGGER.warn(errorMessage);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
- }
-
- final LegacyGuardPolicyContent content = new LegacyGuardPolicyContent();
- content.setContent(toscaPolicy.getProperties());
-
- final Map<String, LegacyGuardPolicyContent> propertiesMap = new LinkedHashMap<>();
- propertiesMap.put("content", content);
- legacyGuardPolicyOutput.setProperties(propertiesMap);
-
- legacyGuardPolicyOutputMap.put(toscaPolicy.getKey().getName(), legacyGuardPolicyOutput);
- }
-
- return legacyGuardPolicyOutputMap;
- }
-
- private PfConceptKey getGuardPolicyType(final LegacyGuardPolicyInput legacyGuardPolicyInput) {
- final String policyId = legacyGuardPolicyInput.getPolicyId();
- if (policyId == null) {
- return null;
- }
-
- for (Entry<String, PfConceptKey> guardPolicyTypeEntry : GUARD_POLICY_TYPE_MAP.entrySet()) {
- if (policyId.startsWith(guardPolicyTypeEntry.getKey())) {
- return guardPolicyTypeEntry.getValue();
- }
- }
-
- return null;
- }
-}
toscaPolicy.getProperties().put(CONTENT_PROPERTY, legacyOperationalPolicy.getContent());
final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
- serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0_0");
+ serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_1_0");
serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
package org.onap.policy.models.tosca.legacy.provider;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.PfDao;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
-import org.onap.policy.models.tosca.legacy.mapping.LegacyGuardPolicyMapper;
import org.onap.policy.models.tosca.legacy.mapping.LegacyOperationalPolicyMapper;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy;
return legacyOperationalPolicy;
}
- /**
- * Get legacy guard policy.
- *
- * @param dao the DAO to use to access the database
- * @param policyId ID of the policy.
- * @param policyVersion version of the policy.
- * @return the policies found
- * @throws PfModelException on errors getting policies
- */
- public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final PfDao dao, @NonNull final String policyId,
- final String policyVersion) throws PfModelException {
-
- LOGGER.debug("->getGuardPolicy: policyId={}, policyVersion={}", policyId, policyVersion);
-
- Map<String, LegacyGuardPolicyOutput> legacyGuardPolicyMap =
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(getLegacyPolicy(dao, policyId, policyVersion));
-
- LOGGER.debug("<-getGuardPolicy: policyId={}, policyVersion={}, legacyGuardPolicyMap={}", policyId,
- policyVersion, legacyGuardPolicyMap);
- return legacyGuardPolicyMap;
- }
-
- /**
- * Create legacy guard policy.
- *
- * @param dao the DAO to use to access the database
- * @param legacyGuardPolicy the definition of the policy to be created.
- * @return the created policy
- * @throws PfModelException on errors creating policies
- */
- public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(@NonNull final PfDao dao,
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
-
- LOGGER.debug("->createGuardPolicy: legacyGuardPolicy={}", legacyGuardPolicy);
-
- JpaToscaServiceTemplate incomingServiceTemplate =
- new LegacyGuardPolicyMapper().toToscaServiceTemplate(legacyGuardPolicy);
- JpaToscaServiceTemplate outgoingingServiceTemplate =
- new SimpleToscaProvider().createPolicies(dao, incomingServiceTemplate);
-
- Map<String, LegacyGuardPolicyOutput> createdLegacyGuardPolicyMap =
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(outgoingingServiceTemplate);
-
- LOGGER.debug("<-createGuardPolicy: createdLegacyGuardPolicyMap={}", createdLegacyGuardPolicyMap);
- return createdLegacyGuardPolicyMap;
- }
-
- /**
- * Update legacy guard policy.
- *
- * @param dao the DAO to use to access the database
- * @param legacyGuardPolicy the definition of the policy to be updated
- * @return the updated policy
- * @throws PfModelException on errors updating policies
- */
- public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(@NonNull final PfDao dao,
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
-
- LOGGER.debug("->updateGuardPolicy: legacyGuardPolicy={}", legacyGuardPolicy);
-
- JpaToscaServiceTemplate incomingServiceTemplate =
- new LegacyGuardPolicyMapper().toToscaServiceTemplate(legacyGuardPolicy);
- JpaToscaServiceTemplate outgoingingServiceTemplate =
- new SimpleToscaProvider().updatePolicies(dao, incomingServiceTemplate);
-
- Map<String, LegacyGuardPolicyOutput> updatedLegacyGuardPolicyMap =
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(outgoingingServiceTemplate);
-
- LOGGER.debug("<-updateGuardPolicy: updatedLegacyGuardPolicyMap={}", updatedLegacyGuardPolicyMap);
- return updatedLegacyGuardPolicyMap;
- }
-
- /**
- * Delete legacy guard policy.
- *
- * @param dao the DAO to use to access the database
- * @param policyId ID of the policy.
- * @param policyVersion version of the policy.
- * @return the deleted policy
- * @throws PfModelException on errors deleting policies
- */
- public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final PfDao dao,
- @NonNull final String policyId, @NonNull final String policyVersion) throws PfModelException {
-
- LOGGER.debug("->deleteGuardPolicy: policyId={}, policyVersion={}", policyId, policyVersion);
- Map<String, LegacyGuardPolicyOutput> legacyGuardPolicyMap = new LegacyGuardPolicyMapper()
- .fromToscaServiceTemplate(deleteLegacyPolicy(dao, policyId, policyVersion));
-
- LOGGER.debug("<-deleteGuardPolicy: policyId={}, policyVersion={}, legacyGuardPolicyMap={}", policyId,
- policyVersion, legacyGuardPolicyMap);
- return legacyGuardPolicyMap;
- }
-
/**
* Get the JPA Policy for a policy ID and version.
*
implements PfAuthorative<ToscaServiceTemplate> {
private static final long serialVersionUID = 8084846046148349401L;
- public static final String DEFAULT_TOSCA_DEFINTIONS_VERISON = "tosca_simple_yaml_1_0_0";
+ public static final String DEFAULT_TOSCA_DEFINTIONS_VERISON = "tosca_simple_yaml_1_1_0";
public static final String DEFAULT_NAME = "ToscaServiceTemplateSimple";
public static final String DEFAULT_VERSION = "1.0.0";
package org.onap.policy.models.tosca.authorative.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
"policies/vCPE.policy.monitoring.input.tosca.json",
"policies/vCPE.policy.monitoring.input.tosca.yaml",
"policies/vCPE.policy.operational.input.tosca.yaml",
- "policies/vDNS.policy.guard.frequency.input.tosca.json",
- "policies/vDNS.policy.guard.frequency.input.tosca.yaml",
- "policies/vDNS.policy.guard.minmax.input.tosca.yaml",
"policies/vDNS.policy.monitoring.input.tosca.json",
"policies/vDNS.policy.monitoring.input.tosca.yaml",
"policies/vDNS.policy.operational.input.tosca.yaml",
+ "policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml",
+ "policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml",
"policies/vFirewall.policy.monitoring.input.tosca.json",
"policies/vFirewall.policy.monitoring.input.tosca.yaml",
"policies/vFirewall.policy.operational.input.tosca.json",
assertEquals(VERSION_100, filteredList.get(7).getVersion());
assertEquals(VERSION_100, filteredList.get(12).getVersion());
- assertEquals(23, policyList.size());
+ assertEquals(22, policyList.size());
assertEquals(22, filteredList.size());
- policyList.get(10).setVersion("2.0.0");
- policyList.get(16).setVersion("3.4.5");
+ //
+ // Change versions to a couple of policies
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ policy.setVersion("2.0.0");
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ policy.setVersion("3.4.5");
+ }
+ });
+ //
+ // We'll still get back the same number of policies
+ //
filteredList = filter.filter(policyList);
assertEquals(22, filteredList.size());
- assertEquals("2.0.0", filteredList.get(12).getVersion());
- assertEquals("3.4.5", filteredList.get(14).getVersion());
-
- policyList.get(10).setVersion(VERSION_100);
- policyList.get(16).setVersion(VERSION_100);
+ //
+ // Assert that the correct versions are returned
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo("2.0.0");
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo("3.4.5");
+ } else if ("operational.scaleout".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_000);
+ } else {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_100);
+ }
+ });
+
+ //
+ // Change versions back
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ policy.setVersion(VERSION_100);
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ policy.setVersion(VERSION_100);
+ }
+ });
+ //
+ // We'll still get back the same number of policies
+ //
filteredList = filter.filter(policyList);
assertEquals(22, filteredList.size());
- assertEquals(VERSION_100, filteredList.get(12).getVersion());
- assertEquals(VERSION_100, filteredList.get(14).getVersion());
+ //
+ // Assert that the correct versions are returned
+ //
+ policyList.forEach(policy -> {
+ //
+ // Should we fix this to be 1.0.0??
+ //
+ if ("operational.scaleout".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_000);
+ } else {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_100);
+ }
+ });
}
@Test
filter = ToscaPolicyFilter.builder().name("guard.frequency.scaleout").build();
filteredList = filter.filter(policyList);
- assertEquals(2, filteredList.size());
+ assertEquals(1, filteredList.size());
filter = ToscaPolicyFilter.builder().name("guard.frequency.scalein").build();
filteredList = filter.filter(policyList);
filter = ToscaPolicyFilter.builder().name("operational.modifyconfig").version(VERSION_100).build();
filteredList = filter.filter(policyList);
- assertEquals(0, filteredList.size());
+ assertEquals(1, filteredList.size());
}
@Test
// null pattern
ToscaPolicyFilter filter = ToscaPolicyFilter.builder().versionPrefix(null).build();
List<ToscaPolicy> filteredList = filter.filter(policyList);
- assertEquals(23, filteredList.size());
+ assertEquals(22, filteredList.size());
filter = ToscaPolicyFilter.builder().versionPrefix("1.").build();
filteredList = filter.filter(policyList);
- assertEquals(21, filteredList.size());
+ assertEquals(20, filteredList.size());
filter = ToscaPolicyFilter.builder().versionPrefix("100.").build();
filteredList = filter.filter(policyList);
filter = ToscaPolicyFilter.builder().typeVersion(VERSION_000).build();
filteredList = filter.filter(policyList);
- assertEquals(3, filteredList.size());
+ assertEquals(0, filteredList.size());
filter = ToscaPolicyFilter.builder().type("onap.policies.optimization.resource.HpaPolicy")
.typeVersion(VERSION_100).build();
"policytypes/onap.policies.optimization.resource.VnfPolicy.yaml",
"policytypes/onap.policies.optimization.resource.PciPolicy.yaml",
"policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml",
- "policytypes/onap.policies.controlloop.guard.Blacklist.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml",
"policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
"policytypes/onap.policies.optimization.resource.HpaPolicy.yaml",
"policytypes/onap.policies.optimization.resource.Vim_fit.yaml",
"policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml",
"policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml",
"policytypes/onap.policies.optimization.service.QueryPolicy.yaml",
- "policytypes/onap.policies.controlloop.guard.MinMax.yaml",
- "policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.MinMax.yaml",
+ "policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml",
"policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml",
"policytypes/onap.policies.Optimization.yaml",
"policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"
typeList.get(12).setVersion("2.0.0");
filteredList = filter.filter(typeList);
assertEquals(20, filteredList.size());
- assertEquals("2.0.0", filteredList.get(11).getVersion());
- assertEquals(VERSION_100, filteredList.get(18).getVersion());
+ //
+ // This seems to change around as to where this policy type
+ // got changed - perhaps we change this test to find a specific name
+ // to test for vs an index which never remains consistent?
+ //
+ assertEquals("2.0.0", filteredList.get(18).getVersion());
+ //
+ // And now this index changes again??
+ //
+ assertEquals(VERSION_100, filteredList.get(17).getVersion());
typeList.get(12).setVersion(VERSION_100);
filteredList = filter.filter(typeList);
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.concepts;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.testconcepts.DummyBadLegacyGuardPolicyContent;
-
-public class LegacyGuardPolicyTest {
-
- @Test
- public void test() {
- LegacyGuardPolicyInput guard = new LegacyGuardPolicyInput();
- assertNotNull(guard);
- guard.setPolicyId("guard.frequency");
- assertEquals("guard.frequency", guard.getPolicyId());
- guard.setPolicyVersion("1");
- assertEquals("1", guard.getPolicyVersion());
- Map<String, String> body = new HashMap<>();
- body.put("actor", "SO");
- LegacyGuardPolicyContent content = new LegacyGuardPolicyContent();
- content.setActor("SO");
- guard.setContent(content);
- assertEquals("SO", guard.getContent().getActor());
-
- DummyBadLegacyGuardPolicyContent dblgpc = new DummyBadLegacyGuardPolicyContent();
- assertThatThrownBy(dblgpc::getAsPropertyMap).hasMessage("could not convert content to a property map");
- }
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.concepts.testconcepts;
-
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyContent;
-
-/**
- * Dummy {@link LegacyGuardPolicyContent} class to force exception for testing.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-public class DummyBadLegacyGuardPolicyContent extends LegacyGuardPolicyContent {
- public static final String TO_TRIGGER_EXCEPTION = "Dummy";
- @SuppressWarnings("unused")
- private final transient String aaa = "aaa";
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.mapping;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.junit.Test;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
-import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate;
-
-/**
- * Test the {@link LegacyGuardPolicyMapper} class.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-public class LegacyGuardPolicyMapperTest {
-
- @Test
- public void testLegacyGuardPolicyMapper() {
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
- serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
- serviceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
-
- JpaToscaPolicy policy = new JpaToscaPolicy(new PfConceptKey("PolicyName", "2.0.0"));
- serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policy.getKey(), policy);
-
- policy.setMetadata(null);
- assertThatThrownBy(() -> {
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(serviceTemplate);
- }).hasMessageContaining("no metadata defined on TOSCA policy");
-
- policy.setMetadata(new LinkedHashMap<>());
- policy.setProperties(null);
- assertThatThrownBy(() -> {
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(serviceTemplate);
- }).hasMessageContaining("no properties defined on TOSCA policy");
-
- policy.setProperties(new LinkedHashMap<>());
- Map<String, LegacyGuardPolicyOutput> guardPolicyMap =
- new LegacyGuardPolicyMapper().fromToscaServiceTemplate(serviceTemplate);
- LegacyGuardPolicyOutput guardPolicy = guardPolicyMap.values().iterator().next();
- assertEquals("2.0.0", guardPolicy.getVersion());
- }
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.legacy.provider;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.eclipse.persistence.config.PersistenceUnitProperties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.dao.DaoParameters;
-import org.onap.policy.models.dao.PfDao;
-import org.onap.policy.models.dao.PfDaoFactory;
-import org.onap.policy.models.dao.impl.DefaultPfDao;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyContent;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test the {@link LegacyProvider} class for legacy guard policies.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-public class LegacyProvider4LegacyGuardTest {
- private static final String POLICY_ID_IS_NULL = "^policyId is marked .*on.*ull but is null$";
- private static final String VDNS_OUTPUT_JSON = "policies/vDNS.policy.guard.frequency.output.json";
- private static final String VDNS_INPUT_JSON = "policies/vDNS.policy.guard.frequency.input.json";
- private static final String LEGACY_POLICY_IS_NULL = "^legacyGuardPolicy is marked .*on.*ull but is null$";
- private static final String DAO_IS_NULL = "^dao is marked .*on.*ull but is null$";
- private PfDao pfDao;
- private StandardCoder standardCoder;
-
- /**
- * Set up the DAO towards the database.
- *
- * @throws Exception on database errors
- */
- @Before
- public void setupDao() throws Exception {
- final DaoParameters daoParameters = new DaoParameters();
- daoParameters.setPluginClass(DefaultPfDao.class.getName());
-
- daoParameters.setPersistenceUnit("ToscaConceptTest");
-
- Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
-
- // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
-
- daoParameters.setJdbcProperties(jdbcProperties);
-
- pfDao = new PfDaoFactory().createPfDao(daoParameters);
- pfDao.init(daoParameters);
- }
-
- /**
- * Set up standard coder.
- */
- @Before
- public void setupStandardCoder() {
- standardCoder = new StandardCoder();
- }
-
- @After
- public void teardown() {
- pfDao.close();
- }
-
- @Test
- public void testPoliciesGet() throws Exception {
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(null, null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(null, null, "");
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(pfDao, null, null);
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(pfDao, "I Dont Exist", null);
- }).hasMessage("no policy found for policy: I Dont Exist:null");
-
- createPolicyTypes();
-
- LegacyGuardPolicyInput originalGip =
- standardCoder.decode(ResourceUtils.getResourceAsString(VDNS_INPUT_JSON), LegacyGuardPolicyInput.class);
-
- assertNotNull(originalGip);
-
- Map<String, LegacyGuardPolicyOutput> createdGopm = new LegacyProvider().createGuardPolicy(pfDao, originalGip);
-
- assertEquals(originalGip.getPolicyId(), createdGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- createdGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotGopm =
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
-
- assertEquals(originalGip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- String expectedJsonOutput = ResourceUtils.getResourceAsString(VDNS_OUTPUT_JSON);
- String actualJsonOutput = standardCoder.encode(gotGopm);
-
- assertEquals(expectedJsonOutput.replaceAll("\\s+", ""), actualJsonOutput.replaceAll("\\s+", ""));
-
- gotGopm = new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), "1");
-
- assertEquals(originalGip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- actualJsonOutput = standardCoder.encode(gotGopm);
-
- assertEquals(expectedJsonOutput.replaceAll("\\s+", ""), actualJsonOutput.replaceAll("\\s+", ""));
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), "2");
- }).hasMessage("no policy found for policy: guard.frequency.scaleout:2");
- }
-
- @Test
- public void testPolicyCreate() throws Exception {
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(null, new LegacyGuardPolicyInput());
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(pfDao, null);
- }).hasMessageMatching(LEGACY_POLICY_IS_NULL);
-
- createPolicyTypes();
-
- LegacyGuardPolicyInput originalGip =
- standardCoder.decode(ResourceUtils.getResourceAsString(VDNS_INPUT_JSON), LegacyGuardPolicyInput.class);
-
- assertNotNull(originalGip);
-
- Map<String, LegacyGuardPolicyOutput> createdGopm = new LegacyProvider().createGuardPolicy(pfDao, originalGip);
-
- assertEquals(originalGip.getPolicyId(), createdGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- createdGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotGopm =
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
-
- assertEquals(originalGip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- String expectedJsonOutput = ResourceUtils.getResourceAsString(VDNS_OUTPUT_JSON);
- String actualJsonOutput = standardCoder.encode(gotGopm);
-
- assertEquals(expectedJsonOutput.replaceAll("\\s+", ""), actualJsonOutput.replaceAll("\\s+", ""));
- }
-
- @Test
- public void testPolicyCreateBad() throws Exception {
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(null, new LegacyGuardPolicyInput());
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(pfDao, null);
- }).hasMessageMatching(LEGACY_POLICY_IS_NULL);
-
- createPolicyTypes();
-
- LegacyGuardPolicyInput originalGip =
- standardCoder.decode(ResourceUtils.getResourceAsString(VDNS_INPUT_JSON), LegacyGuardPolicyInput.class);
-
- assertNotNull(originalGip);
-
- originalGip.setPolicyId("i.do.not.exist");
-
- assertThatThrownBy(() -> {
- new LegacyProvider().createGuardPolicy(pfDao, originalGip);
- }).hasMessage("policy type for guard policy \"i.do.not.exist\" unknown");
- }
-
- @Test
- public void testPolicyUpdate() throws Exception {
- assertThatThrownBy(() -> {
- new LegacyProvider().updateGuardPolicy(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().updateGuardPolicy(null, new LegacyGuardPolicyInput());
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().updateGuardPolicy(pfDao, null);
- }).hasMessageMatching(LEGACY_POLICY_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().updateGuardPolicy(pfDao, new LegacyGuardPolicyInput());
- }).hasMessage("policy type for guard policy \"null\" unknown");
-
- createPolicyTypes();
-
- LegacyGuardPolicyInput originalGip =
- standardCoder.decode(ResourceUtils.getResourceAsString(VDNS_INPUT_JSON), LegacyGuardPolicyInput.class);
-
- assertNotNull(originalGip);
-
- Map<String, LegacyGuardPolicyOutput> createdGopm = new LegacyProvider().createGuardPolicy(pfDao, originalGip);
- assertEquals(originalGip.getPolicyId(), createdGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- createdGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotGopm =
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
-
- assertEquals(originalGip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- originalGip.getContent().setRecipe("Roast Turkey");
- Map<String, LegacyGuardPolicyOutput> updatedGp = new LegacyProvider().updateGuardPolicy(pfDao, originalGip);
- assertEquals(originalGip.getPolicyId(), updatedGp.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- updatedGp.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotUpdatedGopm =
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
- assertEquals(originalGip.getPolicyId(), gotUpdatedGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotUpdatedGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
- assertEquals("Roast Turkey",
- gotUpdatedGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next().getRecipe());
- }
-
- @Test
- public void testPoliciesDelete() throws Exception {
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(null, null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(null, null, "");
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(null, "", null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(null, "", "");
- }).hasMessageMatching(DAO_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(pfDao, null, null);
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(pfDao, null, "");
- }).hasMessageMatching(POLICY_ID_IS_NULL);
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(pfDao, "", null);
- }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(pfDao, "IDontExist", "0");
- }).hasMessage("no policy found for policy: IDontExist:0");
-
- createPolicyTypes();
-
- LegacyGuardPolicyInput originalGip =
- standardCoder.decode(ResourceUtils.getResourceAsString(VDNS_INPUT_JSON), LegacyGuardPolicyInput.class);
-
- assertNotNull(originalGip);
-
- Map<String, LegacyGuardPolicyOutput> createdGopm = new LegacyProvider().createGuardPolicy(pfDao, originalGip);
- assertEquals(originalGip.getPolicyId(), createdGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- createdGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- Map<String, LegacyGuardPolicyOutput> gotGopm =
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
-
- assertEquals(originalGip.getPolicyId(), gotGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- gotGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- String expectedJsonOutput = ResourceUtils.getResourceAsString(VDNS_OUTPUT_JSON);
- String actualJsonOutput = standardCoder.encode(gotGopm);
-
- assertEquals(expectedJsonOutput.replaceAll("\\s+", ""), actualJsonOutput.replaceAll("\\s+", ""));
-
- assertThatThrownBy(() -> {
- new LegacyProvider().deleteGuardPolicy(pfDao, originalGip.getPolicyId(), null);
- }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
-
- Map<String, LegacyGuardPolicyOutput> deletedGopm =
- new LegacyProvider().deleteGuardPolicy(pfDao, originalGip.getPolicyId(), "1");
- assertEquals(originalGip.getPolicyId(), deletedGopm.keySet().iterator().next());
- assertEquals(originalGip.getContent(),
- deletedGopm.get(originalGip.getPolicyId()).getProperties().values().iterator().next());
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
- }).hasMessage("no policy found for policy: guard.frequency.scaleout:null");
-
- LegacyGuardPolicyInput otherGip = new LegacyGuardPolicyInput();
- otherGip.setPolicyId("guard.blacklist.b0");
- otherGip.setPolicyVersion("1");
- otherGip.setContent(new LegacyGuardPolicyContent());
-
- Map<String, LegacyGuardPolicyOutput> createdOtherGopm = new LegacyProvider().createGuardPolicy(pfDao, otherGip);
- assertEquals(otherGip.getPolicyId(), createdOtherGopm.keySet().iterator().next());
- assertEquals(otherGip.getContent(),
- createdOtherGopm.get(otherGip.getPolicyId()).getProperties().values().iterator().next());
-
- assertThatThrownBy(() -> {
- new LegacyProvider().getGuardPolicy(pfDao, originalGip.getPolicyId(), null);
- }).hasMessage("no policy found for policy: guard.frequency.scaleout:null");
- }
-
- private void createPolicyTypes() throws CoderException, PfModelException {
- Object yamlObject = new Yaml().load(
- ResourceUtils.getResourceAsString("policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml"));
- String yamlAsJsonString = new StandardCoder().encode(yamlObject);
-
- ToscaServiceTemplate toscaServiceTemplatePolicyType =
- standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
-
- assertNotNull(toscaServiceTemplatePolicyType);
- new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplatePolicyType);
-
- yamlObject = new Yaml()
- .load(ResourceUtils.getResourceAsString("policytypes/onap.policies.controlloop.guard.Blacklist.yaml"));
- yamlAsJsonString = new StandardCoder().encode(yamlObject);
-
- toscaServiceTemplatePolicyType = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
-
- assertNotNull(toscaServiceTemplatePolicyType);
- new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplatePolicyType);
- }
-}
private static final String VERSION = "version";
- private static final String YAML_VERSION = "tosca_simple_yaml_1_0_0";
+ private static final String YAML_VERSION = "tosca_simple_yaml_1_1_0";
private static final String DEFINITION_VERSION = "tosca_definitions_version";
assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
// Check tosca_definitions_version
- assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
+ assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
// Check policy_types
Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
// Check tosca_definitions_version
- assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
+ assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
// Check policy_types
Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Optimization:
derived_from: tosca.policies.Root