aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-06-29 19:24:06 +0300
committerPavel Aharoni <pa0916@att.com>2017-06-29 19:24:16 +0300
commit16b52f965b23d05cd2b57c5c29d1330e8d04a5f1 (patch)
tree2da7948c85b89f256ab25d23dd09c3513b3d664c /src
parent33641026fa9ea231d88b7ada341cac677b0389d1 (diff)
[SDC-43] NFOD getVnfConfig support
Change-Id: I067a30e1c62228b52403807f9572d35f93cd0cfa Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java9
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java43
-rw-r--r--src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java3
-rw-r--r--src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java33
-rw-r--r--src/test/resources/csars/service-NfodService-csar.csarbin0 -> 39906 bytes
5 files changed, 83 insertions, 5 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 8095974..590abd9 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
@@ -25,6 +25,7 @@ import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -553,7 +554,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<>();
}
@@ -567,10 +573,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");
@@ -608,6 +627,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) {
@@ -648,6 +680,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
return getNodeTemplateBySdcType(topologyTemplate, sdcType);
}
+
/************************************* helper functions ***********************************/
private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, SdcTypes sdcType) {
@@ -688,6 +721,8 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
+
+
}
diff --git a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index 2039645..3af654e 100644
--- a/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -26,6 +26,7 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper fdntCsarHelper;
static ISdcCsarHelper complexCps;
static ISdcCsarHelper fdntCsarHelperWithInputs;
+ static ISdcCsarHelper nfodCsarHlper;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@BeforeClass
@@ -37,7 +38,7 @@ public abstract class SdcToscaParserBasicTest {
rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar");
complexCps = getCsarHelper("csars/service-consolidated-props-csar.csar");
fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar");
-
+ nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar");
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> FDNT ;
diff --git a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index 28058a5..bc506b1 100644
--- a/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -523,4 +523,37 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
+
+ @Test
+ public void testGetVnfConfig() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vnfConfig);
+ assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name"));
+ }
+
+ @Test
+ public void testGetVnfConfigByNonFoundVNF() {
+ NodeTemplate vnfConfig = complexCps.getVnfConfig("f999e2ca-72c0-42d3-9b11-13f2122fb8ef");
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVnfConfigByDummyUUID() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("XXX");
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVnfConfigByNullUUID() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig(null);
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVfcTypWithoutVnf() {
+ List<NodeTemplate> vfcList = nfodCsarHlper.getVfcListByVf("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vfcList);
+ assertEquals(2, vfcList.size());
+ }
+
}
diff --git a/src/test/resources/csars/service-NfodService-csar.csar b/src/test/resources/csars/service-NfodService-csar.csar
new file mode 100644
index 0000000..679c80b
--- /dev/null
+++ b/src/test/resources/csars/service-NfodService-csar.csar
Binary files differ