diff options
author | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-09 16:30:27 +0800 |
---|---|---|
committer | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-09 17:06:22 +0800 |
commit | bfb24b1cc32e287b019fbcef89ac403a660354bb (patch) | |
tree | c1fbf7fa71dee75c7c06c5b9075b7cfd68bd03b9 /holmes-actions/src/main | |
parent | e0a96b91b49f9ca54827c96b2e7e7660c28fab83 (diff) |
modify control loop name
Issue-ID: HOLMES-67
Change-Id: I3911ff57abbe87089dc3d7a2a0e1d4f14ad26cb4
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main')
3 files changed, 16 insertions, 20 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())); |