aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2022-10-31 11:31:50 -0500
committerJorge Hernandez <jorge.hernandez-herrero@att.com>2022-11-02 13:52:10 +0000
commit409ce4e33af338c36f97aa1b529ef7d38741b035 (patch)
tree4230dc6563f73ab1d33d55710a3fa43220ed82d6
parentbc039f47bab7041e7475915fbf90a81e0d22f8d0 (diff)
Support usage for SON policy/models templates.
Issue-ID: POLICY-4427 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I22706cdbd45c49946435aff15bc5ec5f7408296b (cherry picked from commit 427669c39ca10bf2d1343d7f5dc2c39ad9ca3b23)
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java
index 09eb58d5a..111f00800 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 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.
@@ -232,6 +232,16 @@ public class Rules {
throw new CoderException(new FileNotFoundException(policyPath));
}
+ if (policyPath.startsWith("policies/")) {
+ // using policy/models examples where policies are wrapped with the ToscaServiceTemplate
+ // for API component provisioning
+ logger.info("retrieving policy from policy models examples");
+ ToscaServiceTemplate template = coder.decode(policyJson, ToscaServiceTemplate.class);
+ if (template.getToscaTopologyTemplate().getPolicies().size() == 1) {
+ return template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
+ }
+ }
+
return coder.decode(policyJson, ToscaPolicy.class);
}