aboutsummaryrefslogtreecommitdiffstats
path: root/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java')
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java414
1 files changed, 204 insertions, 210 deletions
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() {