From b05d98d452bff903411f4b1efcadc9003206f7f3 Mon Sep 17 00:00:00 2001 From: zm330 Date: Mon, 29 Jul 2019 15:19:40 +0800 Subject: repair vfcInstanceGroup order Issue-ID: SO-2164 Change-Id: I827342692dc4e4241b22c6eb8dd455b2b9385fa8 Signed-off-by: zm330 --- .../installer/heat/ToscaResourceInstaller.java | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'asdc-controller/src/main/java') diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index a08206b477..e4c95f6290 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -1087,9 +1087,9 @@ public class ToscaResourceInstaller { tempGroupList.addAll(groupList); for (Group group : groupList) { + boolean isAllExists = true; ArrayList members = group.getMemberNodes(); for (NodeTemplate memberNode : members) { - boolean isAllExists = true; RequirementAssignments requirements = iSdcCsarHelper.getRequirementsOf(memberNode); if (requirements == null || requirements.getAll() == null || requirements.getAll().isEmpty()) { continue; @@ -1097,27 +1097,28 @@ public class ToscaResourceInstaller { List rqaList = requirements.getAll(); for (RequirementAssignment rqa : rqaList) { String name = rqa.getNodeTemplateName(); - for (NodeTemplate node : nodes) { - if (name.equals(node.getName())) { - break; - } + Optional findNode = + nodes.stream().filter(node -> node.getName().equals(name)).findFirst(); + if (!findNode.isPresent()) { + isAllExists = false; + break; } - - isAllExists = false; - break; } - - if (isAllExists) { - strSequence.add(group.getName()); - tempGroupList.remove(group); - nodes.addAll(group.getMemberNodes()); + if (!isAllExists) { + break; } } - if (!tempGroupList.isEmpty() && tempGroupList.size() < groupList.size()) { - getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper); + if (isAllExists) { + strSequence.add(group.getName()); + tempGroupList.remove(group); + nodes.addAll(group.getMemberNodes()); } } + + if (tempGroupList.size() != 0 && tempGroupList.size() < groupList.size()) { + getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper); + } } public void processWatchdog(String distributionId, String servideUUID, Optional distributionNotification, @@ -1896,7 +1897,13 @@ public class ToscaResourceInstaller { vnfcCustomization .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); vnfcCustomization.setResourceInput(getVnfcResourceInput(vfcTemplate, inputList)); - vfcInstanceGroupCustom.getVnfcCustomizations().add(vnfcCustomization); + List vnfcCustomizations = vfcInstanceGroupCustom.getVnfcCustomizations(); + + if (vnfcCustomizations == null) { + vnfcCustomizations = new ArrayList<>(); + vfcInstanceGroupCustom.setVnfcCustomizations(vnfcCustomizations); + } + vnfcCustomizations.add(vnfcCustomization); } } } -- cgit 1.2.3-korg