use of org.onap.sdc.tosca.parser.api.IEntityDetails in project so by onap.
the class ToscaResourceInstaller method getVNFCGroupSequenceList.
private void getVNFCGroupSequenceList(List<String> strSequence, List<IEntityDetails> vnfcGroupDetails, List<IEntityDetails> vnfcMemberNodes, ISdcCsarHelper iSdcCsarHelper) {
if (CollectionUtils.isEmpty(vnfcGroupDetails)) {
return;
}
List<IEntityDetails> tempGroupList = new ArrayList<>();
tempGroupList.addAll(vnfcGroupDetails);
for (IEntityDetails vnfcGroup : vnfcGroupDetails) {
List<IEntityDetails> members = vnfcGroup.getMemberNodes();
for (IEntityDetails memberNode : members) {
boolean isAllExists = true;
List<RequirementAssignment> requirements = memberNode.getRequirements();
if (requirements == null || requirements.isEmpty()) {
continue;
}
for (RequirementAssignment rqa : requirements) {
String name = rqa.getNodeTemplateName();
for (IEntityDetails node : vnfcMemberNodes) {
if (name.equals(node.getName())) {
break;
}
}
isAllExists = false;
break;
}
if (isAllExists) {
strSequence.add(vnfcGroup.getName());
tempGroupList.remove(vnfcGroupDetails);
vnfcMemberNodes.addAll(vnfcGroupDetails);
}
}
if (!tempGroupList.isEmpty() && tempGroupList.size() < vnfcGroupDetails.size()) {
getVNFCGroupSequenceList(strSequence, tempGroupList, vnfcMemberNodes, iSdcCsarHelper);
}
}
}
use of org.onap.sdc.tosca.parser.api.IEntityDetails in project so by onap.
the class ToscaResourceInstaller method getRequirementList.
List<IEntityDetails> getRequirementList(List<IEntityDetails> resultList, List<IEntityDetails> entityDetails, ISdcCsarHelper iSdcCsarHelper) {
List<IEntityDetails> entities = new ArrayList<>();
entityDetails.addAll(entityDetails);
for (IEntityDetails entity : entityDetails) {
List<RequirementAssignment> requirements = entity.getRequirements();
for (RequirementAssignment ra : requirements) {
String reqNode = ra.getNodeTemplateName();
for (IEntityDetails rEntity : resultList) {
if (rEntity.getName().equals(reqNode)) {
if (!resultList.contains(entityDetails)) {
resultList.add(entity);
}
if (entities.contains(entityDetails)) {
entities.remove(entityDetails);
}
break;
}
}
}
}
if (!entities.isEmpty()) {
getRequirementList(resultList, entities, iSdcCsarHelper);
}
return resultList;
}
use of org.onap.sdc.tosca.parser.api.IEntityDetails in project so by onap.
the class ToscaResourceInstaller method createVFModuleResource.
protected VfModuleCustomization createVFModuleResource(IEntityDetails vfModuleEntityDetails, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet, List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) {
VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
if (vfModuleCustomization == null) {
VfModule vfModule = findExistingVfModule(vnfResource, vfModuleEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
Metadata vfMetadata = vfModuleEntityDetails.getMetadata();
if (vfModule == null)
vfModule = createVfModule(vfModuleEntityDetails, toscaResourceStructure, vfModuleData, vfMetadata);
vfModuleCustomization = createVfModuleCustomization(vfModuleEntityDetails, toscaResourceStructure, vfModule, vfModuleData);
vfModuleCustomization.setVnfCustomization(vnfResource);
setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization, vfMetadata);
vfModuleCustomization.setVfModule(vfModule);
vfModule.getVfModuleCustomization().add(vfModuleCustomization);
vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
} else {
vfResourceStructure.setAlreadyDeployed(true);
}
// ******************************************************************************************************************
// * Extract VFC's and CVFC's then add them to VFModule
// ******************************************************************************************************************
List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new ArrayList<>();
List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<>();
Set<VnfcCustomization> vnfcCustomizations = new HashSet<>();
// Only set the CVNFC if this vfModule group is a member of it.
List<IEntityDetails> groupMembers = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder("org.openecomp.groups.VfModule").uUID(vfModuleCustomization.getVfModule().getModelUUID()), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
String vfModuleMemberName = null;
// Extract CVFC lists
List<IEntityDetails> cvnfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
for (IEntityDetails cvfcEntity : cvnfcEntityList) {
boolean cvnfcVfModuleNameMatch = false;
for (IEntityDetails entity : groupMembers) {
List<IEntityDetails> groupMembersNodes = entity.getMemberNodes();
for (IEntityDetails groupMember : groupMembersNodes) {
vfModuleMemberName = groupMember.getName();
if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) {
cvnfcVfModuleNameMatch = true;
break;
}
}
}
if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
// Extract associated VFC - Should always be just one
List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VFC), TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)), false);
for (IEntityDetails vfcEntity : vfcEntityList) {
VnfcCustomization vnfcCustomization = new VnfcCustomization();
VnfcCustomization existingVnfcCustomization = null;
existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
if (existingVnfcCustomization == null) {
vnfcCustomization = new VnfcCustomization();
} else {
vnfcCustomization = existingVnfcCustomization;
}
// Only Add Abstract VNFC's to our DB, ignore all others
if (existingVnfcCustomization == null && vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
vnfcCustomization.setModelCustomizationUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
vnfcCustomization.setModelInstanceName(vfcEntity.getName());
vnfcCustomization.setModelInvariantUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
vnfcCustomization.setModelName(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
vnfcCustomization.setModelUUID(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
vnfcCustomization.setModelVersion(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
vnfcCustomization.setDescription(testNull(vfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
vnfcCustomization.setToscaNodeType(testNull(vfcEntity.getToscaType()));
vnfcCustomizations.add(vnfcCustomization);
existingVnfcSet.add(vnfcCustomization);
}
// skip adding that record to our DB.
if (vnfcCustomization.getModelCustomizationUUID() != null) {
CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
cvnfcCustomization.setModelCustomizationUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
cvnfcCustomization.setModelInstanceName(cvfcEntity.getName());
cvnfcCustomization.setModelInvariantUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
cvnfcCustomization.setModelName(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
cvnfcCustomization.setModelUUID(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
cvnfcCustomization.setModelVersion(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
cvnfcCustomization.setDescription(testNull(cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
cvnfcCustomization.setToscaNodeType(testNull(cvfcEntity.getToscaType()));
if (existingVnfcCustomization != null) {
cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
} else {
cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
}
cvnfcCustomization.setNfcFunction(getLeafPropertyValue(cvfcEntity, "nfc_function"));
cvnfcCustomization.setNfcNamingCode(getLeafPropertyValue(cvfcEntity, "nfc_naming_code"));
cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
// *****************************************************************************************************************************************
// * Extract Fabric Configuration
// *****************************************************************************************************************************************
List<IEntityDetails> fabricEntityList = getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
for (IEntityDetails fabricEntity : fabricEntityList) {
List<RequirementAssignment> requirements = fabricEntity.getRequirements();
for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) {
ConfigurationResource fabricConfig = null;
ConfigurationResource existingConfig = findExistingConfiguration(existingCvnfcConfigurationCustom, fabricEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (existingConfig == null) {
fabricConfig = createFabricConfiguration(fabricEntity, toscaResourceStructure);
} else {
fabricConfig = existingConfig;
}
CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfModuleMemberName);
cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization);
}
}
}
cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
cvnfcCustomizations.add(cvnfcCustomization);
existingCvnfcSet.add(cvnfcCustomization);
}
}
}
}
vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
return vfModuleCustomization;
}
use of org.onap.sdc.tosca.parser.api.IEntityDetails in project so by onap.
the class ToscaResourceInstaller method processNetworkCollections.
protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
List<IEntityDetails> crEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CR), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
if (crEntityList != null) {
for (IEntityDetails ncEntity : crEntityList) {
createNetworkCollection(ncEntity, toscaResourceStruct, service);
collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
instanceGroupRepo.saveAndFlush(networkInstanceGroup);
}
}
}
service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
}
use of org.onap.sdc.tosca.parser.api.IEntityDetails in project so by onap.
the class ToscaResourceInstaller method processServiceProxyAndConfiguration.
protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
List<IEntityDetails> spEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<IEntityDetails> configEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
ServiceProxyResourceCustomization serviceProxy = null;
if (spEntityList != null) {
for (IEntityDetails spEntity : spEntityList) {
serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
serviceProxyList.add(serviceProxy);
for (IEntityDetails configEntity : configEntityList) {
List<RequirementAssignment> requirements = configEntity.getRequirements();
for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList);
Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream().filter(configurationResourceCustomization -> configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())).filter(configurationResourceCustomization -> configurationResourceCustomization.getModelInstanceName().equals(configurationResource.getModelInstanceName())).findFirst();
if (!matchingObject.isPresent()) {
configurationResourceList.add(configurationResource);
}
break;
}
}
}
}
}
service.setConfigurationCustomizations(configurationResourceList);
service.setServiceProxyCustomizations(serviceProxyList);
}
Aggregations