* ============LICENSE_END============================================
* Modifications copyright (c) 2018 Nokia
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client.req.policy;
* @throws UnsupportedEncodingException
*/
public static Map<AttributeType, Map<String, String>> 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);
/**
* Format Operational OpenLoop Policy yaml.
- *
+ *
* @param refProp
* @param prop
* @param modelElementId
* @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);
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();
* @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);
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<String, Policy> policyObjMap = new HashMap<>();
target.setType(TargetType.valueOf(policyItem.getRecipeLevel()));
}
target.setResourceID(policyItem.getTargetResourceId());
- String actor = refProp.getStringValue("op.policy.appc");
- Map<String, String> payloadMap = null;
- if ("health-diagnostic".equalsIgnoreCase(policyItem.getRecipe())) {
- actor = refProp.getStringValue("op.policy.sdno");
- payloadMap = new HashMap<String, String>();
- 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<String, String>();
- payloadMap.put("type", policyItem.getRecipeInfo());
- }
+ String actor = policyItem.getActor();
+ Map<String, String> 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);
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();