summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2019-04-09 14:24:34 -0500
committerjhh <jorge.hernandez-herrero@att.com>2019-04-09 14:30:01 -0500
commit712274e8d332181729c06c31dcf58d49f2a4d8f7 (patch)
treea684200d82ada2fe062e1f8f1071130f6bec77d5 /feature-lifecycle/src/main
parent3f90dba2636b06bcb90b8f1e158b30886af574d5 (diff)
deploy and undeploy as audits.
Change-Id: Iea1766d5d8075394e1dccc109f4477bd2c270c36 Issue-ID: POLICY-1624 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java4
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java8
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java11
3 files changed, 18 insertions, 5 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index b99953ed..97f3574e 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -283,6 +283,10 @@ public class LifecycleFsm implements Startable {
policiesMap.put(policy.getIdentifier(), policy);
}
+ protected void undeployedPolicyAction(@NonNull ToscaPolicy policy) {
+ policiesMap.remove(policy.getIdentifier());
+ }
+
/* ** Action Helpers ** */
private boolean startIo() {
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
index d481b8bd..38ea0917 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
@@ -61,8 +61,6 @@ public class LifecycleStateActive extends LifecycleStateRunning {
protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: deploy {} into {}", this, policy.getIdentifier(), controller.getName());
- // TODO: This is the latest version - retract policy with same id but different version
-
if (!controller.offer(policy)) {
return false;
}
@@ -75,8 +73,12 @@ public class LifecycleStateActive extends LifecycleStateRunning {
protected boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: undeploy {} from {}", this, policy.getIdentifier(), controller.getName());
- // TODO: retract policy.
+ if (!controller.getDrools().delete(policy)) {
+ logger.warn("Policy {}:{}:{}:{} was not deployed.",
+ policy.getType(), policy.getTypeVersion(), policy.getName(), policy.getVersion());
+ }
+ fsm.undeployedPolicyAction(policy);
return true;
}
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index 405dbeba..ed200ea6 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -134,8 +134,15 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return true;
}
- boolean success = deployPolicies(policies);
- return undeployPolicies(policies) && success;
+ // Note that PAP sends the list of all ACTIVE policies with every
+ // UPDATE message. First, we will undeploy all policies that are
+ // running but are not present in this list. This will include
+ // policies that are overridden by a different version. Second,
+ // we will deploy those policies that are not installed but
+ // resent in this list.
+
+ boolean success = undeployPolicies(policies);
+ return deployPolicies(policies) && success;
}
protected boolean deployPolicies(List<ToscaPolicy> policies) {