diff options
88 files changed, 242 insertions, 1748 deletions
diff --git a/models-examples/src/main/resources/policies/sdnc.policy.naming.input.tosca.yaml b/models-examples/src/main/resources/policies/sdnc.policy.naming.input.tosca.yaml index f17e9096b..77c5a0cf0 100644 --- a/models-examples/src/main/resources/policies/sdnc.policy.naming.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/sdnc.policy.naming.input.tosca.yaml @@ -1,4 +1,4 @@ -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: diff --git a/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.json b/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.json index 929e29efa..406d12e13 100644 --- a/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.json +++ b/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.yaml b/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.yaml index f893158b8..d4969eb44 100644 --- a/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vCPE.policies.optimization.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json index eb0dec43d..5690a7b20 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json +++ b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.yaml b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.yaml index 7f01101c3..44533e5fd 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.output.tosca.yaml b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.output.tosca.yaml index a8a1cdac1..eae1cd4dc 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.monitoring.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vCPE.policy.monitoring.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.json b/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.json index 11db9cf59..305756064 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.json +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.yaml b/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.yaml index 27d020240..b1c51ca8e 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - operational.restart: diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.json b/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.json index aeac3093d..c57103eb5 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.json +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.yaml b/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.yaml index 2c7981a29..3381c4b10 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.json b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.json deleted file mode 100644 index db84a4eaa..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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" - } -} diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.json b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.json deleted file mode 100644 index 9da85c412..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "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" - } - } - } - ] - } -} diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.yaml deleted file mode 100644 index efab1d0df..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.input.tosca.yaml +++ /dev/null @@ -1,19 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.json b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.json deleted file mode 100644 index f8b6ac59c..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.tosca.yaml deleted file mode 100644 index c50b17829..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequency.output.tosca.yaml +++ /dev/null @@ -1,20 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml new file mode 100644 index 000000000..964e1811c --- /dev/null +++ b/models-examples/src/main/resources/policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml @@ -0,0 +1,17 @@ +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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.json b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.json deleted file mode 100644 index f402b5d8a..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.tosca.yaml deleted file mode 100644 index a56917ebe..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.input.tosca.yaml +++ /dev/null @@ -1,18 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.json b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.json deleted file mode 100644 index 778ea5447..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.tosca.yaml deleted file mode 100644 index 97282a6f2..000000000 --- a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmax.output.tosca.yaml +++ /dev/null @@ -1,19 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml new file mode 100644 index 000000000..dafc524b5 --- /dev/null +++ b/models-examples/src/main/resources/policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml @@ -0,0 +1,16 @@ +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 diff --git a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.json b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.json index bb31f4b2c..e5d074163 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.json +++ b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": diff --git a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.yaml index d8e37da00..09a491584 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.output.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.output.tosca.yaml index 669e8946c..963e193d3 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.monitoring.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vDNS.policy.monitoring.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.json b/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.json index 8205fc89e..bb90bbd43 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.json +++ b/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.yaml index 0859ba898..bb12c951a 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - operational.scaleout: diff --git a/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.json b/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.json index 8205fc89e..bb90bbd43 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.json +++ b/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.yaml index 84d7efb0c..9da4b93ba 100644 --- a/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vDNS.policy.operational.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - operational.scaleout: diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.json b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.json index b247672eb..ae8623dca 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.json +++ b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml index 59fcf999d..20afb111b 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.output.tosca.yaml b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.output.tosca.yaml index eb3165f6e..750a84ca0 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vFirewall.policy.monitoring.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.json b/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.json index 171694028..2d7f1c958 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.json +++ b/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.json @@ -1,5 +1,5 @@ { - "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "topology_template": { "policies": [ { diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.yaml b/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.yaml index 468946520..061d3cca1 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vFirewall.policy.operational.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - operational.modifyconfig: diff --git a/models-examples/src/main/resources/policies/vFirewall.policy.operational.output.tosca.yaml b/models-examples/src/main/resources/policies/vFirewall.policy.operational.output.tosca.yaml index 555d84bee..923bc7d75 100644 --- a/models-examples/src/main/resources/policies/vFirewall.policy.operational.output.tosca.yaml +++ b/models-examples/src/main/resources/policies/vFirewall.policy.operational.output.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - diff --git a/models-examples/src/main/resources/policies/vFirewallCDS.policy.operational.input.tosca.yaml b/models-examples/src/main/resources/policies/vFirewallCDS.policy.operational.input.tosca.yaml index 01da34093..617354327 100644 --- a/models-examples/src/main/resources/policies/vFirewallCDS.policy.operational.input.tosca.yaml +++ b/models-examples/src/main/resources/policies/vFirewallCDS.policy.operational.input.tosca.yaml @@ -1,4 +1,4 @@ -tosca_definitions_version: tosca_simple_yaml_1_0_0 +tosca_definitions_version: tosca_simple_yaml_1_1_0 topology_template: policies: - operational.modifyconfig.cds: diff --git a/models-examples/src/main/resources/policytypes/onap.policies.Naming.yaml b/models-examples/src/main/resources/policytypes/onap.policies.Naming.yaml index c30cefe21..a4361cfb8 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.Naming.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.Naming.yaml @@ -1,4 +1,4 @@ -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 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 2cd391ff0..9d91685e3 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.Operational.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.Operational.yaml index 773e0c90b..391abb4d9 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.Operational.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.Operational.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Blacklist.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Blacklist.yaml deleted file mode 100644 index 91a825212..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Blacklist.yaml +++ /dev/null @@ -1,40 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Common.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Common.yaml new file mode 100644 index 000000000..b26287939 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.Common.yaml @@ -0,0 +1,26 @@ +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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml deleted file mode 100644 index 45e5471fc..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml +++ /dev/null @@ -1,50 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.MinMax.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.MinMax.yaml deleted file mode 100644 index 54c4204e2..000000000 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.MinMax.yaml +++ /dev/null @@ -1,44 +0,0 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml new file mode 100644 index 000000000..058066c04 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml @@ -0,0 +1,14 @@ +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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml new file mode 100644 index 000000000..af8efe851 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter.yaml @@ -0,0 +1,23 @@ +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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml new file mode 100644 index 000000000..257515179 --- /dev/null +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.common.MinMax.yaml @@ -0,0 +1,16 @@ +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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml index 35a515611..936cc6535 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.Common.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.Common.yaml index 4a918bef1..4f3723b0b 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.Common.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.Common.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml index 9c6c6120d..5303f5639 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Apex.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml index 2d793cc4b..acdecc29c 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml index dc16da224..3c17c9004 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml @@ -1,4 +1,4 @@ -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 @@ -11,6 +11,7 @@ policy_types: 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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml index 8419b096f..98bba9eae 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.native.Apex.yaml b/models-examples/src/main/resources/policytypes/onap.policies.native.Apex.yaml index 8c780f64a..75533ed61 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.native.Apex.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.native.Apex.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml b/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml index 8416e85bc..38b18cf32 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.native.Drools.yaml @@ -1,4 +1,4 @@ -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 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.native.Xacml.yaml b/models-examples/src/main/resources/policytypes/onap.policies.native.Xacml.yaml index 3e4a27e63..415735df3 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.native.Xacml.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.native.Xacml.yaml @@ -1,4 +1,4 @@ -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 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 index 1d8135162..3aaa6075c 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml @@ -1,4 +1,4 @@ -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 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 index 8e7b724da..67f7dd6e2 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml @@ -1,4 +1,4 @@ -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 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 index 173691f21..3fb8525f7 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index 060c4f97c..196ba9e31 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index d35552f10..0c8283380 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index abc329ccd..fae050b46 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index 887e372df..021cff966 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index fd851248f..6ba2ae18c 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index 960ee15f4..1c7d3b666 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index 68c6636b4..2a615abad 100644 --- 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 @@ -1,4 +1,4 @@ -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 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 index f45ee8162..60da74286 100644 --- 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 @@ -1,4 +1,4 @@ -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 diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java index 767a0fb6f..a8fc4ed73 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java @@ -22,7 +22,6 @@ package org.onap.policy.models.provider; 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; @@ -35,8 +34,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; 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; /** @@ -239,48 +236,6 @@ public interface PolicyModelsProvider extends AutoCloseable { @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. * * @param name the name of the policy to get, null to get all PDP groups diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index 3cae650a3..195b88247 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -24,7 +24,6 @@ package org.onap.policy.models.provider.impl; 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; @@ -55,8 +54,6 @@ 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.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; @@ -280,38 +277,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { } @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(); return new PdpProvider().getPdpGroups(pfDao, name); diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java index c09c6c233..aece188f9 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java @@ -23,9 +23,7 @@ package org.onap.policy.models.provider.impl; 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; @@ -45,8 +43,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; 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; /** @@ -171,30 +167,6 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @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<>(); } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java index f085605f8..388b6ad98 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java @@ -49,7 +49,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; 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; /** @@ -229,38 +228,6 @@ public class DatabasePolicyModelsProviderTest { }).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); @@ -422,26 +389,6 @@ public class DatabasePolicyModelsProviderTest { 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()); diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java index 73940a6b3..80680c1fd 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java @@ -25,7 +25,6 @@ import java.util.ArrayList; 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; @@ -41,8 +40,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; 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; /** @@ -132,30 +129,6 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @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(); } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java index 3212428ae..2e2e3daa6 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java @@ -40,7 +40,6 @@ import org.onap.policy.models.provider.PolicyModelsProviderParameters; 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; /** @@ -103,11 +102,6 @@ public class DummyPolicyModelsProviderTest { 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()); diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java deleted file mode 100644 index ecb50cdc3..000000000 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyGuardPersistenceTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============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); - } - } -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyContent.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyContent.java deleted file mode 100644 index 91ff150fc..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyContent.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============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); - } - } -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyInput.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyInput.java deleted file mode 100644 index 819fcba75..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyInput.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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; - -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyOutput.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyOutput.java deleted file mode 100644 index 2fe3d88e4..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyOutput.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============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; -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java deleted file mode 100644 index b7ebdcec3..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============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; - } -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java index 41792aeb9..de1bc12d7 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java @@ -71,7 +71,7 @@ public class LegacyOperationalPolicyMapper 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()); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java index dc8affc77..314c7728d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java @@ -22,7 +22,6 @@ package org.onap.policy.models.tosca.legacy.provider; import java.util.List; -import java.util.Map; import javax.ws.rs.core.Response; @@ -32,10 +31,7 @@ import org.onap.policy.models.base.PfConceptKey; 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; @@ -152,99 +148,6 @@ public class LegacyProvider { } /** - * 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. * * @param dao The DAO to search diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java index aa4f231c0..e2e27f0e2 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java @@ -73,7 +73,7 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp 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"; diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java index 858ac09fe..9ee3ec8bb 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java @@ -21,6 +21,7 @@ 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; @@ -62,12 +63,11 @@ public class ToscaPolicyFilterTest { "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", @@ -151,22 +151,67 @@ public class ToscaPolicyFilterTest { 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 @@ -177,7 +222,7 @@ public class ToscaPolicyFilterTest { 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); @@ -193,7 +238,7 @@ public class ToscaPolicyFilterTest { filter = ToscaPolicyFilter.builder().name("operational.modifyconfig").version(VERSION_100).build(); filteredList = filter.filter(policyList); - assertEquals(0, filteredList.size()); + assertEquals(1, filteredList.size()); } @Test @@ -201,11 +246,11 @@ public class ToscaPolicyFilterTest { // 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); @@ -236,7 +281,7 @@ public class ToscaPolicyFilterTest { 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(); 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 0f038d3cd..6304091af 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 @@ -63,15 +63,15 @@ public class ToscaPolicyTypeFilterTest { "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" @@ -149,8 +149,16 @@ public class ToscaPolicyTypeFilterTest { 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); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java deleted file mode 100644 index e06692ab0..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============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"); - } -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/testconcepts/DummyBadLegacyGuardPolicyContent.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/testconcepts/DummyBadLegacyGuardPolicyContent.java deleted file mode 100644 index 1b149416c..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/testconcepts/DummyBadLegacyGuardPolicyContent.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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"; -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapperTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapperTest.java deleted file mode 100644 index 332552a73..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapperTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============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()); - } -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java deleted file mode 100644 index 047ef4891..000000000 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java +++ /dev/null @@ -1,388 +0,0 @@ -/*- - * ============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); - } -} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java index 500ba9fa2..318eaeede 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java @@ -57,7 +57,7 @@ public class MonitoringPolicySerializationTest { 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"; diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java index ef4123084..bf2030bd4 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java @@ -145,7 +145,7 @@ public class MonitoringPolicyTypeSerializationTest { 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(); @@ -362,7 +362,7 @@ public class MonitoringPolicyTypeSerializationTest { 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(); diff --git a/models-tosca/src/test/resources/onap.policies.NoVersion.yaml b/models-tosca/src/test/resources/onap.policies.NoVersion.yaml index 2dda556a6..c8562dad0 100644 --- a/models-tosca/src/test/resources/onap.policies.NoVersion.yaml +++ b/models-tosca/src/test/resources/onap.policies.NoVersion.yaml @@ -1,4 +1,4 @@ -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 |