From 772c73244e6036635cf0861cea08034a932ffad8 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Sat, 7 Dec 2019 18:00:36 -0500 Subject: Refactor optimization policies Optimization policies need to be further refactored so that Resource vs Service type policies can be specified. Issue-ID: POLICY-2066 Change-Id: Ia40a947097692ea7dcc6ea8d13eb8669c37fac14 Signed-off-by: Pamela Dragosh --- .../policytypes/onap.policies.Optimization.yaml | 16 ---- .../onap.policies.optimization.AffinityPolicy.yaml | 31 ------- .../onap.policies.optimization.DistancePolicy.yaml | 56 ----------- .../onap.policies.optimization.HpaPolicy.yaml | 103 --------------------- ...p.policies.optimization.OptimizationPolicy.yaml | 66 ------------- .../onap.policies.optimization.PciPolicy.yaml | 30 ------ .../onap.policies.optimization.QueryPolicy.yaml | 24 ----- .../onap.policies.optimization.Resource.yaml | 23 +++++ .../onap.policies.optimization.Service.yaml | 15 +++ ...nap.policies.optimization.SubscriberPolicy.yaml | 28 ------ .../onap.policies.optimization.Vim_fit.yaml | 28 ------ .../onap.policies.optimization.VnfPolicy.yaml | 44 --------- ...icies.optimization.resource.AffinityPolicy.yaml | 31 +++++++ ...icies.optimization.resource.DistancePolicy.yaml | 56 +++++++++++ ...p.policies.optimization.resource.HpaPolicy.yaml | 103 +++++++++++++++++++++ ...s.optimization.resource.OptimizationPolicy.yaml | 66 +++++++++++++ ...p.policies.optimization.resource.PciPolicy.yaml | 30 ++++++ ...nap.policies.optimization.resource.Vim_fit.yaml | 28 ++++++ ...p.policies.optimization.resource.VnfPolicy.yaml | 44 +++++++++ ....policies.optimization.service.QueryPolicy.yaml | 24 +++++ ...cies.optimization.service.SubscriberPolicy.yaml | 28 ++++++ .../provider/impl/PolicyTypePersistenceTest.java | 18 ++-- .../concepts/ToscaPolicyTypeFilterTest.java | 20 ++-- .../OptimizationPolicyTypeSerializationTest.java | 64 +++++++++---- 24 files changed, 514 insertions(+), 462 deletions(-) delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml delete mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml create mode 100644 models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml diff --git a/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml b/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml index f88239d73..2cd391ff0 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml @@ -13,22 +13,6 @@ policy_types: required: true entry_schema: type: string - services: - description: One or more services that the policy applies to. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string - resources: - description: One or more VNF resources that the policy applies to. - type: list - metadata: - matchable: true - required: true - entry_schema: - type: string geography: description: One or more geographic regions type: list diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml deleted file mode 100644 index abac21922..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml +++ /dev/null @@ -1,31 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.AffinityPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - affinityProperties: - type: policy.data.affinityProperties_properties - required: true -data_types: - policy.data.affinityProperties_properties: - derived_from: tosca.nodes.Root - properties: - qualifier: - type: string - constraints: - - valid_values: - - same - - different - category: - type: string - required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml deleted file mode 100644 index 3c9150d9e..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml +++ /dev/null @@ -1,56 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.DistancePolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - distanceProperties: - type: policy.data.distanceProperties_properties - required: true -data_types: - policy.data.distanceProperties_properties: - derived_from: tosca.nodes.Root - properties: - locationInfo: - type: string - required: true - distance: - type: policy.data.distance_properties - required: true - entry_schema: - type: policy.data.distance_properties - policy.data.distance_properties: - derived_from: tosca.nodes.Root - properties: - value: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - < - - <= - - '>' - - '>=' - - = - unit: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - km \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml deleted file mode 100644 index dbb5e9ef1..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml +++ /dev/null @@ -1,103 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.HpaPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - flavorFeatures: - type: list - required: true - entry_schema: - type: policy.data.flavorFeatures_properties -data_types: - policy.data.flavorFeatures_properties: - derived_from: tosca.nodes.Root - properties: - id: - type: string - required: true - type: - type: string - required: true - directives: - type: list - required: true - entry_schema: - type: policy.data.directives_properties - flavorProperties: - type: list - required: true - entry_schema: - type: policy.data.flavorProperties_properties - policy.data.directives_properties: - derived_from: tosca.nodes.Root - properties: - type: - type: string - attributes: - type: list - entry_schema: - type: policy.data.directives_attributes_properties - policy.data.directives_attributes_properties: - derived_from: tosca.nodes.Root - properties: - attribute_name: - type: string - attribute_value: - type: string - policy.data.flavorProperties_properties: - derived_from: tosca.nodes.Root - properties: - hpa-feature: - type: string - required: true - mandatory: - type: string - required: true - score: - type: string - required: false - architecture: - type: string - required: true - hpa-version: - type: string - required: true - directives: - type: list - required: true - entry_schema: - type: policy.data.directives_properties - hpa-feature-attributes: - type: list - required: true - entry_schema: - type: policy.data.hpa-feature-attributes_properties - policy.data.hpa-feature-attributes_properties: - derived_from: tosca.nodes.Root - properties: - hpa-attribute-key: - type: string - required: true - hpa-attribute-value: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - < - - <= - - '>' - - '>=' - - = - - '!=' - - any - - all - - subset - unit: - type: string - required: false \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml deleted file mode 100644 index e03ceeea6..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml +++ /dev/null @@ -1,66 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.OptimizationPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - objective: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - minimize - - maximize - objectiveParameter: - type: policy.data.objectiveParameter_properties - required: true -data_types: - policy.data.objectiveParameter_properties: - derived_from: tosca.nodes.Root - properties: - parameterAttributes: - type: list - required: true - entry_schema: - type: policy.data.parameterAttributes_properties - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - '*' - - + - - '-' - - / - - '%' - policy.data.parameterAttributes_properties: - derived_from: tosca.nodes.Root - properties: - resources: - type: string - required: true - customerLocationInfo: - type: string - required: true - parameter: - type: string - required: true - weight: - type: string - required: true - operator: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - '*' - - + - - '-' - - / - - '%' \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml deleted file mode 100644 index 097a5f173..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml +++ /dev/null @@ -1,30 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.PciPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - pciProperties: - type: list - required: false - entry_schema: - type: policy.data.pciProperties_properties -data_types: - policy.data.pciProperties_properties: - derived_from: tosca.nodes.Root - properties: - algoCategory: - type: string - required: false - pciOptmizationAlgoName: - type: string - required: false - pciOptimizationNwConstraint: - type: string - required: false - pciOptimizationPriority: - type: string - required: false - pciOptimizationTimeConstraint: - type: string - required: false \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml deleted file mode 100644 index 41b923ad7..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml +++ /dev/null @@ -1,24 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.QueryPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - queryProperties: - type: list - required: true - entry_schema: - type: policy.data.queryProperties_properties -data_types: - policy.data.queryProperties_properties: - derived_from: tosca.nodes.Root - properties: - attribute: - type: string - required: true - value: - type: string - required: true - attribute_location: - type: string - required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml new file mode 100644 index 000000000..1d8135162 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml @@ -0,0 +1,23 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.Resource: + derived_from: onap.policies.Optimization + version: 1.0.0 + description: The base policy type for all policies that govern optimization for a Resource in a Service. + properties: + services: + description: One or more services that the policy applies to. + type: list + metadata: + matchable: true + required: true + entry_schema: + type: string + resources: + description: One or more VNF resources that the policy applies to. + type: list + metadata: + matchable: true + required: true + entry_schema: + type: string \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml new file mode 100644 index 000000000..8e7b724da --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml @@ -0,0 +1,15 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.Service: + derived_from: onap.policies.Optimization + version: 1.0.0 + description: The base policy type for all policies that govern optimization for a Service. + properties: + services: + description: One or more services that the policy applies to. + type: list + metadata: + matchable: true + required: true + entry_schema: + type: string \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml deleted file mode 100644 index 010a1534b..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml +++ /dev/null @@ -1,28 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.SubscriberPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - subscriberProperties: - type: policy.data.subscriberProperties_properties - required: true -data_types: - policy.data.subscriberProperties_properties: - derived_from: tosca.nodes.Root - properties: - subscriberName: - type: list - required: true - entry_schema: - type: string - subscriberRole: - type: list - required: true - entry_schema: - type: string - provStatus: - type: list - required: true - entry_schema: - type: string \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml deleted file mode 100644 index b70dddb2f..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml +++ /dev/null @@ -1,28 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.Vim_fit: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - capacityProperties: - type: policy.data.capacityProperties_properties - required: true -data_types: - policy.data.capacityProperties_properties: - derived_from: tosca.nodes.Root - properties: - controller: - type: string - required: true - request: - type: string - required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml deleted file mode 100644 index 18a0ccfd0..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml +++ /dev/null @@ -1,44 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 -policy_types: - onap.policies.optimization.VnfPolicy: - derived_from: onap.policies.Optimization - version: 1.0.0 - properties: - applicableResources: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - any - - all - vnfProperties: - type: list - required: true - entry_schema: - type: policy.data.vnfProperties_properties -data_types: - policy.data.vnfProperties_properties: - derived_from: tosca.nodes.Root - properties: - inventoryProvider: - type: string - required: true - serviceType: - type: string - required: true - inventoryType: - type: list - required: true - entry_schema: - type: string - constraints: - - valid_values: - - serviceInstanceId - - vnfName - - cloudRegionId - - vimId - customerId: - type: string - required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml new file mode 100644 index 000000000..173691f21 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml @@ -0,0 +1,31 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.AffinityPolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + affinityProperties: + type: policy.data.affinityProperties_properties + required: true +data_types: + policy.data.affinityProperties_properties: + derived_from: tosca.nodes.Root + properties: + qualifier: + type: string + constraints: + - valid_values: + - same + - different + category: + type: string + required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml new file mode 100644 index 000000000..060c4f97c --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml @@ -0,0 +1,56 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.DistancePolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + distanceProperties: + type: policy.data.distanceProperties_properties + required: true +data_types: + policy.data.distanceProperties_properties: + derived_from: tosca.nodes.Root + properties: + locationInfo: + type: string + required: true + distance: + type: policy.data.distance_properties + required: true + entry_schema: + type: policy.data.distance_properties + policy.data.distance_properties: + derived_from: tosca.nodes.Root + properties: + value: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - < + - <= + - '>' + - '>=' + - = + unit: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - km \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml new file mode 100644 index 000000000..d35552f10 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml @@ -0,0 +1,103 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.HpaPolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + flavorFeatures: + type: list + required: true + entry_schema: + type: policy.data.flavorFeatures_properties +data_types: + policy.data.flavorFeatures_properties: + derived_from: tosca.nodes.Root + properties: + id: + type: string + required: true + type: + type: string + required: true + directives: + type: list + required: true + entry_schema: + type: policy.data.directives_properties + flavorProperties: + type: list + required: true + entry_schema: + type: policy.data.flavorProperties_properties + policy.data.directives_properties: + derived_from: tosca.nodes.Root + properties: + type: + type: string + attributes: + type: list + entry_schema: + type: policy.data.directives_attributes_properties + policy.data.directives_attributes_properties: + derived_from: tosca.nodes.Root + properties: + attribute_name: + type: string + attribute_value: + type: string + policy.data.flavorProperties_properties: + derived_from: tosca.nodes.Root + properties: + hpa-feature: + type: string + required: true + mandatory: + type: string + required: true + score: + type: string + required: false + architecture: + type: string + required: true + hpa-version: + type: string + required: true + directives: + type: list + required: true + entry_schema: + type: policy.data.directives_properties + hpa-feature-attributes: + type: list + required: true + entry_schema: + type: policy.data.hpa-feature-attributes_properties + policy.data.hpa-feature-attributes_properties: + derived_from: tosca.nodes.Root + properties: + hpa-attribute-key: + type: string + required: true + hpa-attribute-value: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - < + - <= + - '>' + - '>=' + - = + - '!=' + - any + - all + - subset + unit: + type: string + required: false \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml new file mode 100644 index 000000000..abc329ccd --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml @@ -0,0 +1,66 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.OptimizationPolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + objective: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - minimize + - maximize + objectiveParameter: + type: policy.data.objectiveParameter_properties + required: true +data_types: + policy.data.objectiveParameter_properties: + derived_from: tosca.nodes.Root + properties: + parameterAttributes: + type: list + required: true + entry_schema: + type: policy.data.parameterAttributes_properties + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - '*' + - + + - '-' + - / + - '%' + policy.data.parameterAttributes_properties: + derived_from: tosca.nodes.Root + properties: + resources: + type: string + required: true + customerLocationInfo: + type: string + required: true + parameter: + type: string + required: true + weight: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - '*' + - + + - '-' + - / + - '%' \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml new file mode 100644 index 000000000..887e372df --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml @@ -0,0 +1,30 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.PciPolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + pciProperties: + type: list + required: false + entry_schema: + type: policy.data.pciProperties_properties +data_types: + policy.data.pciProperties_properties: + derived_from: tosca.nodes.Root + properties: + algoCategory: + type: string + required: false + pciOptmizationAlgoName: + type: string + required: false + pciOptimizationNwConstraint: + type: string + required: false + pciOptimizationPriority: + type: string + required: false + pciOptimizationTimeConstraint: + type: string + required: false \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml new file mode 100644 index 000000000..fd851248f --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml @@ -0,0 +1,28 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.Vim_fit: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + capacityProperties: + type: policy.data.capacityProperties_properties + required: true +data_types: + policy.data.capacityProperties_properties: + derived_from: tosca.nodes.Root + properties: + controller: + type: string + required: true + request: + type: string + required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml new file mode 100644 index 000000000..960ee15f4 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml @@ -0,0 +1,44 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.resource.VnfPolicy: + derived_from: onap.policies.optimization.Resource + version: 1.0.0 + properties: + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + vnfProperties: + type: list + required: true + entry_schema: + type: policy.data.vnfProperties_properties +data_types: + policy.data.vnfProperties_properties: + derived_from: tosca.nodes.Root + properties: + inventoryProvider: + type: string + required: true + serviceType: + type: string + required: true + inventoryType: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - serviceInstanceId + - vnfName + - cloudRegionId + - vimId + customerId: + type: string + required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml new file mode 100644 index 000000000..68c6636b4 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml @@ -0,0 +1,24 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.service.QueryPolicy: + derived_from: onap.policies.optimization.Service + version: 1.0.0 + properties: + queryProperties: + type: list + required: true + entry_schema: + type: policy.data.queryProperties_properties +data_types: + policy.data.queryProperties_properties: + derived_from: tosca.nodes.Root + properties: + attribute: + type: string + required: true + value: + type: string + required: true + attribute_location: + type: string + required: true \ No newline at end of file diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml new file mode 100644 index 000000000..b6327c87b --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml @@ -0,0 +1,28 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.optimization.service.SubscriberPolicy: + derived_from: onap.policies.optimization.Service + version: 1.0.0 + properties: + subscriberProperties: + type: policy.data.subscriberProperties_properties + required: true +data_types: + policy.data.subscriberProperties_properties: + derived_from: tosca.nodes.Root + properties: + subscriberName: + type: list + required: true + entry_schema: + type: string + subscriberRole: + type: list + required: true + entry_schema: + type: string + provStatus: + type: list + required: true + entry_schema: + type: string \ No newline at end of file diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java index 2ccf215c9..75f21d2f8 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java @@ -64,17 +64,17 @@ public class PolicyTypePersistenceTest { // @formatter:off private String[] policyTypeResourceNames = { "policytypes/onap.policies.controlloop.Operational.yaml", - "policytypes/onap.policies.optimization.DistancePolicy.yaml", - "policytypes/onap.policies.optimization.VnfPolicy.yaml", - "policytypes/onap.policies.optimization.PciPolicy.yaml", - "policytypes/onap.policies.optimization.OptimizationPolicy.yaml", + "policytypes/onap.policies.optimization.resource.DistancePolicy.yaml", + "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.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml", - "policytypes/onap.policies.optimization.HpaPolicy.yaml", - "policytypes/onap.policies.optimization.Vim_fit.yaml", - "policytypes/onap.policies.optimization.SubscriberPolicy.yaml", - "policytypes/onap.policies.optimization.AffinityPolicy.yaml", - "policytypes/onap.policies.optimization.QueryPolicy.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.coordination.FirstBlocksSecond.yaml", diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java index d9ffec566..f4f822c20 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java @@ -27,12 +27,10 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import com.google.gson.GsonBuilder; - import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.utils.coder.CoderException; @@ -59,17 +57,17 @@ public class ToscaPolicyTypeFilterTest { // @formatter:off private static final String[] policyTypeResourceNames = { "policytypes/onap.policies.controlloop.Operational.yaml", - "policytypes/onap.policies.optimization.DistancePolicy.yaml", - "policytypes/onap.policies.optimization.VnfPolicy.yaml", - "policytypes/onap.policies.optimization.PciPolicy.yaml", - "policytypes/onap.policies.optimization.OptimizationPolicy.yaml", + "policytypes/onap.policies.optimization.resource.DistancePolicy.yaml", + "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.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml", - "policytypes/onap.policies.optimization.HpaPolicy.yaml", - "policytypes/onap.policies.optimization.Vim_fit.yaml", - "policytypes/onap.policies.optimization.SubscriberPolicy.yaml", - "policytypes/onap.policies.optimization.AffinityPolicy.yaml", - "policytypes/onap.policies.optimization.QueryPolicy.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.coordination.FirstBlocksSecond.yaml", diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java index 9f9906930..e710faa31 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java @@ -44,7 +44,10 @@ public class OptimizationPolicyTypeSerializationTest { private static final String TYPE_ROOT = "tosca.policies.Root"; private static final String VERSION = "1.0.0"; - private static final String INPUT_YAML = "policytypes/onap.policies.Optimization.yaml"; + private static final String INPUT_OPTIMIZATION_YAML = "policytypes/onap.policies.Optimization.yaml"; + private static final String INPUT_OPTIMIZATION_RESOURCE_YAML = + "policytypes/onap.policies.optimization.Resource.yaml"; + private static final String INPUT_OPTIMIZATION_SERVICE_YAML = "policytypes/onap.policies.optimization.Service.yaml"; private StandardCoder coder; @@ -54,13 +57,39 @@ public class OptimizationPolicyTypeSerializationTest { } @Test - public void test() throws CoderException { - JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_YAML); - validate("initial object", svctmpl); + public void testOptimization() throws CoderException { + JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_YAML); + validate("initial object", svctmpl, TYPE_ROOT, "onap.policies.Optimization", false, false); String ser = serialize(svctmpl); JpaToscaServiceTemplate svctmpl2 = deserialize(ser); - validate("copy", svctmpl2); + validate("copy", svctmpl2, TYPE_ROOT, "onap.policies.Optimization", false, false); + + assertEquals(svctmpl, svctmpl2); + } + + @Test + public void testOptimizationResource() throws CoderException { + JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_RESOURCE_YAML); + validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Resource", true, + true); + + String ser = serialize(svctmpl); + JpaToscaServiceTemplate svctmpl2 = deserialize(ser); + validate("copy", svctmpl2, "onap.policies.Optimization", "onap.policies.optimization.Resource", true, true); + + assertEquals(svctmpl, svctmpl2); + } + + @Test + public void testOptimizationService() throws CoderException { + JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_SERVICE_YAML); + validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Service", false, + true); + + String ser = serialize(svctmpl); + JpaToscaServiceTemplate svctmpl2 = deserialize(ser); + validate("copy", svctmpl2, "onap.policies.Optimization", "onap.policies.optimization.Service", false, true); assertEquals(svctmpl, svctmpl2); } @@ -86,29 +115,32 @@ public class OptimizationPolicyTypeSerializationTest { return coder.encode(auth); } - private void validate(String testnm, JpaToscaServiceTemplate svctmpl) { + private void validate(String testnm, JpaToscaServiceTemplate svctmpl, String derivedFrom, + String typeName, boolean checkResource, boolean checkService) { JpaToscaPolicyTypes policyTypes = svctmpl.getPolicyTypes(); assertEquals(testnm + " type count", 1, policyTypes.getConceptMap().size()); JpaToscaPolicyType policyType = policyTypes.getConceptMap().values().iterator().next(); - assertEquals(testnm + " name", "onap.policies.Optimization", policyType.getName()); + assertEquals(testnm + " name", typeName, policyType.getName()); assertEquals(testnm + " version", VERSION, policyType.getVersion()); assertNotNull(testnm + " derived from", policyType.getDerivedFrom()); - assertEquals(testnm + " derived from name", TYPE_ROOT, policyType.getDerivedFrom().getName()); - - assertEquals(testnm + " description", "The base policy type for all policies that govern optimization", - policyType.getDescription()); + assertEquals(testnm + " derived from name", derivedFrom, policyType.getDerivedFrom().getName()); Map props = policyType.getProperties(); assertNotNull(testnm + " properties", props); - validateScope(testnm, props.get("scope")); - validateServices(testnm, props.get("services")); - validateResources(testnm, props.get("resources")); - validateGeography(testnm, props.get("geography")); - validateIdentity(testnm, props.get("identity")); + if (checkResource && checkService) { + validateResources(testnm, props.get("resources")); + validateServices(testnm, props.get("services")); + } else if (checkService && !checkResource) { + validateServices(testnm, props.get("services")); + } else { + validateScope(testnm, props.get("scope")); + validateGeography(testnm, props.get("geography")); + validateIdentity(testnm, props.get("identity")); + } } // only need to validate deep match of one of these; geography is the most interesting -- cgit 1.2.3-korg