import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.api.notification.IStatusData;
+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.CapabilityAssignment;
import org.onap.so.asdc.installer.ASDCElementInfo;
import org.onap.so.asdc.installer.BigDecimalVersion;
import org.onap.so.asdc.installer.IVfModuleData;
+import org.onap.so.asdc.installer.PnfResourceStructure;
+import org.onap.so.asdc.installer.ResourceStructure;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.asdc.installer.VfModuleArtifact;
import org.onap.so.asdc.installer.VfModuleStructure;
import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
import org.onap.so.db.catalog.beans.SubType;
import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
+import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
-import org.onap.so.logger.MsoLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
protected static final String MSO = "SO";
+ protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
+
+ protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
+
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
+
@Autowired
protected ServiceRepository serviceRepo;
@Autowired
protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
+ @Autowired
+ protected PnfResourceRepository pnfResourceRepository;
+
+ @Autowired
+ protected PnfCustomizationRepository pnfCustomizationRepository;
+
protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
boolean status = false;
VfResourceStructure vfResourceStructure = vfResourceStruct;
try {
- status = vfResourceStructure.isDeployedSuccessfully();
+ status = vfResourceStructure.isDeployedSuccessfully();
} catch (RuntimeException e) {
- status = false;
+ status = false;
}
try {
Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
return status;
} catch (Exception e) {
logger
- .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), MsoLogger.ErrorCode.SchemaError.getValue(),
+ .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
"Exception - isResourceAlreadyDeployed");
throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
}
}
}
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+ if (resourceStruct instanceof VfResourceStructure) {
+ installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
+ } else if (resourceStruct instanceof PnfResourceStructure) {
+ installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
+ } else {
+ logger.warn("Unrecognized resource type");
+ }
+ }
+
+ private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, resourceStruct);
+
+ processResourceSequence(toscaResourceStruct, service);
+ processPnfResources(toscaResourceStruct, service, resourceStruct);
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ resourceStruct.getResourceInstance().getResourceName(),
+ resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of " + resourceStruct.getResourceInstance()
+ .getResourceName()
+ + ". Transaction rollback", e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
@Transactional(rollbackFor = { ArtifactInstallerException.class })
- public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
+ public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
throws ArtifactInstallerException {
VfResourceStructure vfResourceStructure = vfResourceStruct;
extractHeatInformation(toscaResourceStruct, vfResourceStructure);
try {
createToscaCsar(toscaResourceStruct);
Service service = createService(toscaResourceStruct, vfResourceStruct);
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+
+ Metadata metadata = nodeTemplate.getMetaData();
+ String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+ String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ }
processResourceSequence(toscaResourceStruct, service);
processVFResources(toscaResourceStruct, service, vfResourceStructure);
|| dbExceptionToCapture instanceof LockAcquisitionException) {
logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
vfResourceStructure.getResourceInstance().getResourceName(),
- vfResourceStructure.getNotification().getServiceVersion(), MsoLogger.ErrorCode.DataError.getValue(),
+ vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
"Exception - ASCDC Artifact already deployed", e);
} else {
String elementToLog = (!artifactListForLogging.isEmpty()
? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
: "No element listed");
logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- MsoLogger.ErrorCode.DataError.getValue(),
+ ErrorCode.DataError.getValue(),
"Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
+ ". Transaction rollback", e);
throw new ArtifactInstallerException("Exception caught during installation of "
logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
}
- private static String CUSTOMIZATION_UUID = "customizationUUID";
-
private static String getValue(Object value, List<Input> servInputs) {
String output = null;
if(value instanceof Map) {
}
}
- protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
- Service service) throws ArtifactInstallerException {
- List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
+ protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
+ Service service) throws ArtifactInstallerException {
+ List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
if (nodeTemplatesVLList != null) {
for (NodeTemplate vlNode : nodeTemplatesVLList) {
- String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp =
- tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
-
- if (tempNetworkLookUp != null) {
- HeatTemplate heatTemplate =
- heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
- if (heatTemplate != null) {
- NetworkResourceCustomization networkCustomization =
- createNetwork (vlNode,
- toscaResourceStruct,
- heatTemplate,
- tempNetworkLookUp.getAicVersionMax (),
- tempNetworkLookUp.getAicVersionMin (),
- service);
- service.getNetworkCustomizations ().add (networkCustomization);
- } else {
- throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
- + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+ String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp =
+ tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
+
+ if (tempNetworkLookUp != null) {
+ HeatTemplate heatTemplate =
+ heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+ if (heatTemplate != null) {
+ NetworkResourceCustomization networkCustomization =
+ createNetwork (vlNode,
+ toscaResourceStruct,
+ heatTemplate,
+ tempNetworkLookUp.getAicVersionMax (),
+ tempNetworkLookUp.getAicVersionMin (),
+ service);
+ service.getNetworkCustomizations ().add (networkCustomization);
+ } else {
+ throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
+ + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
}
} else {
- NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
- toscaResourceStruct,
- null,
- null,
- null,
- service);
- service.getNetworkCustomizations().add (networkCustomization);
- logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
+ toscaResourceStruct,
+ null,
+ null,
+ null,
+ service);
+ service.getNetworkCustomizations().add (networkCustomization);
+ logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ networkResourceModelName);
}
ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
- .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
- .findFirst();
+ .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
+ .findFirst();
if(!matchingObject.isPresent()){
configurationResourceList.add(configurationResource);
}
}
}
+ /**
+ * This is used to process the PNF specific resource, including resource and resource_customization. {@link
+ * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
+ */
+ protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ PnfResourceStructure resourceStructure) throws Exception {
+ logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
+
+ ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+
+ List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+ for (IEntityDetails entityDetails : entityDetailsList) {
+ Metadata metadata = entityDetails.getMetadata();
+ String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
+ if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
+ logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+
+ if (checkExistingPnfResourceCutomization(customizationUUID)) {
+ logger.info("Resource customization UUID: {} already deployed", customizationUUID);
+ } else {
+ PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
+ if (pnfResource == null) {
+ pnfResource = createPnfResource(entityDetails);
+ }
+ PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
+ pnfResource);
+ pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
+ toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
+ service.getPnfCustomizations().add(pnfResourceCustomization);
+ }
+ } else {
+ logger
+ .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+ }
+ }
+ }
+
+ private PnfResource findExistingPnfResource(Service service, String modelUuid) {
+ PnfResource pnfResource = null;
+ for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
+ if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
+ .getModelUUID().equals(modelUuid)) {
+ pnfResource = pnfResourceCustomization.getPnfResources();
+ }
+ }
+ if (pnfResource == null) {
+ pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
+ }
+ return pnfResource;
+ }
+
+ private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
+ return pnfCustomizationRepository.findById(customizationUUID).isPresent();
+ }
+
+ /**
+ * Construct the {@link PnfResource} from {@link IEntityDetails} object.
+ */
+ private PnfResource createPnfResource(IEntityDetails entity) {
+ PnfResource pnfResource = new PnfResource();
+ Metadata metadata = entity.getMetadata();
+ pnfResource.setModelInvariantUUID(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ pnfResource.setModelVersion(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ pnfResource.setDescription(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+ pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ pnfResource.setToscaNodeType(entity.getToscaType());
+ return pnfResource;
+ }
+
+ /**
+ * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
+ */
+ private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
+ PnfResource pnfResource) {
+
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ Metadata metadata = entityDetails.getMetadata();
+ Map<String, Property> properties = entityDetails.getProperties();
+ pnfResourceCustomization
+ .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+ pnfResourceCustomization
+ .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
+ pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
+ pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
+ pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
+
+ pnfResourceCustomization.setPnfResources(pnfResource);
+
+ return pnfResourceCustomization;
+ }
+
+ /**
+ * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
+ */
+ private String getStringValue(Property property) {
+ if (null == property) {
+ return "";
+ }
+ Object value = property.getValue();
+ return String.valueOf(value);
+ }
protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
// Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
- " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
+ " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
.peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
if(matchingObject.isPresent()){
VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
service.getVnfCustomizations().add(vnfResource);
} else{
logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
- "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ "Tosca VF Customization UUID: " + vfCustomizationUUID);
}
}
}
case ASDCConfiguration.OTHER:
logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
- .getArtifactName() + ")", MsoLogger.ErrorCode.DataError.getValue(), "Artifact type not supported");
+ .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
break;
default:
break;
}
protected Service createService(ToscaResourceStructure toscaResourceStructure,
- VfResourceStructure vfResourceStructure) {
+ ResourceStructure resourceStructure) {
Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
service.setServiceType(serviceMetadata.getValue("serviceType"));
service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+ service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
- if (vfResourceStructure != null)
- service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
+ if (resourceStructure != null)
+ service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
}
- }
+ }
- }
- }
- }
+ }
+ }
+ }
}
crInstanceGroupCustomization.setDescription(
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(vfTemplate, SdcTypes.CVFC);
for(NodeTemplate cvfcTemplate : cvfcList) {
-
- CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- if(existingCvnfcCustomization == null && (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName()))){
+ boolean cvnfcVfModuleNameMatch = false;
+
+ for(NodeTemplate node : groupMembers){
+ vfModuleMemberName = node.getName();
+
+ if(vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
+ cvnfcVfModuleNameMatch = true;
+ break;
+ }
+ }
+
+ if(vfModuleMemberName != null && cvnfcVfModuleNameMatch){
//Extract associated VFC - Should always be just one
List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
VnfcCustomization existingVnfcCustomization = null;
existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.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 && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
// This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB.
if(vnfcCustomization.getModelCustomizationUUID() != null){
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
- cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- cvnfcCustomization.setModelVersion(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- cvnfcCustomization.setDescription(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
-
- if(existingVnfcCustomization != null){
- cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
- }else{
- cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
- }
-
- cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
- cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
- cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
- cvnfcCustomization.setVnfResourceCustomization(vnfResource);
-
- cvnfcCustomizations.add(cvnfcCustomization);
- existingCvnfcSet.add(cvnfcCustomization);
+ cvnfcCustomization = new CvnfcCustomization();
+ cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+ cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ cvnfcCustomization.setModelVersion(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ cvnfcCustomization.setDescription(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+ if(existingVnfcCustomization != null){
+ cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+ }else{
+ cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+ }
+
+ cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+ cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+ cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+ cvnfcCustomization.setVnfResourceCustomization(vnfResource);
+
+ cvnfcCustomizations.add(cvnfcCustomization);
+ existingCvnfcSet.add(cvnfcCustomization);
//*****************************************************************************************************************************************
//* Extract Fabric Configuration
VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
-
vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
}
-
+ cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
}
}
}
-
}
-
vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
}
protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
- VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
- ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
+ VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
+ ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
- Metadata fabricMetadata = fabricTemplate.getMetaData();
-
-
+ Metadata fabricMetadata = fabricTemplate.getMetaData();
+
VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
vfModuleToCvnfc.setConfigurationResource(configResource);
vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
}
}
- }
- }
+ }
+ }
}
vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
.getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+ vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+
+ vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+
vnfResourceCustomization.setVnfResources(vnfResource);
vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
}
}
+