2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.asdc.installer.heat;
25 import java.sql.Timestamp;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Optional;
33 import org.hibernate.exception.ConstraintViolationException;
34 import org.hibernate.exception.LockAcquisitionException;
35 import org.onap.sdc.api.notification.IArtifactInfo;
36 import org.onap.sdc.api.notification.IResourceInstance;
37 import org.onap.sdc.api.notification.IStatusData;
38 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
39 import org.onap.sdc.tosca.parser.impl.SdcTypes;
40 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
41 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
42 import org.onap.sdc.toscaparser.api.Group;
43 import org.onap.sdc.toscaparser.api.NodeTemplate;
44 import org.onap.sdc.toscaparser.api.Policy;
45 import org.onap.sdc.toscaparser.api.RequirementAssignment;
46 import org.onap.sdc.toscaparser.api.elements.Metadata;
47 import org.onap.sdc.utils.DistributionStatusEnum;
48 import org.onap.so.asdc.client.ASDCConfiguration;
49 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
50 import org.onap.so.asdc.installer.ASDCElementInfo;
51 import org.onap.so.asdc.installer.BigDecimalVersion;
52 import org.onap.so.asdc.installer.IVfModuleData;
53 import org.onap.so.asdc.installer.ToscaResourceStructure;
54 import org.onap.so.asdc.installer.VfModuleArtifact;
55 import org.onap.so.asdc.installer.VfModuleStructure;
56 import org.onap.so.asdc.installer.VfResourceStructure;
57 import org.onap.so.asdc.util.YamlEditor;
58 import org.onap.so.db.catalog.beans.AllottedResource;
59 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
60 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
61 import org.onap.so.db.catalog.beans.CollectionResource;
62 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
63 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
64 import org.onap.so.db.catalog.beans.ConfigurationResource;
65 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
66 import org.onap.so.db.catalog.beans.CvnfcCustomization;
67 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
68 import org.onap.so.db.catalog.beans.HeatEnvironment;
69 import org.onap.so.db.catalog.beans.HeatFiles;
70 import org.onap.so.db.catalog.beans.HeatTemplate;
71 import org.onap.so.db.catalog.beans.HeatTemplateParam;
72 import org.onap.so.db.catalog.beans.InstanceGroupType;
73 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
74 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
75 import org.onap.so.db.catalog.beans.NetworkResource;
76 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
77 import org.onap.so.db.catalog.beans.Service;
78 import org.onap.so.db.catalog.beans.ServiceProxyResource;
79 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
80 import org.onap.so.db.catalog.beans.SubType;
81 import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
82 import org.onap.so.db.catalog.beans.ToscaCsar;
83 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
84 import org.onap.so.db.catalog.beans.VfModule;
85 import org.onap.so.db.catalog.beans.VfModuleCustomization;
86 import org.onap.so.db.catalog.beans.VnfResource;
87 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
88 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
89 import org.onap.so.db.catalog.beans.VnfcCustomization;
90 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
91 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
92 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
93 import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
94 import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
95 import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
96 import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
97 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
98 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
99 import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
100 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
101 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
102 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
103 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
104 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceRepository;
105 import org.onap.so.db.catalog.data.repository.ServiceRepository;
106 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
107 import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
108 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
109 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
110 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
111 import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
112 import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
113 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
114 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
115 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
116 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
117 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
118 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
119 import org.onap.so.logger.MessageEnum;
120 import org.onap.so.logger.MsoLogger;
121 import org.springframework.beans.factory.annotation.Autowired;
122 import org.springframework.stereotype.Component;
123 import org.springframework.transaction.annotation.Transactional;
126 public class ToscaResourceInstaller {
128 protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
130 protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
132 protected static final String SCALABLE = "scalable";
134 protected static final String BASIC = "BASIC";
136 protected static final String PROVIDER = "PROVIDER";
138 protected static final String HEAT = "HEAT";
140 protected static final String MANUAL_RECORD = "MANUAL_RECORD";
142 protected static final String MSO = "SO";
146 protected ServiceRepository serviceRepo;
149 protected InstanceGroupRepository instanceGroupRepo;
152 protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
155 protected ServiceProxyResourceRepository serviceProxyRepo;
158 protected CollectionResourceRepository collectionRepo;
161 protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
164 protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
167 protected ConfigurationResourceRepository configRepo;
170 protected VnfResourceRepository vnfRepo;
173 protected VnfCustomizationRepository vnfCustomizationRepo;
176 protected VFModuleRepository vfModuleRepo;
179 protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
182 protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
185 protected VnfcCustomizationRepository vnfcCustomizationRepo;
188 protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
191 protected AllottedResourceRepository allottedRepo;
194 protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
197 protected NetworkResourceRepository networkRepo;
200 protected HeatTemplateRepository heatRepo;
203 protected NetworkResourceCustomizationRepository networkCustomizationRepo;
206 protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
208 protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
210 protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
213 protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
216 protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
218 protected static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ToscaResourceInstaller.class);
220 public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
221 boolean status = false;
222 VfResourceStructure vfResourceStructure = vfResourceStruct;
224 status = vfResourceStructure.isDeployedSuccessfully();
225 } catch (RuntimeException e) {
229 Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
230 if(existingService != null)
233 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
234 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
235 vfResourceStructure.getNotification().getServiceName(),
236 BigDecimalVersion.castAndCheckNotificationVersionToString(
237 vfResourceStructure.getNotification().getServiceVersion()),
238 vfResourceStructure.getNotification().getServiceUUID(),
239 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
240 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
241 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
242 watchdogCDStatusRepository.saveAndFlush(wdStatus);
244 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
245 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
246 vfResourceStructure.getNotification().getServiceName(),
247 BigDecimalVersion.castAndCheckNotificationVersionToString(
248 vfResourceStructure.getNotification().getServiceVersion()),
249 vfResourceStructure.getNotification().getServiceUUID(),
250 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
253 } catch (Exception e) {
254 logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError,
255 "Exception - isResourceAlreadyDeployed");
256 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
260 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
261 logger.debug("Entering installTheComponentStatus for distributionId " + iStatus.getDistributionID()
262 + " and ComponentName " + iStatus.getComponentName());
265 WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
266 iStatus.getComponentName());
267 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
268 watchdogCDStatusRepository.save(cdStatus);
270 } catch (Exception e) {
271 logger.debug("Exception caught in installTheComponentStatus " + e.getMessage());
272 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
276 @Transactional(rollbackFor = { ArtifactInstallerException.class })
277 public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
278 throws ArtifactInstallerException {
279 VfResourceStructure vfResourceStructure = vfResourceStruct;
280 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
282 // PCLO: in case of deployment failure, use a string that will represent
283 // the type of artifact that failed...
284 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
286 createToscaCsar(toscaResourceStruct);
287 createService(toscaResourceStruct, vfResourceStruct);
288 Service service = toscaResourceStruct.getCatalogService();
289 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
292 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
294 Metadata metadata = nodeTemplate.getMetaData();
295 String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
296 String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
297 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
298 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
299 vfCustomizationCategory);
302 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
303 processAllottedResources(toscaResourceStruct, service, allottedResourceList);
304 processNetworks(toscaResourceStruct, service);
305 // process Network Collections
306 processNetworkCollections(toscaResourceStruct, service);
307 // Process Service Proxy & Configuration
308 processServiceProxyAndConfiguration(toscaResourceStruct, service);
310 serviceRepo.save(service);
312 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
313 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
314 watchdogCDStatusRepository.save(status);
316 toscaResourceStruct.setSuccessfulDeployment();
318 } catch (Exception e) {
319 logger.debug("Exception :", e);
320 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
321 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
322 watchdogCDStatusRepository.save(status);
323 Throwable dbExceptionToCapture = e;
324 while (!(dbExceptionToCapture instanceof ConstraintViolationException
325 || dbExceptionToCapture instanceof LockAcquisitionException)
326 && (dbExceptionToCapture.getCause() != null)) {
327 dbExceptionToCapture = dbExceptionToCapture.getCause();
330 if (dbExceptionToCapture instanceof ConstraintViolationException
331 || dbExceptionToCapture instanceof LockAcquisitionException) {
332 logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED,
333 vfResourceStructure.getResourceInstance().getResourceName(),
334 vfResourceStructure.getNotification().getServiceVersion(), "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
336 String elementToLog = (!artifactListForLogging.isEmpty()
337 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
338 : "No element listed");
339 logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError,
340 "Exception caught during installation of "
341 + vfResourceStructure.getResourceInstance().getResourceName()
342 + ". Transaction rollback",
344 throw new ArtifactInstallerException("Exception caught during installation of "
345 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
350 protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
351 throws ArtifactInstallerException {
352 List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
354 if (nodeTemplatesVLList != null) {
355 for (NodeTemplate vlNode : nodeTemplatesVLList) {
356 String networkResourceModelName = vlNode.getMetaData()
357 .getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
359 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
361 if (tempNetworkLookUp != null ) {
362 HeatTemplate heatTemplate = heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
363 if (heatTemplate != null ) {
364 NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct, heatTemplate,tempNetworkLookUp.getAicVersionMax(),
365 tempNetworkLookUp.getAicVersionMin(),service);
366 service.getNetworkCustomizations()
367 .add(networkCustomization);
370 throw new ArtifactInstallerException(
371 "No HeatTemplate found for artifactUUID: "
372 + tempNetworkLookUp.getHeatTemplateArtifactUuid());
375 throw new ArtifactInstallerException(
376 "No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
377 + networkResourceModelName);
384 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
385 List<NodeTemplate> allottedResourceList) {
386 if (allottedResourceList != null) {
387 for (NodeTemplate allottedNode : allottedResourceList) {
388 service.getAllottedCustomizations()
389 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
394 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
396 List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
398 List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
400 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
401 List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
403 ServiceProxyResourceCustomization serviceProxy = null;
405 if (serviceProxyResourceList != null) {
406 for (NodeTemplate spNode : serviceProxyResourceList) {
407 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
409 ServiceProxyResource serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getServiceProxyResource().getModelUUID());
411 if(serviceProxyResource == null){
413 serviceProxyList.add(serviceProxy);
415 for (NodeTemplate configNode : configurationNodeTemplatesList) {
417 List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
418 for (RequirementAssignment requirement : requirementsList) {
419 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
420 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy);
422 configurationResourceList.add(configurationResource);
433 service.setConfigurationCustomizations(configurationResourceList);
434 service.setServiceProxyCustomizations(serviceProxyList);
437 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
439 List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
441 if (networkCollectionList != null) {
442 for (NodeTemplate crNode : networkCollectionList) {
444 createNetworkCollection(crNode, toscaResourceStruct, service);
445 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
447 List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
448 for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
449 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
454 service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
457 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
458 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
460 logger.debug("VF Category is : " + vfCustomizationCategory);
462 if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
465 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
466 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
467 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
469 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
471 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
472 logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
473 " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
475 if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
477 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
479 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
481 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
482 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
484 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
486 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
487 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
488 .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
489 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
491 logger.debug("Comparing VFModuleMetadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
493 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
494 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
495 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).
497 if(matchingObject.isPresent()){
498 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
499 vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
500 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
502 throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
505 service.getVnfCustomizations().add(vnfResource);
510 public void processWatchdog(String distributionId, String servideUUID) {
511 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
512 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
514 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
515 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
518 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
519 VfResourceStructure vfResourceStructure) {
520 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
522 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
523 case ASDCConfiguration.HEAT:
524 case ASDCConfiguration.HEAT_NESTED:
525 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
528 case ASDCConfiguration.HEAT_VOL:
529 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
531 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
532 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
534 case ASDCConfiguration.HEAT_ENV:
535 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
537 case ASDCConfiguration.HEAT_ARTIFACT:
538 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
539 toscaResourceStruct);
541 case ASDCConfiguration.HEAT_NET:
542 case ASDCConfiguration.OTHER:
543 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
544 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
545 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
546 "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
555 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
556 VfModuleArtifact vfModuleArtifact) {
557 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
558 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
559 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
560 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
561 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
562 return moduleArtifact;
568 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
569 List<String> listTypes) {
570 String newFileBody = filebody;
571 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
573 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
575 newFileBody = verifyTheFilePrefixInString(newFileBody,
576 moduleArtifact.getArtifactInfo().getArtifactName());
582 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
584 String needlePrefix = "file:///";
585 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
587 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
591 StringBuilder sb = new StringBuilder(body.length());
593 int currentIndex = 0;
596 while (currentIndex != -1) {
597 startIndex = currentIndex;
598 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
600 if (currentIndex == -1) {
603 // We append from the startIndex up to currentIndex (start of File
605 sb.append(body.substring(startIndex, currentIndex));
606 sb.append(filenameToVerify);
608 currentIndex += prefixedFilenameToVerify.length();
611 sb.append(body.substring(startIndex));
613 return sb.toString();
616 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
617 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
618 HeatTemplate heatTemplate = new HeatTemplate();
619 List<String> typeList = new ArrayList<>();
620 typeList.add(ASDCConfiguration.HEAT_NESTED);
621 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
623 heatTemplate.setTemplateBody(
624 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
625 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
627 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
628 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
630 heatTemplate.setTimeoutMinutes(240);
633 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
634 heatTemplate.setVersion(BigDecimalVersion
635 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
636 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
638 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
639 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
641 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
644 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
645 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
646 heatTemplate.setParameters(heatParam);
647 vfModuleArtifact.setHeatTemplate(heatTemplate);
650 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
651 VfModuleArtifact vfModuleArtifact) {
652 HeatEnvironment heatEnvironment = new HeatEnvironment();
653 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
654 List<String> typeList = new ArrayList<>();
655 typeList.add(ASDCConfiguration.HEAT);
656 typeList.add(ASDCConfiguration.HEAT_VOL);
657 heatEnvironment.setEnvironment(
658 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
659 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
660 heatEnvironment.setVersion(BigDecimalVersion
661 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
662 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
664 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
665 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
667 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
669 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
672 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
673 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
675 HeatFiles heatFile = new HeatFiles();
676 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
677 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
678 heatFile.setFileBody(vfModuleArtifact.getResult());
679 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
680 heatFile.setVersion(BigDecimalVersion
681 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
682 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
683 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
684 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
686 heatFile.setArtifactChecksum(MANUAL_RECORD);
688 vfModuleArtifact.setHeatFiles(heatFile);
691 protected Service createService(ToscaResourceStructure toscaResourceStructure,
692 VfResourceStructure vfResourceStructure) {
694 toscaResourceStructure.getServiceMetadata();
696 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
698 Service service = new Service();
700 if (serviceMetadata != null) {
702 if (toscaResourceStructure.getServiceVersion() != null) {
703 service.setModelVersion(toscaResourceStructure.getServiceVersion());
706 service.setServiceType(serviceMetadata.getValue("serviceType"));
707 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
709 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
710 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
711 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
712 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
714 if (vfResourceStructure != null)
715 service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
717 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
718 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
722 toscaResourceStructure.setCatalogService(service);
726 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
728 Metadata spMetadata = nodeTemplate.getMetaData();
730 ServiceProxyResource spResource = new ServiceProxyResource();
732 spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
733 spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
734 spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
735 spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
736 spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
738 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
740 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
742 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
743 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
744 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
745 spCustomizationResource.setSourceService(service);
746 spCustomizationResource.setServiceProxyResource(spResource);
747 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
748 spCustomizationResource.setServiceProxyResource(spResource);
749 serviceProxyCustomizationSet.add(spCustomizationResource);
751 toscaResourceStructure.setCatalogServiceProxyResource(spResource);
753 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
755 return spCustomizationResource;
758 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
760 Metadata metadata = nodeTemplate.getMetaData();
762 ConfigurationResource configResource = new ConfigurationResource();
764 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
765 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
766 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
767 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
768 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
769 configResource.setToscaNodeType(nodeTemplate.getType());
771 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
773 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
775 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
776 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
778 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
779 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
780 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
781 configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
782 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
783 configCustomizationResource.setConfigurationResource(configResource);
784 configResourceCustomizationSet.add(configCustomizationResource);
786 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
788 toscaResourceStructure.setCatalogConfigurationResource(configResource);
790 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
792 return configCustomizationResource;
795 protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
797 Metadata fabricMetadata = nodeTemplate.getMetaData();
799 ConfigurationResource configResource = new ConfigurationResource();
801 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
802 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
803 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
804 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
805 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
806 configResource.setToscaNodeType(nodeTemplate.getType());
808 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
810 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
812 configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
813 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
815 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
816 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
817 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
818 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
819 configCustomizationResource.setConfigurationResource(configResource);
820 configResourceCustomizationSet.add(configCustomizationResource);
822 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
824 return configCustomizationResource;
827 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
828 ToscaCsar toscaCsar = new ToscaCsar();
829 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
830 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
832 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
834 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
835 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
836 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
837 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
838 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
840 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
843 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
844 VnfcCustomization vnfcCustomization = null;
845 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
846 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
847 vnfcCustomization = vnfcCustom;
851 if(vnfcCustomization==null)
852 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
854 return vnfcCustomization;
857 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
858 CvnfcCustomization cvnfcCustomization = null;
859 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
860 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
861 cvnfcCustomization = cvnfcCustom;
865 if(cvnfcCustomization==null)
866 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
868 return cvnfcCustomization;
871 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
872 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
874 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
875 if(networkResourceCustomization==null){
876 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
877 toscaResourceStructure);
879 NetworkResource networkResource = findExistingNetworkResource(service,
880 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
881 if(networkResource == null)
882 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
885 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
886 networkResourceCustomization.setNetworkResource(networkResource);
888 return networkResourceCustomization;
891 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
892 NetworkResource networkResource = null;
893 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
894 if (networkCustom.getNetworkResource() != null
895 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
896 networkResource = networkCustom.getNetworkResource();
899 if(networkResource==null)
900 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
902 return networkResource;
905 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
906 ToscaResourceStructure toscaResourceStructure) {
907 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
908 networkResourceCustomization.setModelInstanceName(
909 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
910 networkResourceCustomization.setModelCustomizationUUID(
911 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
913 networkResourceCustomization.setNetworkTechnology(
914 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
915 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
916 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
917 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
918 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
919 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
920 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
921 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
922 return networkResourceCustomization;
925 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
926 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
927 NetworkResource networkResource = new NetworkResource();
928 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
929 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
931 if ("true".equalsIgnoreCase(providerNetwork)) {
932 networkResource.setNeutronNetworkType(PROVIDER);
934 networkResource.setNeutronNetworkType(BASIC);
937 networkResource.setModelName(
938 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
940 networkResource.setModelInvariantUUID(
941 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
942 networkResource.setModelUUID(
943 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
944 networkResource.setModelVersion(
945 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
947 networkResource.setAicVersionMax(aicMax);
948 networkResource.setAicVersionMin(aicMin);
949 networkResource.setToscaNodeType(networkNodeTemplate.getType());
950 networkResource.setDescription(
951 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
952 networkResource.setOrchestrationMode(HEAT);
953 networkResource.setHeatTemplate(heatTemplate);
954 return networkResource;
957 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
958 ToscaResourceStructure toscaResourceStructure, Service service) {
960 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
962 // **** Build Object to populate Collection_Resource table
963 CollectionResource collectionResource = new CollectionResource();
966 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
967 collectionResource.setModelInvariantUUID(
968 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
970 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
972 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
974 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
975 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
977 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
979 // **** Build object to populate Collection_Resource_Customization table
980 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
982 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
984 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
986 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
989 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
990 ncfc.setModelCustomizationUUID(
991 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
993 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
994 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
996 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
998 ncfc.setCollectionResource(collectionResource);
999 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1001 //*** Build object to populate the Instance_Group table
1002 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1003 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
1004 "org.openecomp.groups.NetworkCollection");
1006 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1008 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
1010 for (Group group : groupList) {
1012 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1013 Metadata instanceMetadata = group.getMetadata();
1014 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1015 networkInstanceGroup
1016 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1017 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1018 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1019 networkInstanceGroup.setToscaNodeType(group.getType());
1020 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1022 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1024 networkInstanceGroup.setCollectionResource(collectionResource);
1026 // ****Build object to populate
1027 // Collection_Resource_Instance_Group_Customization table
1028 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1029 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1030 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1031 crInstanceGroupCustomization.setModelCustomizationUUID(
1032 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1034 String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
1035 String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
1036 if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1037 fixedQuantity + "_quantity") != null) {
1039 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
1040 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1041 fixedQuantity + "_quantity")));
1044 crInstanceGroupCustomization.setDescription(
1045 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1046 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1047 + "_network_collection_description"));
1048 crInstanceGroupCustomization.setFunction(
1049 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1050 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1051 + "_network_collection_function"));
1052 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1053 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1055 networkInstanceGroup
1056 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1058 networkInstanceGroupList.add(networkInstanceGroup);
1062 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1064 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1065 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1067 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1069 //*****Build object to populate the NetworkResource table
1070 NetworkResource networkResource = new NetworkResource();
1072 for(NodeTemplate vlNodeTemplate : vlNodeList){
1074 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1075 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1077 if ("true".equalsIgnoreCase(providerNetwork)) {
1078 networkResource.setNeutronNetworkType(PROVIDER);
1080 networkResource.setNeutronNetworkType(BASIC);
1083 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1085 networkResource.setModelInvariantUUID(
1086 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1087 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1089 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1091 networkResource.setAicVersionMax(
1092 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1094 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1095 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1097 if (tempNetworkLookUp != null ) {
1099 HeatTemplate heatTemplate = heatRepo
1100 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1101 networkResource.setHeatTemplate(heatTemplate);
1103 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1107 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1109 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1110 networkResource.setOrchestrationMode(HEAT);
1112 // Build object to populate the
1113 // Collection_Network_Resource_Customization table
1114 for (NodeTemplate memberNode : group.getMemberNodes()) {
1115 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1118 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1119 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1121 collectionNetworkResourceCustomization.setNetworkTechnology(
1122 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1123 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1124 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1125 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1126 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1127 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1128 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1129 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1130 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1131 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1132 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1134 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1139 return collectionNetworkResourceCustomization;
1142 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1143 VnfResourceCustomization vnfResourceCustomization) {
1145 Metadata instanceMetadata = group.getMetadata();
1146 // Populate InstanceGroup
1147 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1149 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1150 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1151 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1152 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1153 vfcInstanceGroup.setToscaNodeType(group.getType());
1154 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1155 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1157 //Populate VNFCInstanceGroupCustomization
1158 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1160 vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
1161 vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1162 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1163 vfcInstanceGroupCustom.setFunction("FUNCTION");
1164 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1165 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1167 return vfcInstanceGroupCustom;
1171 protected VFCInstanceGroup findExistingVnfcInstanceGroup(VnfResourceCustomization vnfResourceCustomization,
1173 VFCInstanceGroup vfcInstanceGroup = null;
1174 List<VnfcInstanceGroupCustomization> vnfInstanceGroupCustomizations = vnfResourceCustomization
1175 .getVnfcInstanceGroupCustomizations();
1176 if(vnfInstanceGroupCustomizations != null){
1177 for (VnfcInstanceGroupCustomization vnfcInstanceGroupCustom : vnfResourceCustomization
1178 .getVnfcInstanceGroupCustomizations()) {
1179 if (vnfcInstanceGroupCustom.getInstanceGroup() != null
1180 && vnfcInstanceGroupCustom.getInstanceGroup().getModelUUID().equals(modelUUID)) {
1181 vfcInstanceGroup = (VFCInstanceGroup)vnfcInstanceGroupCustom.getInstanceGroup();
1185 if (vfcInstanceGroup == null)
1186 vfcInstanceGroup = (VFCInstanceGroup) instanceGroupRepo.findByModelUUID(modelUUID);
1188 return vfcInstanceGroup;
1191 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1192 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1193 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1195 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1196 vfModuleData.getVfModuleModelCustomizationUUID());
1197 if(vfModuleCustomization == null){
1198 VfModule vfModule = findExistingVfModule(vnfResource,
1199 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1200 Metadata vfMetadata = group.getMetadata();
1202 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1204 vfModuleCustomization = createVfModuleCustomzation(group, toscaResourceStructure, vfModule, vfModuleData);
1205 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1207 vfModuleCustomization.setVfModule(vfModule);
1208 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1209 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1211 vfResourceStructure.setAlreadyDeployed(true);
1214 //******************************************************************************************************************
1215 //* Extract VFC's and CVFC's then add them to VFModule
1216 //******************************************************************************************************************
1218 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1219 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1220 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1222 // Extract CVFC lists
1223 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1225 for(NodeTemplate cvfcTemplate : cvfcList) {
1227 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1229 if(existingCvnfcCustomization == null){
1231 //Extract associated VFC - Should always be just one
1232 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1234 for(NodeTemplate vfcTemplate : vfcList) {
1236 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1237 VnfcCustomization existingVnfcCustomization = null;
1239 existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1241 // Only Add Abstract VNFC's to our DB, ignore all others
1242 if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
1243 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1244 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1245 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1246 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1247 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1249 vnfcCustomization.setModelVersion(
1250 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1251 vnfcCustomization.setDescription(
1252 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1253 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1255 vnfcCustomizations.add(vnfcCustomization);
1256 existingVnfcSet.add(vnfcCustomization);
1259 // 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.
1260 if(vnfcCustomization.getModelCustomizationUUID() != null){
1262 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1263 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1264 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1265 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1266 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1267 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1269 cvnfcCustomization.setModelVersion(
1270 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1271 cvnfcCustomization.setDescription(
1272 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1273 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1275 if(existingVnfcCustomization != null){
1276 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1278 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1281 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1282 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1284 cvnfcCustomizations.add(cvnfcCustomization);
1285 existingCvnfcSet.add(cvnfcCustomization);
1287 //*****************************************************************************************************************************************
1288 //* Extract Fabric Configuration
1289 //*****************************************************************************************************************************************
1291 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1293 for(NodeTemplate fabricTemplate : fabricConfigList) {
1295 ConfigurationResource fabricConfig = null;
1297 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1299 if(existingConfig == null){
1301 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1303 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1305 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1307 fabricConfig = existingConfig;
1311 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1312 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1314 vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
1325 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1326 vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
1328 return vfModuleCustomization;
1331 protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1332 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1333 ConfigurationResource configResource) {
1335 Metadata fabricMetadata = fabricTemplate.getMetaData();
1338 VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
1340 vfModuleToCvnfc.setConfigurationResource(configResource);
1341 vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
1342 vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1343 vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
1344 vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
1345 vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
1346 vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
1348 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
1350 if(policyList != null){
1351 for(Policy policy : policyList){
1352 vfModuleToCvnfc.setPolicyName(policy.getName());
1356 vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
1357 vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
1358 vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
1360 return vfModuleToCvnfc;
1363 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1364 ConfigurationResource configResource = null;
1365 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1366 if (configurationResourceCustom.getConfigurationResource() != null
1367 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1368 configResource = configurationResourceCustom.getConfigurationResource();
1371 if(configResource==null)
1372 configResource = configRepo.findResourceByModelUUID(modelUUID);
1374 return configResource;
1377 protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) {
1378 ServiceProxyResource serviceProxyResource = null;
1379 for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){
1380 if (serviceProxyResourceCustom.getServiceProxyResource() != null
1381 && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) {
1382 serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource();
1385 if(serviceProxyResource==null)
1386 serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID);
1388 return serviceProxyResource;
1391 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1392 String vfModuleModelCustomizationUUID) {
1393 VfModuleCustomization vfModuleCustomization = null;
1394 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1395 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1396 vfModuleCustomization = vfModuleCustom;
1399 if(vfModuleCustomization==null)
1400 vfModuleCustomization = vfModuleCustomizationRepo
1401 .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
1403 return vfModuleCustomization;
1406 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1407 VfModule vfModule = null;
1408 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1409 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1410 vfModule = vfModuleCustom.getVfModule();
1414 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1419 protected VfModuleCustomization createVfModuleCustomzation(Group group,
1420 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1421 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1423 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1425 vfModuleCustomization.setVfModule(vfModule);
1427 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1428 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1429 if (initialCount != null && initialCount.length() > 0) {
1430 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1433 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1434 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1436 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1437 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1438 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1439 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1442 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1443 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1445 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1446 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1447 if (maxInstances != null && maxInstances.length() > 0) {
1448 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1451 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1452 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1453 if (minInstances != null && minInstances.length() > 0) {
1454 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1456 return vfModuleCustomization;
1459 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1460 IVfModuleData vfModuleData, Metadata vfMetadata) {
1461 VfModule vfModule = new VfModule();
1462 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1464 if(vfModuleModelUUID == null) {
1465 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1466 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1467 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1468 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1471 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1472 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1473 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1474 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1475 vfModule.setModelUUID(vfModuleModelUUID);
1476 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1477 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1478 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1479 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1481 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1482 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1483 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1484 vfModule.setIsBase(true);
1486 vfModule.setIsBase(false);
1491 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
1492 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1493 Metadata vfMetadata) {
1495 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
1496 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
1497 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1498 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
1501 if (matchingObject.isPresent()) {
1502 List<HeatFiles> heatFilesList = new ArrayList<>();
1503 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
1504 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
1505 HeatTemplate parentHeatTemplate = new HeatTemplate();
1506 String parentArtifactType = null;
1507 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
1508 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1510 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
1512 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
1513 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
1514 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
1517 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
1518 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
1520 if(!childNestedHeatTemplates.isEmpty()){
1522 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
1523 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
1525 heatChildTemplates.add(childNestedHeatTemplates.get(0));
1531 if(!heatFilesList.isEmpty()){
1532 vfModule.setHeatFiles(heatFilesList);
1536 // Set all Child Templates related to HEAT_VOLUME
1537 if(!volumeHeatChildTemplates.isEmpty()){
1538 if(vfModule.getVolumeHeatTemplate() != null){
1539 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
1541 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
1545 // Set all Child Templates related to HEAT
1546 if(!heatChildTemplates.isEmpty()){
1547 if(vfModule.getModuleHeatTemplate() != null){
1548 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
1550 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
1556 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1557 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
1558 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
1559 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
1560 vfModuleArtifact.incrementDeployedInDB();
1561 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
1562 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
1563 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
1564 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1565 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
1566 vfModuleArtifact.incrementDeployedInDB();
1567 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1568 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
1569 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
1571 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
1573 vfModuleArtifact.incrementDeployedInDB();
1574 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
1575 heatFilesList.add(vfModuleArtifact.getHeatFiles());
1576 vfModuleArtifact.incrementDeployedInDB();
1577 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
1578 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
1579 vfModuleArtifact.incrementDeployedInDB();
1583 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
1584 ToscaResourceStructure toscaResourceStructure, Service service) {
1585 VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
1586 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1587 if(vnfResourceCustomization == null){
1588 VnfResource vnfResource = findExistingVnfResource(service,
1589 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1591 if(vnfResource==null)
1592 vnfResource=createVnfResource(vfNodeTemplate);
1594 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
1596 vnfResourceCustomization.setVnfResources(vnfResource);
1597 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
1599 // Fetch VNFC Instance Group Info
1600 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1601 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
1602 "org.openecomp.groups.VfcInstanceGroup");
1604 for (Group group : groupList) {
1606 VFCInstanceGroup vfcInstanceGroup = findExistingVnfcInstanceGroup(vnfResourceCustomization,
1607 group.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1608 if(vfcInstanceGroup == null){
1609 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(
1610 vfNodeTemplate, group, vnfResourceCustomization);
1612 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1617 return vnfResourceCustomization;
1620 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1621 VnfResource vnfResource = null;
1622 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1623 if (vnfResourceCustom.getVnfResources() != null
1624 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1625 vnfResource = vnfResourceCustom.getVnfResources();
1628 if(vnfResource==null)
1629 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1634 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1635 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1636 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1637 vnfResourceCustomization.setModelCustomizationUUID(
1638 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1639 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1641 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1642 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1643 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1644 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1645 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1646 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1647 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1648 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1650 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1651 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1653 vnfResourceCustomization.setVnfResources(vnfResource);
1654 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1655 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1657 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1658 .getCapabilitiesOf(vfNodeTemplate);
1660 if (vnfCustomizationCapability != null) {
1661 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1663 if (capAssign != null) {
1664 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1665 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1666 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1667 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1672 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1674 return vnfResourceCustomization;
1677 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1678 VnfResource vnfResource = new VnfResource();
1679 vnfResource.setModelInvariantUUID(
1680 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1681 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1682 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1684 vnfResource.setModelVersion(
1685 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1686 vnfResource.setDescription(
1687 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1688 vnfResource.setOrchestrationMode(HEAT);
1689 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1690 vnfResource.setAicVersionMax(
1691 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1692 vnfResource.setAicVersionMin(
1693 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1698 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1699 ToscaResourceStructure toscaResourceStructure, Service service) {
1700 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1701 .findOneByModelCustomizationUUID(
1702 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1704 if(allottedResourceCustomization == null){
1705 AllottedResource allottedResource = findExistingAllottedResource(service,
1706 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1708 if(allottedResource==null)
1709 allottedResource=createAR(nodeTemplate);
1711 toscaResourceStructure.setAllottedResource(allottedResource);
1712 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1713 allottedResourceCustomization.setAllottedResource(allottedResource);
1714 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1716 return allottedResourceCustomization;
1719 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1720 AllottedResource allottedResource = null;
1721 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1722 if (allottedResourceCustom.getAllottedResource() != null
1723 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1724 allottedResource = allottedResourceCustom.getAllottedResource();
1727 if(allottedResource==null)
1728 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1730 return allottedResource;
1733 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1734 ToscaResourceStructure toscaResourceStructure) {
1735 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1736 allottedResourceCustomization.setModelCustomizationUUID(
1737 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1738 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1741 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1742 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1743 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1744 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1745 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1746 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1747 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1748 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1750 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1752 if(vfcNodes != null){
1753 for(NodeTemplate vfcNode : vfcNodes){
1755 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1756 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1757 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1762 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1763 .getCapabilitiesOf(nodeTemplate);
1765 if (arCustomizationCapability != null) {
1766 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1768 if (capAssign != null) {
1769 allottedResourceCustomization.setMinInstances(
1770 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1771 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1772 allottedResourceCustomization.setMaxInstances(
1773 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1774 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1777 return allottedResourceCustomization;
1780 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1781 AllottedResource allottedResource = new AllottedResource();
1783 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1784 allottedResource.setModelInvariantUUID(
1785 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1787 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1789 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1790 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1791 allottedResource.setSubcategory(
1792 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1794 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1795 return allottedResource;
1798 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1799 // Scan the payload downloadResult and extract the HeatTemplate
1801 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1802 return yamlEditor.getParameterList(artifactUUID);
1805 protected String testNull(Object object) {
1807 if (object == null) {
1809 } else if (object.equals("NULL")) {
1811 } else if (object instanceof Integer) {
1812 return object.toString();
1813 } else if (object instanceof String) {
1814 return (String) object;
1816 return "Type not recognized";
1820 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1821 VfModuleArtifact heatNestedArtifact) {
1823 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1824 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1825 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1826 .getArtifactInfo().getRelatedArtifacts()) {
1827 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1828 return ASDCConfiguration.HEAT;
1834 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1835 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1836 .getRelatedArtifacts() != null) {
1837 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1838 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1839 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1840 return ASDCConfiguration.HEAT_VOL;
1846 // Does not belong to anything
1851 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1853 return vfResourceStructure.getNotification().getServiceName() + "/"
1854 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1857 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1859 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1860 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1864 protected static Timestamp getCurrentTimeStamp() {
1866 return new Timestamp(new Date().getTime());