summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dcae/entity/Rule.java1
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java8
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java27
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParserTest.java1
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java4
-rw-r--r--holmes-actions/src/test/resources/dcae.config.json2
6 files changed, 19 insertions, 24 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/entity/Rule.java b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/entity/Rule.java
index 207f224..0d76b9f 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/entity/Rule.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/entity/Rule.java
@@ -25,6 +25,7 @@ import lombok.Setter;
@AllArgsConstructor
public class Rule {
private String name;
+ private String loopControlName;
private String contents;
private int enabled = 1;
}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java
index e4899d3..9284dd8 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParser.java
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.holmes.common.dcae.utils;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
@@ -30,6 +30,8 @@ import org.onap.holmes.common.exception.CorrelationException;
public class DcaeConfigurationParser {
+ private static final String RULE_CONTENT_SPLIT = "\\$\\$\\$";
+
private static final List<String> OBJECT_ATTRS = Arrays
.asList(new String[]{"streams_subscribes", "streams_publishes", "services_calls", "services_provides"});
@@ -102,7 +104,9 @@ public class DcaeConfigurationParser {
Set<Entry<String, Object>> entries = jsonObject.entrySet();
for (Entry<String, Object> entry : entries) {
if (entry.getKey().startsWith("holmes.default.rule")) {
- ret.addDefaultRule(new Rule(entry.getKey(), (String) entry.getValue(), 1));
+ String value = (String) entry.getValue();
+ String[] contents = value.split(RULE_CONTENT_SPLIT);
+ ret.addDefaultRule(new Rule(entry.getKey(), contents[0], contents[1], 1));
}
}
}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
index 2b03a8a..05b3583 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
@@ -18,8 +18,8 @@ package org.onap.holmes.common.dmaap;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.List;
import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
-import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.AaiQuery;
@@ -36,11 +36,14 @@ import org.onap.holmes.common.utils.JacksonUtil;
@Service
public class DmaapService {
+ public static final int POLICY_MESSAGE_ABATED = 1;
@Inject
private AaiQuery aaiQuery;
@Inject
private Publisher publisher;
+ public static ConcurrentHashMap<String, String> loopControlNames = new ConcurrentHashMap<>();
+
public void publishPolicyMsg(PolicyMsg policyMsg) {
try {
publisher.publish(policyMsg);
@@ -52,9 +55,9 @@ public class DmaapService {
}
}
- public PolicyMsg getPolicyMsg(VesAlarm vesAlarm) {
+ public PolicyMsg getPolicyMsg(VesAlarm vesAlarm, String packgeName) {
return Optional.ofNullable(getVmEntity(vesAlarm.getSourceId(), vesAlarm.getSourceName()))
- .map(vmEntity -> getEnrichedPolicyMsg(vmEntity, vesAlarm))
+ .map(vmEntity -> getEnrichedPolicyMsg(vmEntity, vesAlarm, packgeName))
.orElse(getDefaultPolicyMsg(vesAlarm.getSourceName()));
}
@@ -94,28 +97,16 @@ public class DmaapService {
return vmEntity;
}
- private PolicyMsg getEnrichedPolicyMsg(VmEntity vmEntity, VesAlarm vesAlarm) {
+ private PolicyMsg getEnrichedPolicyMsg(VmEntity vmEntity, VesAlarm vesAlarm, String packageName) {
VnfEntity vnfEntity = getVnfEntity(vesAlarm.getEventId(), vesAlarm.getEventName());
String vserverInstatnceId = getVserverInstanceId(vnfEntity);
PolicyMsg policyMsg = new PolicyMsg();
- policyMsg.setClosedLoopEventClient("DCAE_INSTANCE_ID.dcae-tca");
- policyMsg.setPolicyVersion("1.0.0.5");
- policyMsg.setPolicyName("vLoadBalancer");
- policyMsg.setPolicyScope(
- "resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop");
- policyMsg.setTargetType("VM");
- policyMsg.setClosedLoopAlarmStart(1484855);
- if (vesAlarm.getAlarmIsCleared() == 1) {
+ if (vesAlarm.getAlarmIsCleared() == POLICY_MESSAGE_ABATED) {
policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ABATED);
} else {
policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ONSET);
}
- policyMsg.setClosedLoopControlName(
- "CL-LB-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
- policyMsg.setVersion("1.0.2");
- policyMsg.setTarget("generic-vnf.vnf-id");
- policyMsg.setRequestID("8c1b8bd8-06f7-493f-8ed7-daaa4cc481bc");
- policyMsg.setFrom("DCAE");
+ policyMsg.setClosedLoopControlName(loopControlNames.get(packageName));
policyMsg.getAai().put("vserver.in-maint", String.valueOf(vmEntity.getInMaint()));
policyMsg.getAai().put("vserver.is-closed-loop-disabled",
String.valueOf(vmEntity.getClosedLoopDisable()));
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParserTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParserTest.java
index e20ed5e..827220c 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParserTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/dcae/utils/DcaeConfigurationParserTest.java
@@ -52,7 +52,6 @@ public class DcaeConfigurationParserTest {
br.lines().forEach(line -> {
sb.append(line);
});
-
try {
br.close();
} catch (IOException e) {
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java
index 7198ec8..72a0bc8 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java
@@ -207,10 +207,10 @@ public class DmaapServiceTest {
PowerMock.replayAll();
PolicyMsg actual = Whitebox
- .invokeMethod(dmaapService, "getEnrichedPolicyMsg", vmEntity, vesAlarm);
+ .invokeMethod(dmaapService, "getEnrichedPolicyMsg", vmEntity, vesAlarm, "loopName");
PowerMock.verifyAll();
- assertThat(actual.getPolicyName(), equalTo("vLoadBalancer"));
+ assertThat(actual.getClosedLoopControlName(), equalTo(null));
assertThat(actual.getAai().get("vserver.prov-status"), equalTo("prov"));
assertThat(actual.getAai().get("vserver.vserver-name2") == null, equalTo(true));
assertThat(actual.getAai().get("generic-vnf.service-instance-id"), equalTo(""));
diff --git a/holmes-actions/src/test/resources/dcae.config.json b/holmes-actions/src/test/resources/dcae.config.json
index 6fe72e8..f5aa3ae 100644
--- a/holmes-actions/src/test/resources/dcae.config.json
+++ b/holmes-actions/src/test/resources/dcae.config.json
@@ -1,5 +1,5 @@
{
- "holmes.default.rule.volte.scenario1": "package dcae.ves.test\nimport org.onap.some.related.packages;\nrule\"SameVNF_Relation_Rule\"\nsalience 120\nno-loop true\nwhen\n$root : VesAlarm(\n$sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\nspecificProblem in ( \"LSS_cpiPCSCFFailReg(121297)\", \"LSS_cpiSIPRetransmitInvite(120267)\" ),\n$eventId: eventId)\n$child : VesAlarm( eventId != $eventId,\nCorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId),\nspecificProblem in (\"LSS_externalLinkDown(4271)\",\"LSS_failedAttachReqsRateExceeded(4272)\"),\nthis after [-60s, 60s] $root)\nthen\nDmaapService.publishResult(...);\nend",
+ "holmes.default.rule.volte.scenario1": "loopname$$$package dcae.ves.test\nimport org.onap.some.related.packages;\nrule\"SameVNF_Relation_Rule\"\nsalience 120\nno-loop true\nwhen\n$root : VesAlarm(\n$sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\nspecificProblem in ( \"LSS_cpiPCSCFFailReg(121297)\", \"LSS_cpiSIPRetransmitInvite(120267)\" ),\n$eventId: eventId)\n$child : VesAlarm( eventId != $eventId,\nCorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId),\nspecificProblem in (\"LSS_externalLinkDown(4271)\",\"LSS_failedAttachReqsRateExceeded(4272)\"),\nthis after [-60s, 60s] $root)\nthen\nDmaapService.publishResult(...);\nend",
"collector.schema.file": "./etc/CommonEventFormat_27.2.json",
"collector.service.port": 8080,
"collector.dmaap.streamid": "fault=sec_fault,roadm-sec-to-hp|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert",