diff options
Diffstat (limited to 'asdc-controller')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java | 134 | ||||
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java | 16 |
2 files changed, 95 insertions, 55 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 90b705c019..f8d9d6c96c 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -671,7 +671,7 @@ public class ToscaResourceInstaller { logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); @@ -982,7 +982,7 @@ public class ToscaResourceInstaller { return configCustomizationResource; } - protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) { + protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) { Metadata fabricMetadata = nodeTemplate.getMetaData(); @@ -995,23 +995,7 @@ public class ToscaResourceInstaller { configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); configResource.setToscaNodeType(nodeTemplate.getType()); - ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization(); - - Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>(); - - configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - configCustomizationResource.setModelInstanceName(nodeTemplate.getName()); - - configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function")); - configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role")); - configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type")); - configCustomizationResource.setConfigResourceCustomization(configCustomizationResource); - configCustomizationResource.setConfigurationResource(configResource); - configResourceCustomizationSet.add(configCustomizationResource); - - configResource.setConfigurationResourceCustomization(configResourceCustomizationSet); - - return configCustomizationResource; + return configResource; } protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { @@ -1236,16 +1220,32 @@ public class ToscaResourceInstaller { crInstanceGroupCustomization.setModelCustomizationUUID( networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME); - String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed"); - if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - fixedQuantity + "_quantity") != null) { - - crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt( - toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, - fixedQuantity + "_quantity"))); + // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it. + List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed"); + + if(policyList != null){ + for(Policy policy : policyList){ + for(String policyNetworkCollection : policy.getTargets()){ + + if(policyNetworkCollection.equalsIgnoreCase(group.getName())){ + + Map<String, Object> propMap = policy.getPolicyProperties(); + + if(propMap.get("quantity") != null){ + + String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString())); + + if(quantity != null){ + crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity)); + } + + } + + } + } + } } - + crInstanceGroupCustomization.setDescription( toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) @@ -1262,7 +1262,6 @@ public class ToscaResourceInstaller { networkInstanceGroupList.add(networkInstanceGroup); - //} toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList); @@ -1383,7 +1382,7 @@ public class ToscaResourceInstaller { } - protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate, + protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) { @@ -1391,7 +1390,7 @@ public class ToscaResourceInstaller { vfModuleData.getVfModuleModelCustomizationUUID()); if(vfModuleCustomization == null){ VfModule vfModule = findExistingVfModule(vnfResource, - nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); Metadata vfMetadata = group.getMetadata(); if(vfModule==null) vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata); @@ -1413,15 +1412,24 @@ public class ToscaResourceInstaller { Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>(); Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>(); Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>(); + + // Only set the CVNFC if this vfModule group is a member of it. + List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group); + String vfModuleMemberName = null; + + for(NodeTemplate node : groupMembers){ + vfModuleMemberName = node.getName(); + } + // Extract CVFC lists - List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC); + List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC); for(NodeTemplate cvfcTemplate : cvfcList) { - + CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); - if(existingCvnfcCustomization == null){ + if(existingCvnfcCustomization == null && (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName()))){ //Extract associated VFC - Should always be just one List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); @@ -1473,9 +1481,11 @@ public class ToscaResourceInstaller { cvnfcCustomization.setVnfcCustomization(vnfcCustomization); } + cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); + cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfTemplate, "nf_naming_code")); cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - cvnfcCustomization.setVnfResourceCustomization(vnfResource); - + cvnfcCustomization.setVnfResourceCustomization(vnfResource); + cvnfcCustomizations.add(cvnfcCustomization); existingCvnfcSet.add(cvnfcCustomization); @@ -1483,7 +1493,7 @@ public class ToscaResourceInstaller { //* Extract Fabric Configuration //***************************************************************************************************************************************** - List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION); + List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION); for(NodeTemplate fabricTemplate : fabricConfigList) { @@ -1493,18 +1503,14 @@ public class ToscaResourceInstaller { if(existingConfig == null){ - ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure); - - fabricConfig = fabricConfigCustomization.getConfigurationResource(); + fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure); - service.getConfigurationCustomizations().add(fabricConfigCustomization); }else { fabricConfig = existingConfig; - } - + } VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure, - vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig); + vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate); vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization); } @@ -1525,7 +1531,7 @@ public class ToscaResourceInstaller { protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization, - ConfigurationResource configResource) { + ConfigurationResource configResource, NodeTemplate vfTemplate) { Metadata fabricMetadata = fabricTemplate.getMetaData(); @@ -1538,20 +1544,24 @@ public class ToscaResourceInstaller { vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName()); vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization); vfModuleToCvnfc.setVnfResourceCustomization(vnfResource); - vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name")); - List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate); + List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External"); if(policyList != null){ for(Policy policy : policyList){ - vfModuleToCvnfc.setPolicyName(policy.getName()); + + Map<String, Object> propMap = policy.getPolicyProperties(); + + if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){ + vfModuleToCvnfc.setPolicyName(propMap.get("name").toString()); + } } - } - - vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)); - vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)); - vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)); - + } + + vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function")); + vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role")); + vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type")); + return vfModuleToCvnfc; } @@ -1672,7 +1682,7 @@ public class ToscaResourceInstaller { protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization, Metadata vfMetadata) { - + Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream() .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID() .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, @@ -2037,6 +2047,20 @@ public class ToscaResourceInstaller { + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); } + protected String getPropertyInput(String propertyName){ + + String inputName = new String(); + + if (propertyName != null) { + int getInputIndex = propertyName.indexOf("{get_input="); + if (getInputIndex > -1) { + inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1); + } + } + + return inputName; + } + protected static Timestamp getCurrentTimeStamp() { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index 24304ba28c..f886ce7a3e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -313,6 +313,16 @@ public class ASDCNotificationLogging { buffer.append("Description:"); buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); + + List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfNodeTemplate, group); + + for(NodeTemplate node : groupMembers){ + buffer.append("Member Name:"); + buffer.append(testNull(node.getName())); + buffer.append(System.lineSeparator()); + } + + } List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC); @@ -341,6 +351,9 @@ public class ASDCNotificationLogging { buffer.append("Description:"); buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); + buffer.append("Template Name:"); + buffer.append(testNull(cvfcTemplate.getName())); + buffer.append(System.lineSeparator()); List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC); @@ -368,6 +381,9 @@ public class ASDCNotificationLogging { buffer.append("Description:"); buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); buffer.append(System.lineSeparator()); + buffer.append("Sub Category:"); + buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY))); + buffer.append(System.lineSeparator()); } |