diff options
author | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-23 15:34:22 +0800 |
---|---|---|
committer | Shiwei Tian <tian.shiwei@zte.com.cn> | 2017-10-23 15:34:22 +0800 |
commit | 75b8b484b7207c393026ee6509a22b2016a22475 (patch) | |
tree | 5dbe71ffbe2ab1ef80ac09c3c690845ca0713824 /holmes-actions/src/main/java/org | |
parent | ece7abcfdf6d68a8f41732883435822ceb745c11 (diff) |
modify bug
Issue-ID: HOLMES-71
Change-Id: I1f7828319a571c78ef706220dbc2ae182f4b98ad
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main/java/org')
3 files changed, 46 insertions, 26 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java index df4e4ac..7cbb6f3 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java @@ -95,13 +95,14 @@ public class AaiQuery { private String getBaseUrl(String suffixUrl) { String url = ""; try { - url = MicroServiceConfig.getMsbServerAddr() + suffixUrl; + String[] msbUrl = MicroServiceConfig.getMsbServerAddr().split(":"); + url = msbUrl[0] + ":" + msbUrl[1] + suffixUrl; } catch (Exception e) { log.info("Failed to get msb address"); } - if (url.equals("")) { + if ("".equals(url)) { try { - url = "https:\\\\" + MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config") + url = "https://" + MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config") + suffixUrl; } catch (Exception e) { log.info("Failed to get aai address"); @@ -112,9 +113,18 @@ public class AaiQuery { private String getMsbSuffixAddr(String suffixUrl) { String[] addrSplits = suffixUrl.substring(1).split("/"); + String[] conv = addrSplits[2].split("-"); + addrSplits[2] = conv[0]; + if (conv.length > 1) { + for(int i = 1; i < conv.length; i++) { + addrSplits[2] = addrSplits[2] + conv[i].substring(0, 1).toUpperCase() + conv[i] + .substring(1); + } + } String ret = addrSplits[1]; addrSplits[1] = addrSplits[0] + "-" + addrSplits[2]; addrSplits[2] = ret; + addrSplits[0] = "api"; StringBuffer stringBuffer = new StringBuffer(); for (String split : addrSplits) { stringBuffer.append("/" + split); 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 4dfc392..3ddf126 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 @@ -24,6 +24,7 @@ import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.jvnet.hk2.annotations.Service; import org.onap.holmes.common.aai.AaiQuery; +import org.onap.holmes.common.aai.entity.RelationshipList.Relationship; import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData; import org.onap.holmes.common.aai.entity.VmEntity; import org.onap.holmes.common.aai.entity.VnfEntity; @@ -71,16 +72,24 @@ public class DmaapService { private String getVserverInstanceId(VnfEntity vnfEntity) { String vserverInstanceId = ""; if (vnfEntity != null) { - List<RelationshipData> relationshipDataList = vnfEntity.getRelationshipList() - .getRelationships().stream() - .filter(relationship -> relationship.getRelatedTo().equals("service-instance")) - .limit(1).findFirst().get().getRelationshipDataList(); - - vserverInstanceId = relationshipDataList.stream() - .filter(relationshipData -> relationshipData.getRelationshipKey() - .equals("service-instance.service-instance-id")) - .findFirst() - .map(relationshipData -> relationshipData.getRelationshipValue()).get(); + List<Relationship> relationshipList = vnfEntity.getRelationshipList().getRelationships(); + Relationship relationship = null; + for(int i = 0; i < relationshipList.size(); i++) { + if ("service-instance".equals(relationshipList.get(i).getRelatedTo())) { + relationship = relationshipList.get(i); + break; + } + } + if (relationship != null) { + List<RelationshipData> relationshipDataList = relationship.getRelationshipDataList(); + for(int i = 0; i < relationshipDataList.size(); i++) { + if ("service-instance.service-instance-id" + .equals(relationshipDataList.get(i).getRelationshipKey())) { + vserverInstanceId = relationshipDataList.get(i).getRelationshipValue(); + break; + } + } + } } return vserverInstanceId; } @@ -102,15 +111,16 @@ public class DmaapService { alarmUniqueRequestID.put(rootAlarm.getSourceId(), requestID); } policyMsg.setClosedLoopControlName(loopControlNames.get(packageName)); - policyMsg.getAai().put("vserver.in-maint", String.valueOf(vmEntity.getInMaint())); - policyMsg.getAai().put("vserver.is-closed-loop-disabled", + policyMsg.setTarget(vmEntity.getVserverName()); + policyMsg.getAAI().put("vserver.in-maint", String.valueOf(vmEntity.getInMaint())); + policyMsg.getAAI().put("vserver.is-closed-loop-disabled", String.valueOf(vmEntity.getClosedLoopDisable())); - policyMsg.getAai().put("vserver.prov-status", vmEntity.getProvStatus()); - policyMsg.getAai().put("vserver.resource-version", vmEntity.getResourceVersion()); - policyMsg.getAai().put("vserver.vserver-id", vmEntity.getVserverId()); - policyMsg.getAai().put("vserver.vserver-name", vmEntity.getVserverName()); - policyMsg.getAai().put("vserver.vserver-name2", vmEntity.getVserverName2()); - policyMsg.getAai().put("vserver.vserver-selflink", vmEntity.getVserverSelflink()); + policyMsg.getAAI().put("vserver.prov-status", vmEntity.getProvStatus()); + policyMsg.getAAI().put("vserver.resource-version", vmEntity.getResourceVersion()); + policyMsg.getAAI().put("vserver.vserver-id", vmEntity.getVserverId()); + policyMsg.getAAI().put("vserver.vserver-name", vmEntity.getVserverName()); + policyMsg.getAAI().put("vserver.vserver-name2", vmEntity.getVserverName2()); + policyMsg.getAAI().put("vserver.vserver-selflink", vmEntity.getVserverSelflink()); return policyMsg; } @@ -118,16 +128,16 @@ public class DmaapService { PolicyMsg policyMsg = new PolicyMsg(); policyMsg.setTarget("vserver.vserver-name"); policyMsg.setTargetType("VM"); - policyMsg.getAai().put("vserver.vserver-name", sourceName); + policyMsg.getAAI().put("vserver.vserver-name", sourceName); return policyMsg; } private void enrichVnfInfo(VesAlarm childAlarm, PolicyMsg policyMsg) { VnfEntity vnfEntity = getVnfEntity(childAlarm.getSourceId(), childAlarm.getSourceName()); String vserverInstatnceId = getVserverInstanceId(vnfEntity); - policyMsg.getAai().put("generic-vnf.vnf-id", childAlarm.getSourceId()); - policyMsg.getAai().put("generic-vnf.vnf-name", childAlarm.getSourceName()); - policyMsg.getAai().put("generic-vnf.service-instance-id", vserverInstatnceId); + policyMsg.getAAI().put("generic-vnf.vnf-id", childAlarm.getSourceId()); + policyMsg.getAAI().put("generic-vnf.vnf-name", childAlarm.getSourceName()); + policyMsg.getAAI().put("generic-vnf.service-instance-id", vserverInstatnceId); } private VnfEntity getVnfEntity(String vnfId, String vnfName) { diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java index 0c3078b..4462474 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/entity/PolicyMsg.java @@ -40,7 +40,7 @@ public class PolicyMsg { @JsonProperty(value = "target_type")
private String targetType = "VM";
private String target;
- private Map<String, String> aai = new HashMap<>();
+ private Map<String, String> AAI = new HashMap<>();
public static enum EVENT_STATUS {
ONSET, ABATED;
|