diff options
10 files changed, 58 insertions, 21 deletions
diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.input.json b/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.input.json index 7d26e8e67..1ae033ac2 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.input.json +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.input.json @@ -1,5 +1,6 @@ { "policy-id" : "operational.restart", "policy-version" : "1", - "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard" + "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard", + "controllerName" : "usecases" }
\ No newline at end of file diff --git a/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.output.json b/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.output.json index 7d26e8e67..1ae033ac2 100644 --- a/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.output.json +++ b/models-examples/src/main/resources/policies/vCPE.policy.operational.legacy.output.json @@ -1,5 +1,6 @@ { "policy-id" : "operational.restart", "policy-version" : "1", - "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard" + "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard", + "controllerName" : "usecases" }
\ No newline at end of file diff --git a/models-examples/src/main/resources/policies/vDNS.policy.guard.blacklist.input.tosca.yaml b/models-examples/src/main/resources/policies/vDNS.policy.guard.blacklist.input.tosca.yaml new file mode 100644 index 000000000..78a2de6b3 --- /dev/null +++ b/models-examples/src/main/resources/policies/vDNS.policy.guard.blacklist.input.tosca.yaml @@ -0,0 +1,15 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - guard.blacklist.scaleout: + type: onap.policies.controlloop.guard.common.Blacklist + type_version: 1.0.0 + version: 1.0.0 + metadata: + policy-id: guard.blacklist.scaleout + properties: + actor: SO + operation: VF Module Create + id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + blacklist: + - the-vfmodule-where-root-is-true
\ No newline at end of file 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 index dafc524b5..4c3afb745 100644 --- 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 @@ -1,16 +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 + 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 + target: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e + min: 1 + max: 2
\ 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 index 058066c04..0456f43cb 100644 --- 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 @@ -8,7 +8,7 @@ policy_types: properties: blacklist: type: list - description: List of entity id's + description: List of entity id's not allowed to have control loop operations on. 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 index af8efe851..bda3e4cc5 100644 --- 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 @@ -13,6 +13,7 @@ policy_types: timeUnits: type: string description: The units of time the window is counting. + required: true constraints: - valid_values: ["second", "minute", "hour", "day", "week", "month", "year"] limit: 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 index 257515179..fb376d432 100644 --- 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 @@ -4,11 +4,17 @@ policy_types: 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 + description: | + Supports Min/Max number of entity for scaling operations. Although min and max fields are marked as not + required, you need to have at least one or the other. properties: + target: + type: string + required: true + description: The target entity that has scaling restricted min: type: integer - required: true + required: false description: The minimum instances of this entity max: type: integer diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java index 70453da76..a87fab1e0 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 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. @@ -42,5 +42,6 @@ public class LegacyOperationalPolicy { private String policyVersion; private String content; + private String controllerName; }
\ No newline at end of file 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 de1bc12d7..881a5fadd 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2020 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. @@ -47,6 +48,7 @@ public class LegacyOperationalPolicyMapper // Property name for the operational policy content private static final String CONTENT_PROPERTY = "content"; + private static final String CONTROLLER_PROPERTY = "controllerName"; private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicyMapper.class); @@ -69,6 +71,9 @@ public class LegacyOperationalPolicyMapper final Map<String, String> propertyMap = new HashMap<>(); toscaPolicy.setProperties(propertyMap); toscaPolicy.getProperties().put(CONTENT_PROPERTY, legacyOperationalPolicy.getContent()); + if (legacyOperationalPolicy.getControllerName() != null) { + toscaPolicy.getProperties().put(CONTROLLER_PROPERTY, legacyOperationalPolicy.getControllerName()); + } final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_1_0"); @@ -115,6 +120,11 @@ public class LegacyOperationalPolicyMapper legacyOperationalPolicy.setContent(content); + String controllerName = toscaPolicy.getProperties().get(CONTROLLER_PROPERTY); + if (controllerName != null) { + legacyOperationalPolicy.setControllerName(controllerName); + } + return legacyOperationalPolicy; } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java index 36cea6372..43ad191cc 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 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. @@ -39,6 +39,8 @@ public class LegacyOperationalPolicyTest { assertEquals("1", policy.getPolicyVersion()); policy.setContent("controlLoop%3A%0A%20%20"); assertTrue(policy.getContent().length() > 0); + policy.setControllerName("blah"); + assertEquals("blah", policy.getControllerName()); } } |