diff options
author | Michael Lando <ml636r@att.com> | 2017-06-29 16:30:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-06-29 16:30:42 +0000 |
commit | f118ea26bcea3a3d9af27faa7d54e895a0202dcf (patch) | |
tree | defb8b5159f143363fc825c9fee4e74b34500490 /src/main/java | |
parent | 45cbac699c67de72160d6aa83c3979b675bc326c (diff) | |
parent | 16b52f965b23d05cd2b57c5c29d1330e8d04a5f1 (diff) |
Merge "[SDC-43] NFOD getVnfConfig support"
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java | 9 | ||||
-rw-r--r-- | src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java | 43 |
2 files changed, 48 insertions, 4 deletions
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java index 35c68d4..45d8392 100644 --- a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java +++ b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java @@ -361,4 +361,13 @@ public interface ISdcCsarHelper { * @return service node templates of this SDC type. */ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType); + + /** + * Get all node templates for this CSAR service. + * @param vfCustomizationUuid - the Customization UUID of the node. + * @return VNF Configuration Node Template. + */ + public NodeTemplate getVnfConfig(String vfCustomizationUuid); + + } diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java index e3b9937..0ed4c97 100644 --- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java +++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -561,7 +562,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { } public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType) { - if (parentNodeTemplate == null) { + return getNodeTemplateBySdcType(parentNodeTemplate, sdcType, false); + } + + private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType, boolean isVNF) { + + if (parentNodeTemplate == null) { log.error("getNodeTemplateBySdcType - nodeTemplate is null or empty"); return new ArrayList<>(); } @@ -575,10 +581,23 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { if (substitutionMappings != null) { List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates(); - if (nodeTemplates != null && nodeTemplates.size() > 0) - return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList()); - else + if (nodeTemplates != null && nodeTemplates.size() > 0) { + if (sdcType.equals(SdcTypes.VFC) && isVNF) { + return nodeTemplates.stream() + .filter(x -> (x.getMetaData() != null && + sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && (x.getType().endsWith("VnfConfiguration"))) + .collect(Collectors.toList()); + } + else { + return nodeTemplates.stream() + .filter(x -> (x.getMetaData() != null && + sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && !(x.getType().endsWith("VnfConfiguration"))) + .collect(Collectors.toList()); + } + } + else { log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist"); + } } else log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist"); @@ -616,6 +635,19 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { return filterMap; } + + public NodeTemplate getVnfConfig(String vfCustomizationUuid) { + + if (GeneralUtility.isEmptyString(vfCustomizationUuid)) { + log.error("getVnfConfig - vfCustomizationId - is null or empty"); + return null; + } + + List<NodeTemplate> serviceVfList = getServiceVfList(); + NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid); + NodeTemplate vnfConfig = getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC, true).stream().findAny().orElse(null); + return vnfConfig; + } /************************************* helper functions ***********************************/ private Map<String, String> filterProperties(Object property, String path, FilterType filterType, String pattern, Map<String, String> filterMap) { @@ -656,6 +688,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate(); return getNodeTemplateBySdcType(topologyTemplate, sdcType); } + /************************************* helper functions ***********************************/ private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, SdcTypes sdcType) { @@ -696,6 +729,8 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { return null; } + + } |