From 22bda27545153fd0b1a8f6609867699b3ee23a75 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 8 Aug 2018 14:15:36 +0200 Subject: Add support for ScaleOut Support Scaleout in Clamp UI + rework the Backend to support more configurable fields of operational policy. Issue-ID: CLAMP-201 Change-Id: I87dceeecfb4145bf4a0357daefd279729609e21d Signed-off-by: Determe, Sebastien (sd378r) --- .../client/req/policy/OperationalPolicyReq.java | 40 ++++------ .../onap/clamp/clds/model/properties/Policy.java | 6 +- .../clamp/clds/model/properties/PolicyChain.java | 31 ++++---- .../clamp/clds/model/properties/PolicyItem.java | 28 ++++--- .../portfolios/PolicyWindow_properties.html | 93 +++++++++++++++------- .../resources/clds/templates/globalProperties.json | 25 +++--- .../policy/modelBpmnProperties.json | 28 +++++++ 7 files changed, 160 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java index 2ebab88b..f062dfca 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java @@ -19,7 +19,7 @@ * ============LICENSE_END============================================ * Modifications copyright (c) 2018 Nokia * =================================================================== - * + * */ package org.onap.clamp.clds.client.req.policy; @@ -77,7 +77,7 @@ public class OperationalPolicyReq { * @throws UnsupportedEncodingException */ public static Map> formatAttributes(ClampProperties refProp, - ModelProperties prop, String modelElementId, PolicyChain policyChain) + ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { Global global = prop.getGlobal(); prop.setCurrentModelElementId(modelElementId); @@ -130,7 +130,7 @@ public class OperationalPolicyReq { /** * Format Operational OpenLoop Policy yaml. - * + * * @param refProp * @param prop * @param modelElementId @@ -140,7 +140,7 @@ public class OperationalPolicyReq { * @throws UnsupportedEncodingException */ protected static String formatOpenLoopYaml(ClampProperties refProp, ModelProperties prop, String modelElementId, - PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects Global global = prop.getGlobal(); prop.setCurrentModelElementId(modelElementId); @@ -150,7 +150,7 @@ public class OperationalPolicyReq { Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); // create builder ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), - policyChain.getTimeout(), service, vfResources); + policyChain.getTimeout(), service, vfResources); // builder.setTriggerPolicy(refProp.getStringValue("op.openloop.policy")); // Build the specification Results results = builder.buildSpecification(); @@ -170,7 +170,7 @@ public class OperationalPolicyReq { * @throws UnsupportedEncodingException */ protected static String formatYaml(ClampProperties refProp, ModelProperties prop, String modelElementId, - PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects Global global = prop.getGlobal(); prop.setCurrentModelElementId(modelElementId); @@ -181,7 +181,7 @@ public class OperationalPolicyReq { Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); // create builder ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), - policyChain.getTimeout(), service, vfResources); + policyChain.getTimeout(), service, vfResources); builder.addResource(vfcResources); // process each policy Map policyObjMap = new HashMap<>(); @@ -195,31 +195,21 @@ public class OperationalPolicyReq { target.setType(TargetType.valueOf(policyItem.getRecipeLevel())); } target.setResourceID(policyItem.getTargetResourceId()); - String actor = refProp.getStringValue("op.policy.appc"); - Map payloadMap = null; - if ("health-diagnostic".equalsIgnoreCase(policyItem.getRecipe())) { - actor = refProp.getStringValue("op.policy.sdno"); - payloadMap = new HashMap(); - payloadMap.put("ttl", policyItem.getRecipePayload()); - } - // For reboot recipe we have to send type as SOFT/HARD in pay load - if (policyItem.getRecipeInfo() != null && !policyItem.getRecipeInfo().isEmpty()) { - payloadMap = new HashMap(); - payloadMap.put("type", policyItem.getRecipeInfo()); - } + String actor = policyItem.getActor(); + Map payloadMap = policyItem.getRecipePayload(); Policy policyObj; if (policyItemList.indexOf(policyItem) == 0) { String policyDescription = policyItem.getRecipe() - + " Policy - the trigger (no parent) policy - created by CLDS"; + + " Policy - the trigger (no parent) policy - created by CLDS"; policyObj = builder.setTriggerPolicy(policyName, policyDescription, actor, target, - policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); + policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " - + parentPolicyObj.getName() + " - created by CLDS"; + + parentPolicyObj.getName() + " - created by CLDS"; policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, actor, target, - policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(), - parentPolicyObj.getId(), convertToPolicyResult(policyItem.getParentPolicyConditions())); + policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(), + parentPolicyObj.getId(), convertToPolicyResult(policyItem.getParentPolicyConditions())); logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); } policyObjMap.put(policyItem.getId(), policyObj); @@ -274,7 +264,7 @@ public class OperationalPolicyReq { if (parent == null || parent.length() == 0) { if (!outList.isEmpty()) { throw new BadRequestException( - "Operation Policy validation problem: more than one trigger policy"); + "Operation Policy validation problem: more than one trigger policy"); } else { outList.add(inItem); inListItr.remove(); diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java index 2ae0f07d..501eb807 100644 --- a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java @@ -18,7 +18,7 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * + * */ package org.onap.clamp.clds.model.properties; @@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -62,8 +63,9 @@ public class Policy extends AbstractModelElement { * @param modelProp * @param modelBpmn * @param modelJson + * @throws IOException */ - public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) throws IOException { super(TYPE_POLICY, modelProp, modelBpmn, modelJson); // process policies diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java index 96fc33c2..cf24c781 100644 --- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java +++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java @@ -18,7 +18,7 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * + * */ package org.onap.clamp.clds.model.properties; @@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -65,23 +66,23 @@ public class PolicyChain { private List policyItems; private String policyType; - public PolicyChain(JsonNode node) { + public PolicyChain(JsonNode node) throws IOException { policyId = AbstractModelElement.getValueByName(node, "pid"); timeout = AbstractModelElement.getIntValueByName(node, "timeout"); policyType = AbstractModelElement.getValueByName(node, "policyType"); - - if(node != null && node.size() > 0) { - JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); - if(policyNode != null) { - Iterator itr = policyNode.elements(); - policyItems = new ArrayList<>(); - while (itr.hasNext()) { - policyItems.add(new PolicyItem(itr.next())); - } - - } - } + + if(node != null && node.size() > 0) { + JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); + if(policyNode != null) { + Iterator itr = policyNode.elements(); + policyItems = new ArrayList<>(); + while (itr.hasNext()) { + policyItems.add(new PolicyItem(itr.next())); + } + + } + } } /** * @return the policyId @@ -103,7 +104,7 @@ public class PolicyChain { public List getPolicyItems() { return policyItems; } - + /** * @return the policyType */ diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java index 75bf6ae3..6e3e8659 100644 --- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java @@ -18,16 +18,21 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * + * */ package org.onap.clamp.clds.model.properties; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; import java.util.List; +import java.util.Map; + +import org.onap.clamp.clds.util.JacksonUtils; /** * Parse policyConfigurations from Policy json properties. @@ -61,7 +66,7 @@ public class PolicyItem implements Cloneable { private String targetResourceId; private String recipeInfo; private String recipeLevel; - private String recipePayload; + private Map recipePayload; private String oapRop; private String oapLimit; @@ -69,8 +74,9 @@ public class PolicyItem implements Cloneable { * Parse Policy given json node. * * @param node + * @throws IOException */ - public PolicyItem(JsonNode node) { + public PolicyItem(JsonNode node) throws IOException { id = AbstractModelElement.getValueByName(node, "_id"); recipe = AbstractModelElement.getValueByName(node, "recipe"); maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries"); @@ -83,9 +89,16 @@ public class PolicyItem implements Cloneable { } recipeInfo = AbstractModelElement.getValueByName(node, "recipeInfo"); recipeLevel = AbstractModelElement.getValueByName(node, "recipeLevel"); - recipePayload = AbstractModelElement.getValueByName(node, "recipeInput"); + String payload = AbstractModelElement.getValueByName(node, "recipeInput"); + + + if (payload != null && !payload.isEmpty()) { + //recipePayload = JacksonUtils.getObjectMapperInstance().convertValue(payload, Map.class); + recipePayload = JacksonUtils.getObjectMapperInstance().readValue(payload, new TypeReference>(){}); + } oapRop = AbstractModelElement.getValueByName(node, "oapRop"); oapLimit = AbstractModelElement.getValueByName(node, "oapLimit"); + actor = AbstractModelElement.getValueByName(node, "actor"); } /** @@ -202,7 +215,7 @@ public class PolicyItem implements Cloneable { return recipeLevel; } - public String getRecipePayload() { + public Map getRecipePayload() { return recipePayload; } @@ -219,9 +232,4 @@ public class PolicyItem implements Cloneable { } return oapLimit; } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } } diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html index 3a894c28..5109c1bf 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html @@ -178,42 +178,55 @@ label {
- -
- + +
- + +
-
Error: This Policy name is already taken.
-
Error: Please rename your new Policy.
-
Error: Spaces are not allowed in the ID.
+
Error: This Policy + name is already taken.
+
Error: Please rename your + new Policy.
+
Error: Spaces are not + allowed in the ID.
- diff --git a/src/main/resources/clds/templates/globalProperties.json b/src/main/resources/clds/templates/globalProperties.json index e677abe9..880b9927 100644 --- a/src/main/resources/clds/templates/globalProperties.json +++ b/src/main/resources/clds/templates/globalProperties.json @@ -47,6 +47,11 @@ "policy": { "pname": "0", "timeout": 345, + "actor": { + "APPC":"APPC", + "MSO": "SO", + "VFC": "VFC" + }, "vnfRecipe": { "": "", "restart": "Restart", @@ -54,20 +59,18 @@ "migrate": "Migrate", "healthCheck": "Health Check", "modifyConfig": "ModifyConfig", - "vfModuleCreate":"VF Module Create" + "vfModuleCreate":"VF Module Create", + "scaleOut":"Scale Out" }, "maxRetries": "3", - "retryTimeLimit": 180, - "resource": { - "vCTS": "vCTS", - "v3CDB": "v3CDB", - "vUDR": "vUDR", - "vCOM": "vCOM", - "vRAR": "vRAR", - "vLCS": "vLCS", - "vUDR-BE": "vUDR-BE", - "vDBE": "vDBE" + "recipeLevel": { + "":"", + "VNF":"VNF", + "VM":"VM", + "VFC":"VFC", + "PNF":"PNF" }, + "retryTimeLimit": 180, "parentPolicyConditions": { "Failure_Retries": "Failure: Max Retries Exceeded", "Failure_Timeout": "Failure: Time Limit Exceeded", diff --git a/src/test/resources/example/model-properties/policy/modelBpmnProperties.json b/src/test/resources/example/model-properties/policy/modelBpmnProperties.json index 0ef38752..d0453c30 100644 --- a/src/test/resources/example/model-properties/policy/modelBpmnProperties.json +++ b/src/test/resources/example/model-properties/policy/modelBpmnProperties.json @@ -109,6 +109,13 @@ [ "" ] + }, + { + "name": "actor", + "value": + [ + "APPC" + ] } ], @@ -176,6 +183,13 @@ [ "resource-idOther" ] + }, + { + "name": "actor", + "value": + [ + "APPC" + ] } ] ] @@ -241,6 +255,13 @@ [ "" ] + }, + { + "name": "actor", + "value": + [ + "APPC" + ] } ], @@ -308,6 +329,13 @@ [ "resource-idOther" ] + }, + { + "name": "actor", + "value": + [ + "APPC" + ] } ] ] -- cgit 1.2.3-korg