From 53b503a4986cc5733e10d4ac05238fe3c20aa73d Mon Sep 17 00:00:00 2001 From: jhh Date: Mon, 2 Mar 2020 15:26:22 -0600 Subject: Undeploy support for drools policies. Issue-ID: POLICY-2388 Signed-off-by: jhh Change-Id: I4c5ed6752a32c9c2391cf03dd56cb2f1abc32dfd Signed-off-by: jhh --- .../drools/lifecycle/PolicyTypeNativeController.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'feature-lifecycle/src/main/java') 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; + } } } -- cgit 1.2.3-korg