summaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2019-04-25 07:45:29 -0500
committerjhh <jorge.hernandez-herrero@att.com>2019-04-25 22:26:45 -0500
commite32d0fac919c8cc5657496a16c300877bd29621e (patch)
tree43c9ba1b8aa16dab7c809639d9e56a681ebd928b /controlloop/templates
parenta91076ff372a49d080b78b3608bb0d7d26055741 (diff)
Match up ControlLoopParams against ToscaPolicy
Change-Id: Ia23a5b90b452bcafe2a8aa660598697ebfb07431 Issue-ID: POLICY-1691 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl35
1 files changed, 27 insertions, 8 deletions
diff --git a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 8dcc79866..3f2bf572c 100644
--- a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -33,6 +33,7 @@ import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NewEventStatus;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
+import org.onap.policy.controlloop.utils.ControlLoopUtils;
import org.onap.policy.controlloop.actor.so.SoActorServiceProvider;
import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.appc.Request;
@@ -101,9 +102,6 @@ rule "INSERT.PARAMS"
$params : ControlLoopParams()
then
- // Note: globals have bad behavior when persistence is used,
- // hence explicitly getting the logger vs using a global
-
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "."
+ drools.getRule().getName(), $params.getControlLoopYaml());
@@ -111,18 +109,39 @@ end
/*
*
-* Called when a Tosca Policy fact is present.
+* Called when a Tosca Policy is present.
*
*/
-rule "NEW TOSCA POLICY"
+rule "NEW.TOSCA.POLICY"
when
$policy : ToscaPolicy()
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}:{}: [{}|{}|{}|{}]: CONTENT: {}", drools.getRule().getName(),
- $policy.getType(), $policy.getTypeVersion(), $policy.getName(), $policy.getVersion(),
- $policy);
+ logger.info("{}: [{}|{}|{}|{}]: CONTENT: {}", drools.getRule().getName(),
+ $policy.getType(), $policy.getTypeVersion(), $policy.getName(),
+ $policy.getVersion(), $policy);
+
+ ControlLoopParams params = ControlLoopUtils.toControlLoopParams($policy);
+ if (params != null) {
+ insert(params);
+ }
+end
+
+/*
+ * Remove Control Loop Parameters.
+ */
+rule "REMOVE.PARAMS"
+ when
+ $params : ControlLoopParams( $policyName : getPolicyName(), $policyVersion : getPolicyVersion() )
+ not ( ToscaPolicy( getName() == $policyName, getVersion() == $policyVersion ) )
+ then
+
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ logger.info("{}: [{}|{}|{}]", drools.getRule().getName(),
+ $params.getPolicyScope(), $params.getPolicyName(), $params.getPolicyVersion());
+
+ retract($params);
end
/*