summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-03-02 15:26:22 -0600
committerjhh <jorge.hernandez-herrero@att.com>2020-03-03 09:12:42 -0600
commit53b503a4986cc5733e10d4ac05238fe3c20aa73d (patch)
tree197a9f8855c8c68361d129ccfe14a85be67ad248 /feature-lifecycle/src/main/java
parent300e6ff3003823e6efeaef73a48fa9b3234ca8a0 (diff)
Undeploy support for drools policies.
Issue-ID: POLICY-2388 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I4c5ed6752a32c9c2391cf03dd56cb2f1abc32dfd Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main/java')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
index 2d9ca514..1b5e7c47 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
@@ -23,10 +23,16 @@ package org.onap.policy.drools.lifecycle;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
+import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PolicyTypeNativeController implements PolicyTypeController {
+ private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeController.class);
@Getter
protected final ToscaPolicyTypeIdentifier policyType;
@@ -48,7 +54,13 @@ public class PolicyTypeNativeController implements PolicyTypeController {
@Override
public boolean undeploy(ToscaPolicy policy) {
- // TODO
- return true;
+ try {
+ ControllerPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
+ PolicyControllerConstants.getFactory().destroy(nativePolicy.getProperties().getControllerName());
+ return true;
+ } catch (RuntimeException | CoderException e) {
+ logger.warn("failed undeploy of policy: {}", policy);
+ return false;
+ }
}
}