From ab3eab60a0883ffa22eb12e2b8680088c9ad25a1 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 16 Apr 2020 12:09:24 +0200 Subject: Remove policy from PEF when removing op policy The operational policy must be removed from the PEF when the user remove an operational policy (at least attempt to purge the PEF) Issue-ID: CLAMP-824 Signed-off-by: sebdet Change-Id: I442c0890c391d43e8fcbdb89189d6ad2581db3af --- src/main/java/org/onap/clamp/loop/Loop.java | 30 + .../java/org/onap/clamp/loop/LoopController.java | 4 +- src/main/java/org/onap/clamp/loop/LoopService.java | 2 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 18 +- .../resources/clds/camel/routes/policy-flows.xml | 1076 +++++++++++--------- ui-react/src/api/LoopService.js | 4 +- .../src/components/dialogs/Loop/ModifyLoopModal.js | 14 +- 7 files changed, 628 insertions(+), 520 deletions(-) diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 19a17dbb0..081331337 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -330,6 +330,36 @@ public class Loop extends AuditEntity implements Serializable { } } + /** + * Return the operationalPolicy object with the opPolicyName. + * + * @param opPolicyName The operationalPolicy name + * @return The OperationalPolicy object found in loop object + */ + public OperationalPolicy getOperationalPolicy(String opPolicyName) { + for (OperationalPolicy operationalPolicy : this.getOperationalPolicies()) { + if (operationalPolicy.getName().equals(opPolicyName)) { + return operationalPolicy; + } + } + return null; + } + + /** + * Return the microServicePolicy object with the msPolicyName. + * + * @param msPolicyName The microServicePolicy name + * @return The MicroServicePolicy object found in loop object + */ + public MicroServicePolicy getMicroServicePolicy(String msPolicyName) { + for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) { + if (microServicePolicy.getName().equals(msPolicyName)) { + return microServicePolicy; + } + } + return null; + } + /** * Generate the loop name. * diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index a2a44631b..fad93bc7d 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -137,11 +137,11 @@ public class LoopController { } /** - * This method remove an operational policy to a loop instance. + * This method removes an operational policy from a loop instance. * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ public Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index 6658c5a30..ca3681b62 100644 --- a/src/main/java/org/onap/clamp/loop/LoopService.java +++ b/src/main/java/org/onap/clamp/loop/LoopService.java @@ -131,7 +131,7 @@ public class LoopService { * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 770626755..fc7dbd492 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -770,15 +770,29 @@ - + - + + + ${header.policyName} + + + ${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)} + + + false + + + + false + + - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - ${exchangeProperty[policyComponent].computeState(*)} - - + + + + false + + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + false + + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + ${exchangeProperty[policyComponent].computeState(*)} + + - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET - Policy status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET + Policy status + + + + POLICY + + + + + - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET Policy deployment - status - - - - POLICY - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - - - - - - - - ${exchangeProperty[policy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policy].getName()} creation - status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET Policy deployment + status + + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + ${exchangeProperty[policy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - ${exchangeProperty[policy].isLegacy()} == true - - 1 - - - - - 1.0.0 - - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + ${exchangeProperty[policy].isLegacy()} == true + + 1 + + + + + 1.0.0 + + + + + - - - - - ${exchangeProperty[policy].getName()} removal - status - - - - POLICY - - - - - - - - - - - - ${exchangeProperty[guardPolicy].getValue()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[guardPolicy].getKey()} creation status - - - - POLICY - - - - - + + + + + ${exchangeProperty[policy].getName()} removal + status + + + + POLICY + + + + + + + + + + + + ${exchangeProperty[guardPolicy].getValue()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[guardPolicy].getKey()} creation status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - ${exchangeProperty[guardPolicy].getKey()} removal status - - - - POLICY - - - - - + + + + + ${exchangeProperty[guardPolicy].getKey()} removal status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group push ALL status - - - POLICY - - - - - + + + + + PDP Group push ALL status + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group remove ALL status - - - POLICY - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - - - + + + + + PDP Group remove ALL status + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + ${exchangeProperty[policyName]} PDP Group removal status + + + + POLICY + + + + java.lang.Exception + + false + + + PDP Group removal, Error reported: ${exception} + + + POLICY + + + + + + + + + \ No newline at end of file diff --git a/ui-react/src/api/LoopService.js b/ui-react/src/api/LoopService.js index 698ee28c2..f10d187cb 100644 --- a/ui-react/src/api/LoopService.js +++ b/ui-react/src/api/LoopService.js @@ -240,8 +240,8 @@ export default class LoopService { }); } - static removeOperationalPolicyType(loopName, policyType, policyVersion) { - return fetch('/restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion , { + static removeOperationalPolicyType(loopName, policyType, policyVersion, policyName) { + return fetch('/restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion + '/' + policyName , { method: 'PUT', headers: { "Content-Type": "application/json" diff --git a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js index 1802e43de..11e935338 100644 --- a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js @@ -78,6 +78,10 @@ export default class ModifyLoopModal extends React.Component { cellStyle: cellStyle, headerStyle: headerStyle }, + { title: "Policy Name", field: "policyName", + cellStyle: cellStyle, + headerStyle: headerStyle + }, { title: "Version", field: "version", cellStyle: cellStyle, headerStyle: headerStyle @@ -90,7 +94,7 @@ export default class ModifyLoopModal extends React.Component { cellStyle: cellStyle, headerStyle: headerStyle }, - { title: "Add", field: "updatedDate", editable: 'never', + { title: "Created Date", field: "createdDate", editable: 'never', cellStyle: cellStyle, headerStyle: headerStyle } @@ -128,7 +132,9 @@ export default class ModifyLoopModal extends React.Component { var operationalPolicies = this.state.loopCache.getOperationalPolicies(); var selectedPolicyModels = []; for (var policy in operationalPolicies) { - selectedPolicyModels.push(operationalPolicies[policy]["policyModel"]); + var newRow = operationalPolicies[policy]["policyModel"]; + newRow.add("policyName", operationalPolicies[policy].name); + selectedPolicyModels.push(newRow); } PolicyToscaService.getToscaPolicyModels().then(allToscaModels => { @@ -167,7 +173,7 @@ export default class ModifyLoopModal extends React.Component { } handleRemove() { - LoopService.removeOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version); + LoopService.removeOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version,this.state.selectedRowData.policyName); this.props.loadLoopFunction(this.state.loopCache.getLoopName()); this.handleClose(); } @@ -203,7 +209,7 @@ export default class ModifyLoopModal extends React.Component {