import org.onap.clamp.clds.model.prop.Tca;
import org.onap.clamp.clds.model.refprop.RefProp;
import org.onap.policy.api.AttributeType;
-import org.onap.policy.asdc.Resource;
-import org.onap.policy.asdc.ResourceType;
-import org.onap.policy.asdc.Service;
+import org.onap.policy.sdc.Resource;
+import org.onap.policy.sdc.ResourceType;
+import org.onap.policy.sdc.Service;
import org.onap.policy.controlloop.policy.OperationsAccumulateParams;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private OperationalPolicyReq() {
+
+ }
+
/**
* Format Operational Policy attributes.
*
String recipe = policyItem.getRecipe();
String maxRetries = String.valueOf(policyItem.getMaxRetries());
String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit());
+ String targetResourceId = String.valueOf(policyItem.getTargetResourceId());
logger.info("recipe=" + recipe);
logger.info("maxRetries=" + maxRetries);
logger.info("retryTimeLimit=" + retryTimeLimit);
+ logger.info("targetResourceId=" + targetResourceId);
ruleAttributes.put("Recipe", recipe);
ruleAttributes.put("MaxRetries", maxRetries);
ruleAttributes.put("RetryTimeLimit", retryTimeLimit);
+ ruleAttributes.put("ResourceId", targetResourceId);
+
} else {
logger.info("templateName=" + templateName);
logger.info("operationTopic=" + operationTopic);
* @throws BuilderException
* @throws UnsupportedEncodingException
*/
- private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+ public static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
builder.addResource(vfcResources);
// process each policy
- HashMap<String, org.onap.policy.controlloop.policy.Policy> policyObjMap = new HashMap<>();
+ Map<String, Policy> policyObjMap = new HashMap<>();
List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems());
- Target target = new Target();
- target.setType(TargetType.VM);
- for (int i = 0; i < policyItemList.size(); i++) {
-
- org.onap.policy.controlloop.policy.Policy policyObj;
- PolicyItem policyItem = policyItemList.get(i);
+ for (PolicyItem policyItem : policyItemList) {
String policyName = policyItem.getRecipe() + " Policy";
- if (i == 0) {
+ Target target = new Target();
+ target.setType(TargetType.VM);
+ target.setResourceID(policyItem.getTargetResourceId());
+ Policy policyObj;
+ if (policyItemList.indexOf(policyItem) == 0) {
String policyDescription = policyItem.getRecipe()
+ " Policy - the trigger (no parent) policy - created by CLDS";
policyObj = builder.setTriggerPolicy(policyName, policyDescription,
refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null,
policyItem.getMaxRetries(), policyItem.getRetryTimeLimit());
} else {
- org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap
- .get(policyItem.getParentPolicy());
+ Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy());
String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by "
+ parentPolicyObj.getName() + " - created by CLDS";
policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription,
* @throws BuilderException
* @throws UnsupportedEncodingException
*/
- private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+ public static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
builder.addResource(vfcResources);
// process each policy
- HashMap<String, Policy> policyObjMap = new HashMap<>();
+ Map<String, Policy> policyObjMap = new HashMap<>();
List<PolicyItem> policyItemList = addAOTSActorRecipe(refProp, global.getService(),
policyChain.getPolicyItems());
- Target target = new Target();
- target.setType(TargetType.VM);
+
Policy lastPolicyObj = new Policy();
- for (int i = 0; i < policyItemList.size(); i++) {
- org.onap.policy.controlloop.policy.Policy policyObj;
- PolicyItem policyItem = policyItemList.get(i);
+ for (PolicyItem policyItem : policyItemList) {
+ Target target = new Target();
+ target.setType(TargetType.VM);
+ target.setResourceID(policyItem.getTargetResourceId());
String policyName = policyItem.getRecipe() + " Policy";
- if (i == 0) {
+ Policy policyObj;
+ if (policyItemList.indexOf(policyItem) == 0) {
// To set up time window payload for trigger policy
Map<String, String> payloadMap = new HashMap<>();
payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow"));