aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java12
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java37
2 files changed, 49 insertions, 0 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 6c8f5df..bb5bd25 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
@@ -326,9 +326,21 @@ public interface ISdcCsarHelper {
* port_fe_oam={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_2", network_role_tag="Mobility_OAM_protected"}}<br><br>
* @param vfc - VFC node template to look for CP-related props.
* @return map <b>CP node template name</b> to a map of <b>full path to a property on this CP</b> - <b> value of this property on this CP</b>.
+ * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
*/
+ @Deprecated
public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
+ /**
+ * Get the map of CP-related props from a VFC node template. <br>
+ * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
+ * {port_fe_sigtran={ip_requirements={ip_count_required: {count: 1}, dhcp_enabled: true, ip_version: 4}, subnetpoolid: "subnet_1", network_role_tag: "SIGNET_vrf_B1_direct"}<br>
+ * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
+ * @param vfc - VFC node template to look for CP-related props.
+ * @return map <b>CP node template name</b> to a map of <b>property name</b> - <b> property value as object</b>.
+ */
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
+
/**
* Get customization UUID of a node template
* @param nt - node template
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 7b901ec..c927817 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
@@ -90,6 +90,43 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
return processProperties(split, properties);
}
+
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc) {
+ if (vfc == null) {
+ log.error("getCpPropertiesFromVfc - vfc is null");
+ return new HashMap<>();
+ }
+
+ String presetProperty = "_ip_requirements";
+ Map<String, Map<String, Object>> cps = new HashMap<>();
+
+ Map<String, Property> props = vfc.getProperties();
+ if (props != null) {
+ // find all port names by pre-set property (ip_requirements)
+ for (Map.Entry<String, Property> entry : props.entrySet()) {
+ if (entry.getKey().endsWith(presetProperty)) {
+ String portName = entry.getKey().replaceAll(presetProperty, "");
+ cps.put(portName, new HashMap<>());
+ }
+ }
+
+ if (cps.size() > 0) {
+ // ports found - find all their properties
+ for (String portName : cps.keySet()) {
+ for (Map.Entry<String, Property> property: props.entrySet()) {
+ if (property.getKey().startsWith(portName)) {
+ String portProperty = property.getKey().replaceFirst(portName + "_", "");
+ if (property.getValue() != null) {
+ cps.get(portName).put(portProperty, property.getValue().getValue());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return cps;
+ }
public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc) {