From 3b2a4a9f36d21c0d5519e83551fde633945eb3a7 Mon Sep 17 00:00:00 2001 From: Pavel Aharoni Date: Mon, 17 Jul 2017 16:45:26 +0300 Subject: [SDC-137] update port properties function Change-Id: I1e2de708ca8fc327941cbb04290d52f07e243ecd Signed-off-by: Pavel Aharoni --- .../sdc/tosca/parser/api/ISdcCsarHelper.java | 12 +++++++ .../sdc/tosca/parser/impl/SdcCsarHelperImpl.java | 37 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'src/main/java/org/openecomp') 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"}}

* @param vfc - VFC node template to look for CP-related props. * @return map CP node template name to a map of full path to a property on this CP - value of this property on this CP. + * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List. */ + @Deprecated public Map> getCpPropertiesFromVfc(NodeTemplate vfc); + /** + * Get the map of CP-related props from a VFC node template.
+ * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this:

+ * {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"}
+ * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}
+ * @param vfc - VFC node template to look for CP-related props. + * @return map CP node template name to a map of property name - property value as object. + */ + public Map> 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 properties = nodeTemplate.getProperties(); return processProperties(split, properties); } + + public Map> getCpPropertiesFromVfcAsObject(NodeTemplate vfc) { + if (vfc == null) { + log.error("getCpPropertiesFromVfc - vfc is null"); + return new HashMap<>(); + } + + String presetProperty = "_ip_requirements"; + Map> cps = new HashMap<>(); + + Map props = vfc.getProperties(); + if (props != null) { + // find all port names by pre-set property (ip_requirements) + for (Map.Entry 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 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> getCpPropertiesFromVfc(NodeTemplate vfc) { -- cgit 1.2.3-korg