diff options
4 files changed, 129 insertions, 3 deletions
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java index d4b3344ca..667f95aae 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java @@ -22,6 +22,9 @@ package org.onap.ccsdk.sli.northbound.uebclient; import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; @@ -58,6 +61,8 @@ public class SdncNodeModel extends SdncBaseModel { // extract properties - network_assignments addParameter("is_shared_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISSHAREDNETWORK)); addParameter("is_external_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISEXTERNALNETWORK)); + String trunkNetworkIndicator = extractBooleanValue(nodeTemplate, "network_assignments#is_trunked"); + addParameter("trunk_network_indicator", trunkNetworkIndicator); // extract properties - network_assignments - ipv4_subnet_default_assignment String useIpv4 = extractBooleanValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#use_ipv4"); @@ -122,6 +127,50 @@ public class SdncNodeModel extends SdncBaseModel { throw new IOException (e); } } + + public void insertRelatedNetworkRoleData () throws IOException { + + Object propertyValue = sdcCsarHelper.getNodeTemplatePropertyAsObject(nodeTemplate, "network_assignments#related_networks"); + ArrayList<Map<String, String>> relatedNetworkList = (ArrayList)propertyValue; + + String networkModelCustomizationUUID = getCustomizationUUID(); + + if (relatedNetworkList != null) { + + try { + cleanUpExistingToscaData("RELATED_NETWORK_ROLE", "network_model_customization_uuid", networkModelCustomizationUUID); + } catch (IOException e) { + LOG.error("Could not clean up Tosca CSAR data in the RELATED_NETWORK_ROLE table"); + throw new IOException (e); + } + + for (Map<String, String> relatedNetworkValue : relatedNetworkList) { + LOG.debug("Node Template [" + nodeTemplate.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkValue.get("related_network_role")); + + String relatedNetworkRoleValue = relatedNetworkValue.get("related_network_role"); + + try { + // Table cleanup RELATED_NETWORK_ROLE occurs per network + // If related_network_role for this service already exist in RELATED_NETWORK_ROLE, don't attempt insertion + Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>(); + addParameter("related_network_role", relatedNetworkRoleValue, relatedNetworkRoleParamsCheck); + addParameter("network_model_customization_uuid", networkModelCustomizationUUID, relatedNetworkRoleParamsCheck); + if (checkForExistingToscaData("RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) { + relatedNetworkRoleParamsCheck.remove("related_network_role"); + LOG.info("Call insertToscaData for RELATED_NETWORK_ROLE where network_model_customization_uuid = " + networkModelCustomizationUUID); + insertToscaData(buildSql("RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRoleValue + "\"", model_yaml, relatedNetworkRoleParamsCheck), null); + } + } catch (IOException e) { + LOG.debug("Could not insert Tosca CSAR data into the RELATED_NETWORK_ROLE table"); + throw new IOException (e); + } + } + } + else { + LOG.debug("Node Template [" + nodeTemplate.getName() + "], property [" + "related_networks" + "] property value: " + null); + } + + } public String getSql(String model_yaml) { 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 224a51998..3903eb414 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 @@ -710,6 +710,7 @@ public class SdncUebCallback implements INotificationCallback { try { nodeModel.insertNetworkModelData(); + nodeModel.insertRelatedNetworkRoleData(); } 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 db5004309..94392262e 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 @@ -281,6 +281,72 @@ public class SdncVFCModel extends SdncBaseModel { } } + public void insertVFCRelatedNetworkRoleData (String vfCustomizationUUID, NodeTemplate vfcNode) throws IOException { + + // Get the CPs on this VFC - ASDC suggests getNodeTemplateChildren + List<NodeTemplate> cpNodesList = sdcCsarHelper.getNodeTemplateChildren(vfcNode); + + String vfcCustomizationUuid = getCustomizationUUID(); + + try { + cleanUpExistingToscaData("VFC_RELATED_NETWORK_ROLE", "vfc_customization_uuid", vfcCustomizationUuid); + } 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"); + Map<String, String> relatedNetworkRoleParams = new HashMap<String, String>(); + addParameter("vfc_customization_uuid", vfcCustomizationUuid, 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); + } + + // 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); + } + + } 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); + } + } + + } + public String getVmType() { return vmType; } 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 84f8296c9..850a34fa0 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 @@ -79,11 +79,11 @@ public class SdncVFModel extends SdncBaseModel { for (Group group : vfcInstanceGroupListForVf){ String vfcInstanceGroupFunction = extractGetInputValue(group, nodeTemplate, "vfc_instance_group_function"); - addParameter(extractGetInputName (group, "vfc_instance_group_function"), vfcInstanceGroupFunction, attributeValueParams); + addParameter("vfc_instance_group_function", vfcInstanceGroupFunction, attributeValueParams); String networkCollectionFunction = extractGetInputValue(group, nodeTemplate, "network_collection_function"); - addParameter(extractGetInputName (group, "network_collection_function"), networkCollectionFunction, attributeValueParams); + addParameter("network_collection_function", networkCollectionFunction, attributeValueParams); String initSubinterfaceQuantity = extractGetInputValue(group, nodeTemplate, "init_subinterface_quantity"); - addParameter(extractGetInputName (group, "init_subinterface_quantity"), initSubinterfaceQuantity, attributeValueParams); + addParameter("init_subinterface_quantity", initSubinterfaceQuantity, attributeValueParams); } } @@ -185,6 +185,15 @@ public class SdncVFModel extends SdncBaseModel { private void insertVFCData() throws IOException { + /* For each VF, insert VFC_MODEL, VFC_TO_NETWORK_ROLE_MAPPING, VNF_RELATED_NETWORK_ROLE and VFC_RELATED_NETWORK_ROLE data + + try { + cleanUpExistingToscaData("VNF_RELATED_NETWORK_ROLE", "vnf_customization_uuid", getCustomizationUUID()); + } catch (IOException e) { + LOG.error("Could not clean up Tosca CSAR data in the VNF_RELATED_NETWORK_ROLE table"); + throw new IOException (e); + }*/ + // For each VF, insert VFC_MODEL data List<NodeTemplate> vfcNodes = sdcCsarHelper.getVfcListByVf(getCustomizationUUIDNoQuotes()); for (NodeTemplate vfcNode : vfcNodes){ @@ -194,6 +203,7 @@ public class SdncVFModel extends SdncBaseModel { vfcModel.insertVFCModelData(); vfcModel.insertVFCtoNetworkRoleMappingData(vfcNode); + //vfcModel.insertVFCRelatedNetworkRoleData(getCustomizationUUID(), vfcNode); } catch (IOException e) { LOG.error("Could not insert Tosca CSAR VFC data"); throw new IOException (e); |