aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAria, Lalena (la505a) <lalena.aria>2019-06-14 14:58:13 +0000
committerlalena.aria <lalena.aria@att.com>2019-06-14 15:04:59 +0000
commit69a61e338d5e528870085f6d365ae41bfd2cd9a4 (patch)
tree43da7746255c2535c2e00592f3b4b2c1893a17ef
parente8fcf7c536a77381542dabc239a3e127c319e4a8 (diff)
Use getEntity to populate VFC and AR tables
Changes made: Update SdncARModel to use IEntityDetails instead of NodeTemplate. Update SdncVFCModel to use IEntityDetails instead of Group. Small fixes in SdncVFModuleModel. Corresponding junit changes for getEntity migration. Issue-ID: CCSDK-1367 Change-Id: Ifaf57e9fb22ef87be80bad39948f07bb0a78a6bc Signed-off-by: lalena.aria <lalena.aria@att.com>
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java43
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java75
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java30
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java414
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java69
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java8
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java12
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java20
8 files changed, 401 insertions, 270 deletions
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java
index 9cac459d..f1e514da 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java
@@ -23,10 +23,14 @@
package org.onap.ccsdk.sli.northbound.uebclient;
import java.io.IOException;
+import java.util.List;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.slf4j.Logger;
@@ -40,21 +44,21 @@ public class SdncARModel extends SdncBaseModel {
private String type = null;
private String subcategory = null;
- public SdncARModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate,DBResourceManager jdbcDataSource) {
+ public SdncARModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails arEntity, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
- super(sdcCsarHelper, nodeTemplate, jdbcDataSource);
+ super(sdcCsarHelper, arEntity, jdbcDataSource, config);
// extract metadata
- Metadata metadata = nodeTemplate.getMetaData();
+ Metadata metadata = arEntity.getMetadata();
type = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE);
subcategory = extractValue (metadata, "subcategory");
addParameter("type", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
// extract properties
- addParameter("role", extractValue (nodeTemplate, "nf_role"));
- addParameter("type", extractValue (nodeTemplate, "nf_type"));
- addParameter("ecomp_generated_naming", extractBooleanValue (nodeTemplate, "nf_naming#ecomp_generated_naming"));
- addParameter("naming_policy", extractValue (nodeTemplate, "nf_naming#naming_policy"));
+ addParameter("role", extractValue (arEntity, "nf_role"));
+ addParameter("type", extractValue (arEntity, "nf_type"));
+ addParameter("ecomp_generated_naming", extractBooleanValue (arEntity, "nf_naming", "ecomp_generated_naming"));
+ addParameter("naming_policy", extractValue (arEntity, "nf_naming", "naming_policy"));
}
public void insertAllottedResourceModelData () throws IOException {
@@ -67,6 +71,29 @@ public class SdncARModel extends SdncBaseModel {
throw new IOException (e);
}
}
+
+ public void insertAllottedResourceVfcModelData () throws IOException {
+
+ // Insert the child VFCs (not CVFC) into VFC_MODEL
+ String vfCustomizationUuid = getCustomizationUUID().replace("\"", "");
+ EntityQuery vfcEntityQuery = EntityQuery.newBuilder(SdcTypes.VFC).build();
+ TopologyTemplateQuery vfcTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID(vfCustomizationUuid)
+ .build();
+ List<IEntityDetails> nestedVfcs = sdcCsarHelper.getEntity(vfcEntityQuery, vfcTopologyTemplateQuery, true); // true allows for nested search
+ if (nestedVfcs == null || nestedVfcs.isEmpty()) {
+ LOG.info("Could not find the nested VFCs for: " + vfCustomizationUuid);
+ }
+
+ for (IEntityDetails nestedVfc: nestedVfcs) {
+ try {
+ SdncVFCModel arVfcModel = new SdncVFCModel (sdcCsarHelper, nestedVfc, jdbcDataSource, config);
+ arVfcModel.insertVFCModelData();
+ } catch (IOException e) {
+ LOG.info("Could not find the nested VFCs for: " + vfCustomizationUuid);
+ }
+ }
+ }
public String getSubcategory() {
return subcategory;
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
index a5de97fc..24591125 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
@@ -706,6 +706,65 @@ public class SdncBaseModel {
}
}
+ protected String extractValue (IEntityDetails entityDetails, String path, String name) {
+ String value = null;
+
+ if (entityDetails.getProperties().containsKey(path)) {
+ Property property = entityDetails.getProperties().get(path);
+ if (property != null && property.getLeafPropertyValue(name) != null) {
+ value = property.getLeafPropertyValue(name).get(0);
+ }
+ }
+
+ if (value != null) {
+ return value;
+ } else {
+ return "";
+ }
+ }
+
+ protected String extractValue (Property property, String name) {
+ String value = null;
+
+ if (!property.getLeafPropertyValue(name).isEmpty()) {
+ value = property.getLeafPropertyValue(name).get(0);
+ }
+
+ if (value != null) {
+ return value;
+ } else {
+ return "";
+ }
+ }
+
+ protected String extractBooleanValue (Property property, String name) {
+ String value = null;
+
+ if (!property.getLeafPropertyValue(name).isEmpty()) {
+ value = property.getLeafPropertyValue(name).get(0);
+ }
+
+ if (value != null) {
+ return value.contains("true") ? "Y" : "N";
+ } else {
+ return "";
+ }
+ }
+
+ protected String extractIntegerValue (Property property, String name) {
+ String value = null;
+
+ if (!property.getLeafPropertyValue(name).isEmpty()) {
+ value = property.getLeafPropertyValue(name).get(0);
+ }
+
+ if (value != null && !value.isEmpty() && !value.contains("null")) {
+ return value;
+ } else {
+ return "";
+ }
+ }
+
protected String extractGetInputValue (Group group, NodeTemplate nodeTemplate, String name) {
String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, extractGetInputName (group, name));
@@ -821,6 +880,22 @@ public class SdncBaseModel {
}
}
+ protected String extractBooleanValue (IEntityDetails entityDetails, String path, String name) {
+ String value = null;
+ if (entityDetails.getProperties().containsKey(path)) {
+ Property property = entityDetails.getProperties().get(path);
+ if (property != null && property.getLeafPropertyValue(name) != null) {
+ value = property.getLeafPropertyValue(name).get(0);
+ }
+ }
+
+ if (value != null && !value.isEmpty()) {
+ return value.contains("true") ? "Y" : "N";
+ } else {
+ return "";
+ }
+ }
+
public static String extractBooleanValue (ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, String name) {
String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
if (value != null && !value.isEmpty()) {
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
index 4d9dbda9..95672ea5 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
@@ -718,16 +718,26 @@ public class SdncUebCallback implements INotificationCallback {
}
}
- // Ingest Allotted Resource Data - 1707
- List<NodeTemplate> arNodeTemplatesList = sdcCsarHelper.getAllottedResources();
-
- for (NodeTemplate nodeTemplate : arNodeTemplatesList) {
-
- try {
- SdncARModel nodeModel = new SdncARModel (sdcCsarHelper, nodeTemplate, jdbcDataSource);
- nodeModel.insertAllottedResourceModelData ();
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
+ // Ingest Allotted Resource Data - 1707 / migrate to getEntity - 1908
+ // Use getEntity to get all VFs in the service filter by metadata Category = Allotted Resource
+ EntityQuery vfEntityQuery = EntityQuery.newBuilder(SdcTypes.VF).build();
+ TopologyTemplateQuery vfTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+ List<IEntityDetails> vfEntities = sdcCsarHelper.getEntity(vfEntityQuery, vfTopologyTemplateQuery, true);
+ if (vfEntities != null) {
+ for (IEntityDetails vfEntity : vfEntities){
+
+ // If this VF has metadata Category: Allotted Resource, insert it into ALLOTTED_RESOURCE_MODEL table
+ String vfCategory = SdncBaseModel.extractValue(sdcCsarHelper, vfEntity.getMetadata(), "category");
+ if (vfCategory.contains("Allotted Resource")) {
+
+ try {
+ SdncARModel arModel = new SdncARModel (sdcCsarHelper, vfEntity, jdbcDataSource, config);
+ arModel.insertAllottedResourceModelData ();
+ arModel.insertAllottedResourceVfcModelData();
+ } catch (IOException e) {
+ deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
+ }
+ }
}
}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
index 94392262..bd71c024 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
@@ -27,9 +27,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,28 +46,28 @@ public class SdncVFCModel extends SdncBaseModel {
private String vmType = null;
private String vmCount = null;
- public SdncVFCModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, DBResourceManager jdbcDataSource) {
+ public SdncVFCModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
- super(sdcCsarHelper, nodeTemplate, jdbcDataSource);
+ super(sdcCsarHelper, entityDetails, jdbcDataSource, config);
// extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue (nodeTemplate, "nfc_naming#ecomp_generated_naming"));
- addParameter("naming_policy", extractValue (nodeTemplate, "nfc_naming#naming_policy"));
- vmCount = extractValue (nodeTemplate, "service_template_filter#count"); // need path to vm_count, extracted as service_template_filter#count
+ addParameter("ecomp_generated_naming", extractBooleanValue (entityDetails, "nfc_naming", "ecomp_generated_naming"));
+ addParameter("naming_policy", extractValue (entityDetails, "nfc_naming", "naming_policy"));
+ vmCount = extractValue (entityDetails, "service_template_filter", "count"); // need path to vm_count, extracted as service_template_filter#count
if (vmCount.isEmpty()) {
vmCount = "0"; // vm_count can not be null
}
- vmType = extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG);
+ vmType = extractValue (entityDetails, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG);
addParameter("vm_type", vmType); // populate vm_type with vm_type_tag value
addParameter("vm_type_tag", vmType);
- addParameter("nfc_naming_code", extractValue (nodeTemplate, "nfc_naming_code"));
- addParameter("nfc_function", extractValue (nodeTemplate, "nfc_function"));
- addParameter("high_availability", extractValue (nodeTemplate, "high_availablity"));
- addParameter("vm_image_name", extractValue (nodeTemplate, "vm_image_name"));
- addParameter("vm_flavor_name", extractValue (nodeTemplate, "vm_flavor_name"));
- addParameter("nfc_naming", extractValue (nodeTemplate, "nfc_naming"));
- addParameter("min_instances", extractValue (nodeTemplate, "min_instances"));
- addParameter("max_instances", extractValue (nodeTemplate, "max_instances"));
+ addParameter("nfc_naming_code", extractValue (entityDetails, "nfc_naming_code"));
+ addParameter("nfc_function", extractValue (entityDetails, "nfc_function"));
+ addParameter("high_availability", extractValue (entityDetails, "high_availablity"));
+ addParameter("vm_image_name", extractValue (entityDetails, "vm_image_name"));
+ addParameter("vm_flavor_name", extractValue (entityDetails, "vm_flavor_name"));
+ addParameter("nfc_naming", extractValue (entityDetails, "nfc_naming"));
+ addParameter("min_instances", extractValue (entityDetails, "min_instances"));
+ addParameter("max_instances", extractValue (entityDetails, "max_instances"));
}
public void insertVFCModelData () throws IOException {
@@ -78,16 +82,20 @@ public class SdncVFCModel extends SdncBaseModel {
}
- public void insertVFCtoNetworkRoleMappingData (NodeTemplate vfcNode) throws IOException {
-
+ public void insertVFCtoNetworkRoleMappingData (IEntityDetails cvfcEntity) throws IOException {
+
+ // Get the CPs on this VFC - using getEntity
// For each VFC node, get CP properties to insert into VFC_TO_NETWORK_ROLE_MAPPING
// VFC_TO_NETWORK_ROLE_MAPPING: vfc_customization_uuid, network_role, network_role_tag, vm_type, ipv4_count, ipv6_count,
// ipv4_use_dhcp, ipv6_use_dhcp, ipv4_ip_version, ipv6_ip_version, extcp_subnetpool_id
- Map<String,Map<String,Object>> cpPropertiesMap = sdcCsarHelper.getCpPropertiesFromVfcAsObject(vfcNode);
- // DEBUG only
- if (cpPropertiesMap != null && !cpPropertiesMap.toString().contentEquals("{}")) {
- LOG.info("getCpPropertiesFromVfcAsObject for vfc_customization_uuid " + this.getCustomizationUUID() + ": " + cpPropertiesMap.toString());
+ String vfcCustomizationUuid = getCustomizationUUID().replace("\"", "");
+ EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
+ TopologyTemplateQuery topologyTemplateQueryVFC = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(vfcCustomizationUuid).build();
+ List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVFC, true);
+ if (cpEntities == null || cpEntities.isEmpty()) {
+ LOG.info("insertVFCtoNetworkRoleMappingData: Could not find the nested CVFCs for: " + vfcCustomizationUuid);
+ return;
}
// Clean up all VFC_TO_NETWORK_ROLE_MAPPING data for this VFC node
@@ -96,165 +104,147 @@ public class SdncVFCModel extends SdncBaseModel {
} catch (IOException e) {
LOG.error("Could not clean up data in VFC_TO_NETWORK_ROLE_MAPPING table ", e);
}
-
- // There will be a cpPropertiesMap entry for each CP which will contain a map of properties to be inserted into VFC_TO_NETWORK_ROLE_MAPPING
+
// There can be multiple insertions per CP:
// Insert once for each unique IP Version / Subnet Role combination per CP (network_role)
- // If there are IPV4 and IPV6 ip_requirements elements that have the same subnet_role (within a CP) combine those parameters for one insert
- for (String nodeMapKey : cpPropertiesMap.keySet()) { // there will be one entry in this map per CP (network_role)
- LOG.debug("node key = " + nodeMapKey);
- Map<String,Object> propsMap = cpPropertiesMap.get(nodeMapKey);
- Map<String, String> commonParams = new HashMap<String, String>(); // non-IP Version specific parameters
+ for (IEntityDetails cpEntity : cpEntities) {
+ // Extract common parameters
+ Map<String, String> commonParams = new HashMap<String, String>(); // non-IP Version specific parameters
// Get vm_type from VFC node
- SdncBaseModel.addParameter("vm_type", getVmType(), commonParams);
+ addParameter("vm_type", getVmType(), commonParams);
- // Extract non-IP Version specific parameters
- String networkRole = nullCheck(propsMap.get("network_role")).isEmpty() ? "default-network-role" : nullCheck(propsMap.get("network_role"));
- SdncBaseModel.addParameter("network_role", networkRole, commonParams); // can not be null
- SdncBaseModel.addParameter("network_role_tag", nullCheck(propsMap.get("network_role_tag")), commonParams);
- SdncBaseModel.addParameter("extcp_subnetpool_id", nullCheck(propsMap.get("subnetpoolid")), commonParams);
-
- // Loop thru all CPs using getNodeTemplateChildren and match the network_role on the CP with network_role from
- // getCpPropertiesFromVfcAsObject output, then get subinterface_indicator for this CP
- List<NodeTemplate> cpNodesList = sdcCsarHelper.getNodeTemplateChildren(vfcNode);
- for (NodeTemplate cpNode : cpNodesList){
- String cpNetworkRole = extractValue(cpNode, "network_role");
-
- if (cpNetworkRole == networkRole) {
- String subinterfaceIndicator = extractBooleanValue (cpNode, "subinterface_indicator");
- addParameter("subinterface_indicator", subinterfaceIndicator, commonParams);
- }
- }
-
- // Extract IP Version specific parameters
- String ipRequirementsString = nullCheck(propsMap.get("ip_requirements"));
- //ArrayList<Map<String, Object>> ipPropsList = (ArrayList<Map<String, Object>>) propsMap.get("ip_requirements");
- ArrayList<Map<String, Object>> ipPropsList = new ArrayList<Map<String, Object>>();
-
- if (!ipRequirementsString.equals("{}")) {
- ipPropsList = (ArrayList<Map<String, Object>>) propsMap.get("ip_requirements");
- }
+ // Extract non-IP Version specific parameters - outside the ip_requirements block
+ String networkRole = extractValue(cpEntity, "network_role").isEmpty() ? "default-network-role" : extractValue(cpEntity, "network_role"); // set default-network-role?
+ addParameter("network_role", networkRole, commonParams); // can not be null
+ addParameter("network_role_tag", nullCheck(extractValue(cpEntity, "network_role_tag")), commonParams);
+ addParameter("extcp_subnetpool_id", nullCheck(extractValue(cpEntity, "subnetpoolid")), commonParams);
+ String subinterfaceIndicator = extractBooleanValue (cpEntity, "subinterface_indicator");
+ addParameter("subinterface_indicator", subinterfaceIndicator, commonParams);
// Build lists of all IPV4 and IPV6 ip_requirements elements
ArrayList<Map<String, String>> ipv4PropParamsList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> ipv6PropParamsList = new ArrayList<Map<String, String>>();
-
- if (ipPropsList != null) {
- for (Map<String, Object> ipPropMap : ipPropsList) {
- //LOG.info("ip_requirements prop map = " + nullCheck(ipPropMap));
-
- String ipVersion = nullCheck(ipPropMap.get("ip_version"));
- if (ipVersion == null) {
- LOG.error("SdncVFCModel: ipVersion not included in ip_requirements element");
- continue;
- }
-
- String subnetRole = nullCheck(ipPropMap.get("subnet_role"));
-
- if (ipVersion.contains("4")) {
+
+ // Extract IP Version specific parameters
+ if (cpEntity.getProperties().containsKey("ip_requirements")) {
+
+ ArrayList<Map<String, Object>> ipPropsList = new ArrayList<Map<String, Object>>();
+ ipPropsList = (ArrayList<Map<String, Object>>) cpEntity.getProperties().get("ip_requirements").getValue();
+
+ if (ipPropsList != null) {
+ for (Map<String, Object> ipPropMap : ipPropsList) {
+ //LOG.info("ip_requirements prop map = " + nullCheck(ipPropMap));
+
+ String ipVersion = nullCheck(ipPropMap.get("ip_version"));
+ if (ipVersion == null) {
+ LOG.error("SdncVFCModel: ipVersion not included in ip_requirements element");
+ continue;
+ }
- // If we have already encountered this subnetRole for IPV4, skip this ip_requirements element
- if (!ipPropParamsMapContainsSubnetRole (ipv4PropParamsList, subnetRole)) {
+ String subnetRole = nullCheck(ipPropMap.get("subnet_role"));
- Map<String, String> ipv4PropParams = new HashMap<String, String>();
- SdncBaseModel.addParameter("ipv4_ip_version", ipVersion, ipv4PropParams);
- SdncBaseModel.addParameter("ipv4_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv4PropParams);
- Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
- if (ipCountRequired != null && ipCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv4_count", nullCheck(ipCountRequired.get("count")), ipv4PropParams);
- }
- Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
- if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv4_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv4PropParams);
- }
- SdncBaseModel.addParameter("ipv4_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv4PropParams);
- SdncBaseModel.addParameter("ipv4_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv4PropParams);
- SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv4PropParams);
-
- ipv4PropParamsList.add(ipv4PropParams);
+ if (ipVersion.contains("4")) {
+
+ // If we have already encountered this subnetRole for IPV4, skip this ip_requirements element
+ if (!ipPropParamsMapContainsSubnetRole (ipv4PropParamsList, subnetRole)) {
- } else {
- LOG.error("SdncVFCModel: Additional V4 ip-requirements element encountered for this subnet_role: ", subnetRole);
- }
+ Map<String, String> ipv4PropParams = new HashMap<String, String>();
+ SdncBaseModel.addParameter("ipv4_ip_version", ipVersion, ipv4PropParams);
+ SdncBaseModel.addParameter("ipv4_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv4PropParams);
+ Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
+ if (ipCountRequired != null && ipCountRequired.get("count") != null) {
+ SdncBaseModel.addParameter("ipv4_count", nullCheck(ipCountRequired.get("count")), ipv4PropParams);
+ }
+ Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
+ if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
+ SdncBaseModel.addParameter("ipv4_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv4PropParams);
+ }
+ SdncBaseModel.addParameter("ipv4_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv4PropParams);
+ SdncBaseModel.addParameter("ipv4_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv4PropParams);
+ SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv4PropParams);
+
+ ipv4PropParamsList.add(ipv4PropParams);
+
+ } else {
+ LOG.error("SdncVFCModel: Additional V4 ip-requirements element encountered for this subnet_role: ", subnetRole);
+ }
- } else if (ipVersion.contains("6")) {
+ } else if (ipVersion.contains("6")) {
- // If we have already encountered this subnetRole for IPV6, skip this ip_requirements element
- if (!ipPropParamsMapContainsSubnetRole (ipv6PropParamsList, subnetRole)) {
-
- Map<String, String> ipv6PropParams = new HashMap<String, String>();
- SdncBaseModel.addParameter("ipv6_ip_version", ipVersion, ipv6PropParams);
- SdncBaseModel.addParameter("ipv6_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv6PropParams);
- Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
- if (ipCountRequired != null && ipCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv6_count", nullCheck(ipCountRequired.get("count")), ipv6PropParams);
- }
- Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
- if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv6_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv6PropParams);
- }
- SdncBaseModel.addParameter("ipv6_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv6PropParams);
- SdncBaseModel.addParameter("ipv6_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv6PropParams);
- SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv6PropParams);
+ // If we have already encountered this subnetRole for IPV6, skip this ip_requirements element
+ if (!ipPropParamsMapContainsSubnetRole (ipv6PropParamsList, subnetRole)) {
- ipv6PropParamsList.add(ipv6PropParams);
-
- } else {
- LOG.error("SdncVFCModel: Additional V6 ip-requirements element encountered for this subnetRole: ", subnetRole);
- }
-
- } else {
- LOG.error("SdncVFCModel: invalid IP version encountered: ", ipVersion);
- }
-
- } // for each ip-requirements element
-
- } // ipPropsList null check
-
- // After all Common and IP Version specific parameters are extracted, insert IPV4 and IPV6 data separately
- // Insert IPV4 data
- for (Map<String, String> ipv4PropParams: ipv4PropParamsList) {
-
- Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
- addParamsToMap(commonParams, mappingParams);
- addParamsToMap(ipv4PropParams, mappingParams);
+ Map<String, String> ipv6PropParams = new HashMap<String, String>();
+ SdncBaseModel.addParameter("ipv6_ip_version", ipVersion, ipv6PropParams);
+ SdncBaseModel.addParameter("ipv6_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv6PropParams);
+ Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
+ if (ipCountRequired != null && ipCountRequired.get("count") != null) {
+ SdncBaseModel.addParameter("ipv6_count", nullCheck(ipCountRequired.get("count")), ipv6PropParams);
+ }
+ Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
+ if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
+ SdncBaseModel.addParameter("ipv6_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv6PropParams);
+ }
+ SdncBaseModel.addParameter("ipv6_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv6PropParams);
+ SdncBaseModel.addParameter("ipv6_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv6PropParams);
+ SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv6PropParams);
- // Insert ipv4PropParams into VFC_TO_NETWORK_ROLE_MAPPING
- try {
- LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
- addRequiredParameters(mappingParams);
- insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
-
- }
+ ipv6PropParamsList.add(ipv6PropParams);
+
+ } else {
+ LOG.error("SdncVFCModel: Additional V6 ip-requirements element encountered for this subnetRole: ", subnetRole);
+ }
+
+ } else {
+ LOG.error("SdncVFCModel: invalid IP version encountered: ", ipVersion);
+ }
+
+ } // for each ip-requirements element
+
+ } // ipPropsList null check
- // Insert IPV6 data
- for (Map<String, String> ipv6PropParams: ipv6PropParamsList) {
-
- Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
- addParamsToMap(commonParams, mappingParams);
- addParamsToMap(ipv6PropParams, mappingParams);
-
- // Insert ipv6PropParams into VFC_TO_NETWORK_ROLE_MAPPING
- try {
- LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
- addRequiredParameters(mappingParams);
- insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
+ // After all Common and IP Version specific parameters are extracted, insert IPV4 and IPV6 data separately
+ // Insert IPV4 data
+ for (Map<String, String> ipv4PropParams: ipv4PropParamsList) {
+
+ Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
+ addParamsToMap(commonParams, mappingParams);
+ addParamsToMap(ipv4PropParams, mappingParams);
+
+ // Insert ipv4PropParams into VFC_TO_NETWORK_ROLE_MAPPING
+ try {
+ LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
+ addRequiredParameters(mappingParams);
+ insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
+ } catch (IOException e) {
+ LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
+ throw new IOException (e);
+ }
+
+ }
- }
-
- } // Outer map loop - one per ExtCP
-
+ // Insert IPV6 data
+ for (Map<String, String> ipv6PropParams: ipv6PropParamsList) {
+
+ Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
+ addParamsToMap(commonParams, mappingParams);
+ addParamsToMap(ipv6PropParams, mappingParams);
+
+ // Insert ipv6PropParams into VFC_TO_NETWORK_ROLE_MAPPING
+ try {
+ LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
+ addRequiredParameters(mappingParams);
+ insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
+ } catch (IOException e) {
+ LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
+ throw new IOException (e);
+ }
+ }
+ }
+ }
}
-
+
protected boolean ipPropParamsMapContainsSubnetRole (ArrayList<Map<String, String>> ipPropParamsList, String subnetRole) {
boolean subnetRoleFound = false;
@@ -281,70 +271,74 @@ public class SdncVFCModel extends SdncBaseModel {
}
}
- public void insertVFCRelatedNetworkRoleData (String vfCustomizationUUID, NodeTemplate vfcNode) throws IOException {
+ public void insertVFCRelatedNetworkRoleData (String vfCustomizationUUID, IEntityDetails cvfcEntity) throws IOException {
- // Get the CPs on this VFC - ASDC suggests getNodeTemplateChildren
- List<NodeTemplate> cpNodesList = sdcCsarHelper.getNodeTemplateChildren(vfcNode);
+ // Get the CPs on this VFC - using getEntity
- String vfcCustomizationUuid = getCustomizationUUID();
+ String vfcCustomizationUuid = getCustomizationUUID().replace("\"", "");
+ // Get the CPs on this VFC - ASDC suggests getNodeTemplateChildren
+ //List<NodeTemplate> cpNodesList = sdcCsarHelper.getNodeTemplateChildren(vfcNode);
+ EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
+ TopologyTemplateQuery topologyTemplateQueryVFC = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(vfcCustomizationUuid).build();
+ List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVFC, true);
+ if (cpEntities == null || cpEntities.isEmpty()) {
+ LOG.info("insertVFCRelatedNetworkRoleData: Could not find the nested CVFCs for: " + vfcCustomizationUuid);
+ return;
+ }
try {
- cleanUpExistingToscaData("VFC_RELATED_NETWORK_ROLE", "vfc_customization_uuid", vfcCustomizationUuid);
+ cleanUpExistingToscaData("VFC_RELATED_NETWORK_ROLE", "vfc_customization_uuid", getCustomizationUUID());
} catch (IOException e) {
LOG.error("Could not clean up Tosca CSAR data in the VFC_RELATED_NETWORK_ROLE table");
throw new IOException (e);
}
- for (NodeTemplate cpNode : cpNodesList){
- String networkRole = extractValue(cpNode, "network_role");
+ for (IEntityDetails cpEntity : cpEntities){
+ String networkRole = extractValue(cpEntity, "network_role");
Map<String, String> relatedNetworkRoleParams = new HashMap<String, String>();
- addParameter("vfc_customization_uuid", vfcCustomizationUuid, relatedNetworkRoleParams);
+ addParameter("vfc_customization_uuid", getCustomizationUUID(), relatedNetworkRoleParams);
addParameter("vm_type", vmType, relatedNetworkRoleParams);
addParameter("network_role", networkRole, relatedNetworkRoleParams);
-
- final Object relatedNetworksPropertyValue = cpNode.getPropertyValue("related_networks");
-
- ArrayList<Map<String, String>> relatedNetworkList = (ArrayList)relatedNetworksPropertyValue;
- if (relatedNetworkList != null) {
- for (Map<String, String> relatedNetworkValue : relatedNetworkList) {
- LOG.debug("CP [" + cpNode.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkValue.get("related_network_role"));
- String relatedNetworkRoleValue = relatedNetworkValue.get("related_network_role");
-
- try {
- // Table cleanup for VFC_RELATED_NETWORK_ROLE occurs per vfc
- // If cp related_network_role, cp network_role and vm_type for this vfc already exist in VFC_RELATED_NETWORK_ROLE,
- // don't attempt insertion
- Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
- addParamsToMap(relatedNetworkRoleParams, relatedNetworkRoleParamsCheck);
- addParameter("related_network_role", relatedNetworkRoleValue, relatedNetworkRoleParamsCheck);
- if (checkForExistingToscaData("VFC_RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) {
- LOG.info("Call insertToscaData for VFC_RELATED_NETWORK_ROLE where vfc_customization_uuid = " + vfcCustomizationUuid);
- insertToscaData(buildSql("VFC_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRoleValue + "\"", model_yaml, relatedNetworkRoleParams), null);
- }
+
+ if (cpEntity.getProperties().containsKey("related_networks")) {
+
+ Property relatedNetworksProperty = cpEntity.getProperties().get("related_networks");
+ List<String> relatedNetworkRoles = relatedNetworksProperty.getLeafPropertyValue("related_network_role");
+
+ for (String relatedNetworkRole : relatedNetworkRoles) {
+ LOG.debug("CP [" + cpEntity.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkRole);
+
+ try {
+ // Table cleanup for VFC_RELATED_NETWORK_ROLE occurs per vfc
+ // If cp related_network_role, cp network_role and vm_type for this vfc already exist in VFC_RELATED_NETWORK_ROLE,
+ // don't attempt insertion
+ Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
+ addParamsToMap(relatedNetworkRoleParams, relatedNetworkRoleParamsCheck);
+ addParameter("related_network_role", relatedNetworkRole, relatedNetworkRoleParamsCheck);
+ if (checkForExistingToscaData("VFC_RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) {
+ LOG.info("Call insertToscaData for VFC_RELATED_NETWORK_ROLE where vfc_customization_uuid = " + getCustomizationUUID());
+ insertToscaData(buildSql("VFC_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRole + "\"", model_yaml, relatedNetworkRoleParams), null);
+ }
- // Table cleanup for VNF_RELATED_NETWORK_ROLE occurs per vf (up one level)
- // Insert same related_network_role data into VNF_RELATED_NETWORK_ROLE
- Map<String, String> vfRelatedNetworkRoleParamsCheck = new HashMap<String, String>();
- addParameter("vnf_customization_uuid", vfCustomizationUUID, vfRelatedNetworkRoleParamsCheck);
- addParameter("network_role", networkRole, vfRelatedNetworkRoleParamsCheck);
- addParameter("related_network_role", relatedNetworkRoleValue, vfRelatedNetworkRoleParamsCheck);
- if (checkForExistingToscaData("VNF_RELATED_NETWORK_ROLE", vfRelatedNetworkRoleParamsCheck) == false) {
- vfRelatedNetworkRoleParamsCheck.remove("related_network_role");
- LOG.info("Call insertToscaData for VNF_RELATED_NETWORK_ROLE where vnf_customization_uuid = " + vfCustomizationUUID);
- insertToscaData(buildSql("VNF_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRoleValue + "\"", model_yaml, vfRelatedNetworkRoleParamsCheck), null);
- }
+ // Table cleanup for VNF_RELATED_NETWORK_ROLE occurs per vf (up one level)
+ // Insert same related_network_role data into VNF_RELATED_NETWORK_ROLE
+ Map<String, String> vfRelatedNetworkRoleParamsCheck = new HashMap<String, String>();
+ addParameter("vnf_customization_uuid", vfCustomizationUUID, vfRelatedNetworkRoleParamsCheck);
+ addParameter("network_role", networkRole, vfRelatedNetworkRoleParamsCheck);
+ addParameter("related_network_role", relatedNetworkRole, vfRelatedNetworkRoleParamsCheck);
+ if (checkForExistingToscaData("VNF_RELATED_NETWORK_ROLE", vfRelatedNetworkRoleParamsCheck) == false) {
+ vfRelatedNetworkRoleParamsCheck.remove("related_network_role");
+ LOG.info("Call insertToscaData for VNF_RELATED_NETWORK_ROLE where vnf_customization_uuid = " + vfCustomizationUUID);
+ insertToscaData(buildSql("VNF_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRole + "\"", model_yaml, vfRelatedNetworkRoleParamsCheck), null);
+ }
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }
- }
- }
- else {
- LOG.debug("CP [" + cpNode.getName() + "], property [" + "related_networks" + "] property value: " + null);
- }
+ } catch (IOException e) {
+ LOG.error("Could not insert Tosca CSAR data into the VFC_RELATED_NETWORK_ROLE table");
+ throw new IOException (e);
+ }
+ }
+ }
}
-
}
public String getVmType() {
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
index 12eccf21..d6a09317 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
@@ -22,7 +22,6 @@
package org.onap.ccsdk.sli.northbound.uebclient;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -141,8 +140,8 @@ public class SdncVFModel extends SdncBaseModel {
// Insert each VF Module group (entity) into VF_MODULE_MODEL if its name is prefixed with the VF name
for (IEntityDetails vfModule : vfModules){
- // If this vfModule name is prefixed with the VF name of the VF bing processed, insert this VF Module in VF_MODULE_MODEL
- String normailizedVfName = nodeTemplate.getName().toLowerCase().replace(" ", "");
+ // If this vfModule name is prefixed with the VF name of the VF being processed, insert this VF Module in VF_MODULE_MODEL
+ String normailizedVfName = nodeTemplate.getName().toLowerCase().replace(" ", "").replace("-", ""); // need full set of normalization rules from ASDC
if (!vfModule.getName().startsWith(normailizedVfName)) {
continue;
}
@@ -169,7 +168,7 @@ public class SdncVFModel extends SdncBaseModel {
.build();
List<IEntityDetails> vfModulesNonCatalog = sdcCsarHelper.getEntity(entityQuery2, topologyTemplateQuery2, false);
if (vfModulesNonCatalog == null || vfModulesNonCatalog.isEmpty()) {
- LOG.info("insertVFModuleDataGetEntity2: Could not find the non-catelog VF Module for: " + vfModuleModel.getCustomizationUUID() + ". Unable to insert members into VF_MODULE_TO_VFC_MAPPING");
+ LOG.info("insertVFModuleData: Could not find the non-catelog VF Module for: " + vfModuleModel.getCustomizationUUID() + ". Unable to insert members into VF_MODULE_TO_VFC_MAPPING");
continue;
}
@@ -184,10 +183,7 @@ public class SdncVFModel extends SdncBaseModel {
String vfcVmType = extractValue (vfModuleMember, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG); // extracted as vm_type_tag
String vfcVmCount = "";
if (vfModuleMember.getProperties().containsKey("service_template_filter")) {
- Property property = vfModuleMember.getProperties().get("service_template_filter");
- if (property != null && property.getLeafPropertyValue("count") != null) {
- vfcVmCount = property.getLeafPropertyValue("count").get(0);
- }
+ vfcVmCount = extractIntegerValue (vfModuleMember.getProperties().get("service_template_filter"), "count");
}
if (vfcVmCount.isEmpty()) {
vfcVmCount = "0"; // vm_count can not be null
@@ -210,7 +206,7 @@ public class SdncVFModel extends SdncBaseModel {
.build();
List<IEntityDetails> nestedCvfcs = sdcCsarHelper.getEntity(entityQuery3, topologyTemplateQuery3, true); // true allows for nested search
if (nestedCvfcs == null || nestedCvfcs.isEmpty()) {
- LOG.info("insertVFModuleDataGetEntity2: Could not find the nested CVFCs for: " + cvfcCustomizationUuid);
+ LOG.info("insertVFModuleData: Could not find the nested CVFCs for: " + cvfcCustomizationUuid);
continue;
}
@@ -221,10 +217,7 @@ public class SdncVFModel extends SdncBaseModel {
String nestedVfcVmType = extractValue (nestedCvfc, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG); // extracted as vm_type_tag
String nestedVfcVmCount = "";
if (nestedCvfc.getProperties().containsKey("service_template_filter")) {
- Property property = nestedCvfc.getProperties().get("service_template_filter");
- if (property != null && property.getLeafPropertyValue("count") != null) {
- nestedVfcVmCount = property.getLeafPropertyValue("count").get(0);
- }
+ nestedVfcVmCount = extractIntegerValue (nestedCvfc.getProperties().get("service_template_filter"), "count");
}
if (nestedVfcVmCount.isEmpty()) {
nestedVfcVmCount = "0"; // vm_count can not be null
@@ -237,16 +230,11 @@ public class SdncVFModel extends SdncBaseModel {
} catch (IOException e) {
LOG.error("Could not insert Tosca CSAR data into the VF_MODULE_TO_VFC_MAPPING table");
throw new IOException (e);
- }
-
- }
-
- }
-
- }
-
- }
-
+ }
+ }
+ }
+ } // For each VF Module member
+ } // For each VF Module
}
private void insertVFtoNetworkRoleMappingData () throws IOException {
@@ -259,11 +247,16 @@ public class SdncVFModel extends SdncBaseModel {
throw new IOException (e);
}
- // For this VF, insert VF_TO_NETWORK_ROLE_MAPPING data
+ // For this VF, insert VF_TO_NETWORK_ROLE_MAPPING data. network_role is a property on the CPs for this VF.
+ // Use getEntity to extract all the CPs on this VF
EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
TopologyTemplateQuery topologyTemplateQueryVF = TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(getCustomizationUUIDNoQuotes()).build();
List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVF, true);
-
+ if (cpEntities == null || cpEntities.isEmpty()) {
+ LOG.info("insertVFtoNetworkRoleMappingData: Could not find CPs for VF: " + getCustomizationUUIDNoQuotes());
+ return;
+ }
+
for (IEntityDetails entity: cpEntities ) {
Map<String, Property> properties = entity.getProperties();
@@ -310,21 +303,35 @@ public class SdncVFModel extends SdncBaseModel {
throw new IOException (e);
}*/
- // For each VF, insert VFC_MODEL data
- List<NodeTemplate> vfcNodes = sdcCsarHelper.getVfcListByVf(getCustomizationUUIDNoQuotes());
- for (NodeTemplate vfcNode : vfcNodes){
+ // Get any CVFCs under this VF (top-level and nested)
+ String vfCustomizationUid = customizationUUID;
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID(vfCustomizationUid) // customization UUID of the VF if exists
+ .build();
+ List<IEntityDetails> cvfcEntities = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, true); // true allows for nested search
+ if (cvfcEntities == null || cvfcEntities.isEmpty()) {
+ LOG.info("insertVFCDataEntity: Could not find the CVFCs for: " + vfCustomizationUid);
+ }
+
+ for (IEntityDetails cvfcEntity: cvfcEntities) {
+ // Insert this CVFC data into VFC_MODEL
try {
- SdncVFCModel vfcModel = new SdncVFCModel(sdcCsarHelper, vfcNode, jdbcDataSource);
+
+ SdncVFCModel vfcModel = new SdncVFCModel(sdcCsarHelper, cvfcEntity, jdbcDataSource, config);
vfcModel.insertVFCModelData();
- vfcModel.insertVFCtoNetworkRoleMappingData(vfcNode);
- //vfcModel.insertVFCRelatedNetworkRoleData(getCustomizationUUID(), vfcNode);
+ vfcModel.insertVFCtoNetworkRoleMappingData(cvfcEntity);
+ //vfcModel.insertVFCRelatedNetworkRoleData(getCustomizationUUID(), cvfcEntity);
+
} catch (IOException e) {
LOG.error("Could not insert Tosca CSAR VFC data");
throw new IOException (e);
}
}
+
}
public void insertVFCInstanceGroupData () throws IOException {
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java
index f9a03b3f..ef815d02 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java
@@ -25,17 +25,21 @@ package org.onap.ccsdk.sli.northbound.uebclient;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.Group;
public class SdncVFModuleModel extends SdncBaseModel {
public SdncVFModuleModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails vfModule, SdncVFModel vfNodeModel) {
super(sdcCsarHelper, vfModule);
- // override base implementation for setting customizationUUID because customizationUUID is called differently for Groups
+ // override base implementation for setting metadata because properties are called differently for Groups
customizationUUID = extractValue (vfModule.getMetadata(), "vfModuleModelCustomizationUUID");
+ invariantUUID = extractValue (vfModule.getMetadata(), "vfModuleModelInvariantUUID");
UUID = extractValue (vfModule.getMetadata(), "vfModuleModelUUID");
+ version = extractValue (vfModule.getMetadata(), "vfModuleModelVersion");
addParameter("vf_customization_uuid", vfNodeModel.getCustomizationUUIDNoQuotes());
+ addParameter("invariant_uuid", invariantUUID);
+ addParameter("uuid", UUID);
+ addParameter("version", version);
// extract properties
addParameter("vf_module_type", extractValue(vfModule, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE));
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
index ea6499cd..734dee22 100644
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
+++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
@@ -7,9 +7,10 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
- import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
- import org.onap.sdc.toscaparser.api.NodeTemplate;
- import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
public class SdncARModelTest {
@@ -19,8 +20,11 @@ import org.junit.Test;
public void setUp() throws Exception {
ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
NodeTemplate nodeTemplate = mock(NodeTemplate.class);
+ IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- testSdncARModel = new SdncARModel(mockCsarHelper,nodeTemplate,mockDBResourceManager);
+ SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+
+ testSdncARModel = new SdncARModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
assertNotNull(testSdncARModel);
}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
index 46931235..768eed86 100644
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
+++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
@@ -10,7 +10,8 @@ import java.util.HashMap;
import java.util.ArrayList;
import org.junit.Before;
-import org.junit.Test;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
@@ -20,16 +21,20 @@ public class SdncVFCModelTest {
SdncVFCModel testSdncVFCModel;
NodeTemplate mockVFCNodeTemplate = null;
+ IEntityDetails mockEntityDetails = null;
@Before
public void setup() {
ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
NodeTemplate mockNodeTemplate = mock(NodeTemplate.class);
+ mockEntityDetails = mock(IEntityDetails.class);
mockVFCNodeTemplate = mock(NodeTemplate.class);
Metadata mockMetadata = mock(Metadata.class);
DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
when(mockNodeTemplate.getMetaData()).thenReturn(mockMetadata);
+ when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
when(mockCsarHelper.getNodeTemplatePropertyLeafValue(mockNodeTemplate, "nfc_naming_code")).thenReturn("test-nfc-naming-code");
@@ -50,9 +55,14 @@ public class SdncVFCModelTest {
cpPropertiesMap.put("cp-node-1", propertiesMap);
when(mockCsarHelper.getCpPropertiesFromVfcAsObject(mockVFCNodeTemplate)).thenReturn(cpPropertiesMap);
- testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockNodeTemplate, mockDBResourceManager);
- testSdncVFCModel.setVmType("Test-type");
- testSdncVFCModel.setVmCount("5");
+ try {
+ testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockEntityDetails, mockDBResourceManager, mockSdncUebConfiguration);
+ testSdncVFCModel.setVmType("Test-type");
+ testSdncVFCModel.setVmCount("5");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
@@ -83,7 +93,7 @@ public class SdncVFCModelTest {
@Test
public void testInsertVFCtoNetworkRoleMappingData() {
try {
- testSdncVFCModel.insertVFCtoNetworkRoleMappingData(mockVFCNodeTemplate);
+ testSdncVFCModel.insertVFCtoNetworkRoleMappingData(mockEntityDetails);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();