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,
351 Service service) throws ArtifactInstallerException {
352 List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
354 if (nodeTemplatesVLList != null) {
355 for (NodeTemplate vlNode : nodeTemplatesVLList) {
356 String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
358 TempNetworkHeatTemplateLookup tempNetworkLookUp =
359 tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
361 if (tempNetworkLookUp != null) {
362 HeatTemplate heatTemplate =
363 heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
364 if (heatTemplate != null) {
365 NetworkResourceCustomization networkCustomization =
366 createNetwork (vlNode,
369 tempNetworkLookUp.getAicVersionMax (),
370 tempNetworkLookUp.getAicVersionMin (),
372 service.getNetworkCustomizations ().add (networkCustomization);
374 throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
375 + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
378 NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
384 service.getNetworkCustomizations().add (networkCustomization);
385 logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
386 + networkResourceModelName);
393 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
394 List<NodeTemplate> allottedResourceList) {
395 if (allottedResourceList != null) {
396 for (NodeTemplate allottedNode : allottedResourceList) {
397 service.getAllottedCustomizations()
398 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
403 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
405 List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
407 List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
409 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
410 List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
412 ServiceProxyResourceCustomization serviceProxy = null;
414 if (serviceProxyResourceList != null) {
415 for (NodeTemplate spNode : serviceProxyResourceList) {
416 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
418 ServiceProxyResource serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getServiceProxyResource().getModelUUID());
420 if(serviceProxyResource == null){
422 serviceProxyList.add(serviceProxy);
424 for (NodeTemplate configNode : configurationNodeTemplatesList) {
426 List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
427 for (RequirementAssignment requirement : requirementsList) {
428 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
429 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy);
431 configurationResourceList.add(configurationResource);
442 service.setConfigurationCustomizations(configurationResourceList);
443 service.setServiceProxyCustomizations(serviceProxyList);
446 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
448 List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
450 if (networkCollectionList != null) {
451 for (NodeTemplate crNode : networkCollectionList) {
453 createNetworkCollection(crNode, toscaResourceStruct, service);
454 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
456 List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
457 for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
458 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
463 service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
466 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
467 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
469 logger.debug("VF Category is : " + vfCustomizationCategory);
471 if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
474 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
475 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
476 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
478 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
480 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
481 logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
482 " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
484 if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
486 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
488 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
490 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
491 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
493 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
495 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
496 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
497 .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
498 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
500 logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
502 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
503 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
504 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
506 if(matchingObject.isPresent()){
507 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
508 vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
509 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
511 throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
514 service.getVnfCustomizations().add(vnfResource);
516 logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
517 "Tosca VF Customization UUID: " + vfCustomizationUUID);
522 public void processWatchdog(String distributionId, String servideUUID) {
523 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
524 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
526 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
527 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
530 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
531 VfResourceStructure vfResourceStructure) {
532 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
534 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
535 case ASDCConfiguration.HEAT:
536 case ASDCConfiguration.HEAT_NESTED:
537 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
540 case ASDCConfiguration.HEAT_VOL:
541 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
543 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
544 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
546 case ASDCConfiguration.HEAT_ENV:
547 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
549 case ASDCConfiguration.HEAT_ARTIFACT:
550 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
551 toscaResourceStruct);
553 case ASDCConfiguration.HEAT_NET:
554 case ASDCConfiguration.OTHER:
555 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
556 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
557 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
558 "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
567 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
568 VfModuleArtifact vfModuleArtifact) {
569 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
570 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
571 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
572 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
573 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
574 return moduleArtifact;
580 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
581 List<String> listTypes) {
582 String newFileBody = filebody;
583 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
585 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
587 newFileBody = verifyTheFilePrefixInString(newFileBody,
588 moduleArtifact.getArtifactInfo().getArtifactName());
594 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
596 String needlePrefix = "file:///";
597 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
599 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
603 StringBuilder sb = new StringBuilder(body.length());
605 int currentIndex = 0;
608 while (currentIndex != -1) {
609 startIndex = currentIndex;
610 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
612 if (currentIndex == -1) {
615 // We append from the startIndex up to currentIndex (start of File
617 sb.append(body.substring(startIndex, currentIndex));
618 sb.append(filenameToVerify);
620 currentIndex += prefixedFilenameToVerify.length();
623 sb.append(body.substring(startIndex));
625 return sb.toString();
628 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
629 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
630 HeatTemplate heatTemplate = new HeatTemplate();
631 List<String> typeList = new ArrayList<>();
632 typeList.add(ASDCConfiguration.HEAT_NESTED);
633 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
635 heatTemplate.setTemplateBody(
636 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
637 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
639 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
640 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
642 heatTemplate.setTimeoutMinutes(240);
645 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
646 heatTemplate.setVersion(BigDecimalVersion
647 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
648 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
650 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
651 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
653 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
656 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
657 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
658 heatTemplate.setParameters(heatParam);
659 vfModuleArtifact.setHeatTemplate(heatTemplate);
662 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
663 VfModuleArtifact vfModuleArtifact) {
664 HeatEnvironment heatEnvironment = new HeatEnvironment();
665 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
666 List<String> typeList = new ArrayList<>();
667 typeList.add(ASDCConfiguration.HEAT);
668 typeList.add(ASDCConfiguration.HEAT_VOL);
669 heatEnvironment.setEnvironment(
670 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
671 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
672 heatEnvironment.setVersion(BigDecimalVersion
673 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
674 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
676 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
677 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
679 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
681 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
684 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
685 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
687 HeatFiles heatFile = new HeatFiles();
688 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
689 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
690 heatFile.setFileBody(vfModuleArtifact.getResult());
691 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
692 heatFile.setVersion(BigDecimalVersion
693 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
694 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
695 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
696 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
698 heatFile.setArtifactChecksum(MANUAL_RECORD);
700 vfModuleArtifact.setHeatFiles(heatFile);
703 protected Service createService(ToscaResourceStructure toscaResourceStructure,
704 VfResourceStructure vfResourceStructure) {
706 toscaResourceStructure.getServiceMetadata();
708 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
710 Service service = new Service();
712 if (serviceMetadata != null) {
714 if (toscaResourceStructure.getServiceVersion() != null) {
715 service.setModelVersion(toscaResourceStructure.getServiceVersion());
718 service.setServiceType(serviceMetadata.getValue("serviceType"));
719 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
721 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
722 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
723 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
724 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
726 if (vfResourceStructure != null)
727 service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
729 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
730 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
734 toscaResourceStructure.setCatalogService(service);
738 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
740 Metadata spMetadata = nodeTemplate.getMetaData();
742 ServiceProxyResource spResource = new ServiceProxyResource();
744 spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
745 spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
746 spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
747 spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
748 spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
750 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
752 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
754 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
755 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
756 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
757 spCustomizationResource.setSourceService(service);
758 spCustomizationResource.setServiceProxyResource(spResource);
759 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
760 spCustomizationResource.setServiceProxyResource(spResource);
761 serviceProxyCustomizationSet.add(spCustomizationResource);
763 toscaResourceStructure.setCatalogServiceProxyResource(spResource);
765 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
767 return spCustomizationResource;
770 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
772 Metadata metadata = nodeTemplate.getMetaData();
774 ConfigurationResource configResource = new ConfigurationResource();
776 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
777 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
778 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
779 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
780 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
781 configResource.setToscaNodeType(nodeTemplate.getType());
783 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
785 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
787 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
788 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
790 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
791 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
792 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
793 configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
794 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
795 configCustomizationResource.setConfigurationResource(configResource);
796 configResourceCustomizationSet.add(configCustomizationResource);
798 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
800 toscaResourceStructure.setCatalogConfigurationResource(configResource);
802 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
804 return configCustomizationResource;
807 protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
809 Metadata fabricMetadata = nodeTemplate.getMetaData();
811 ConfigurationResource configResource = new ConfigurationResource();
813 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
814 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
815 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
816 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
817 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
818 configResource.setToscaNodeType(nodeTemplate.getType());
820 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
822 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
824 configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
825 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
827 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
828 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
829 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
830 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
831 configCustomizationResource.setConfigurationResource(configResource);
832 configResourceCustomizationSet.add(configCustomizationResource);
834 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
836 return configCustomizationResource;
839 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
840 ToscaCsar toscaCsar = new ToscaCsar();
841 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
842 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
844 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
846 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
847 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
848 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
849 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
850 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
852 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
855 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
856 VnfcCustomization vnfcCustomization = null;
857 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
858 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
859 vnfcCustomization = vnfcCustom;
863 if(vnfcCustomization==null)
864 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
866 return vnfcCustomization;
869 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
870 CvnfcCustomization cvnfcCustomization = null;
871 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
872 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
873 cvnfcCustomization = cvnfcCustom;
877 if(cvnfcCustomization==null)
878 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
880 return cvnfcCustomization;
883 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
884 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
886 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
887 if(networkResourceCustomization==null){
888 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
889 toscaResourceStructure);
891 NetworkResource networkResource = findExistingNetworkResource(service,
892 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
893 if(networkResource == null)
894 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
897 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
898 networkResourceCustomization.setNetworkResource(networkResource);
900 return networkResourceCustomization;
903 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
904 NetworkResource networkResource = null;
905 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
906 if (networkCustom.getNetworkResource() != null
907 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
908 networkResource = networkCustom.getNetworkResource();
911 if(networkResource==null)
912 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
914 return networkResource;
917 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
918 ToscaResourceStructure toscaResourceStructure) {
919 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
920 networkResourceCustomization.setModelInstanceName(
921 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
922 networkResourceCustomization.setModelCustomizationUUID(
923 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
925 networkResourceCustomization.setNetworkTechnology(
926 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
927 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
928 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
929 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
930 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
931 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
932 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
933 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
934 return networkResourceCustomization;
937 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
938 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
939 NetworkResource networkResource = new NetworkResource();
940 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
941 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
943 if ("true".equalsIgnoreCase(providerNetwork)) {
944 networkResource.setNeutronNetworkType(PROVIDER);
946 networkResource.setNeutronNetworkType(BASIC);
949 networkResource.setModelName(
950 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
952 networkResource.setModelInvariantUUID(
953 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
954 networkResource.setModelUUID(
955 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
956 networkResource.setModelVersion(
957 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
959 networkResource.setAicVersionMax(aicMax);
960 networkResource.setAicVersionMin(aicMin);
961 networkResource.setToscaNodeType(networkNodeTemplate.getType());
962 networkResource.setDescription(
963 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
964 networkResource.setOrchestrationMode(HEAT);
965 networkResource.setHeatTemplate(heatTemplate);
966 return networkResource;
969 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
970 ToscaResourceStructure toscaResourceStructure, Service service) {
972 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
974 // **** Build Object to populate Collection_Resource table
975 CollectionResource collectionResource = new CollectionResource();
978 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
979 collectionResource.setModelInvariantUUID(
980 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
982 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
984 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
986 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
987 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
989 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
991 // **** Build object to populate Collection_Resource_Customization table
992 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
994 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
996 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
998 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1001 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1002 ncfc.setModelCustomizationUUID(
1003 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1005 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
1006 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
1008 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1010 ncfc.setCollectionResource(collectionResource);
1011 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1013 //*** Build object to populate the Instance_Group table
1014 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1015 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
1016 "org.openecomp.groups.NetworkCollection");
1018 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1020 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
1022 for (Group group : groupList) {
1024 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1025 Metadata instanceMetadata = group.getMetadata();
1026 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1027 networkInstanceGroup
1028 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1029 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1030 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1031 networkInstanceGroup.setToscaNodeType(group.getType());
1032 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1034 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1036 networkInstanceGroup.setCollectionResource(collectionResource);
1038 // ****Build object to populate
1039 // Collection_Resource_Instance_Group_Customization table
1040 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1041 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1042 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1043 crInstanceGroupCustomization.setModelCustomizationUUID(
1044 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1046 String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
1047 String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
1048 if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1049 fixedQuantity + "_quantity") != null) {
1051 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
1052 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1053 fixedQuantity + "_quantity")));
1056 crInstanceGroupCustomization.setDescription(
1057 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1058 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1059 + "_network_collection_description"));
1060 crInstanceGroupCustomization.setFunction(
1061 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1062 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1063 + "_network_collection_function"));
1064 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1065 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1067 networkInstanceGroup
1068 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1070 networkInstanceGroupList.add(networkInstanceGroup);
1074 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1076 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1077 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1079 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1081 //*****Build object to populate the NetworkResource table
1082 NetworkResource networkResource = new NetworkResource();
1084 for(NodeTemplate vlNodeTemplate : vlNodeList){
1086 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1087 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1089 if ("true".equalsIgnoreCase(providerNetwork)) {
1090 networkResource.setNeutronNetworkType(PROVIDER);
1092 networkResource.setNeutronNetworkType(BASIC);
1095 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1097 networkResource.setModelInvariantUUID(
1098 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1099 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1101 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1103 networkResource.setAicVersionMax(
1104 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1106 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1107 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1109 if (tempNetworkLookUp != null ) {
1111 HeatTemplate heatTemplate = heatRepo
1112 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1113 networkResource.setHeatTemplate(heatTemplate);
1115 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1119 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1121 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1122 networkResource.setOrchestrationMode(HEAT);
1124 // Build object to populate the
1125 // Collection_Network_Resource_Customization table
1126 for (NodeTemplate memberNode : group.getMemberNodes()) {
1127 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1130 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1131 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1133 collectionNetworkResourceCustomization.setNetworkTechnology(
1134 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1135 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1136 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1137 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1138 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1139 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1140 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1141 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1142 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1143 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1144 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1146 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1151 return collectionNetworkResourceCustomization;
1154 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1155 VnfResourceCustomization vnfResourceCustomization) {
1157 Metadata instanceMetadata = group.getMetadata();
1158 // Populate InstanceGroup
1159 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1161 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1162 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1163 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1164 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1165 vfcInstanceGroup.setToscaNodeType(group.getType());
1166 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1167 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1169 //Populate VNFCInstanceGroupCustomization
1170 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1172 vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
1173 vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1174 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1175 vfcInstanceGroupCustom.setFunction("FUNCTION");
1176 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1177 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1179 return vfcInstanceGroupCustom;
1183 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1184 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1185 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1187 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1188 vfModuleData.getVfModuleModelCustomizationUUID());
1189 if(vfModuleCustomization == null){
1190 VfModule vfModule = findExistingVfModule(vnfResource,
1191 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1192 Metadata vfMetadata = group.getMetadata();
1194 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1196 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1197 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1199 vfModuleCustomization.setVfModule(vfModule);
1200 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1201 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1203 vfResourceStructure.setAlreadyDeployed(true);
1206 //******************************************************************************************************************
1207 //* Extract VFC's and CVFC's then add them to VFModule
1208 //******************************************************************************************************************
1210 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1211 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1212 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1214 // Extract CVFC lists
1215 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1217 for(NodeTemplate cvfcTemplate : cvfcList) {
1219 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1221 if(existingCvnfcCustomization == null){
1223 //Extract associated VFC - Should always be just one
1224 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1226 for(NodeTemplate vfcTemplate : vfcList) {
1228 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1229 VnfcCustomization existingVnfcCustomization = null;
1231 existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1233 // Only Add Abstract VNFC's to our DB, ignore all others
1234 if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
1235 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1236 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1237 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1238 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1239 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1241 vnfcCustomization.setModelVersion(
1242 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1243 vnfcCustomization.setDescription(
1244 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1245 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1247 vnfcCustomizations.add(vnfcCustomization);
1248 existingVnfcSet.add(vnfcCustomization);
1251 // 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.
1252 if(vnfcCustomization.getModelCustomizationUUID() != null){
1254 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1255 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1256 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1257 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1258 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1259 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1261 cvnfcCustomization.setModelVersion(
1262 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1263 cvnfcCustomization.setDescription(
1264 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1265 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1267 if(existingVnfcCustomization != null){
1268 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1270 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1273 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1274 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1276 cvnfcCustomizations.add(cvnfcCustomization);
1277 existingCvnfcSet.add(cvnfcCustomization);
1279 //*****************************************************************************************************************************************
1280 //* Extract Fabric Configuration
1281 //*****************************************************************************************************************************************
1283 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1285 for(NodeTemplate fabricTemplate : fabricConfigList) {
1287 ConfigurationResource fabricConfig = null;
1289 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1291 if(existingConfig == null){
1293 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1295 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1297 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1299 fabricConfig = existingConfig;
1303 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1304 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1306 vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
1317 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1318 vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
1320 return vfModuleCustomization;
1323 protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1324 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1325 ConfigurationResource configResource) {
1327 Metadata fabricMetadata = fabricTemplate.getMetaData();
1330 VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
1332 vfModuleToCvnfc.setConfigurationResource(configResource);
1333 vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
1334 vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1335 vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
1336 vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
1337 vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
1338 vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
1340 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
1342 if(policyList != null){
1343 for(Policy policy : policyList){
1344 vfModuleToCvnfc.setPolicyName(policy.getName());
1348 vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
1349 vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
1350 vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
1352 return vfModuleToCvnfc;
1355 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1356 ConfigurationResource configResource = null;
1357 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1358 if (configurationResourceCustom.getConfigurationResource() != null
1359 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1360 configResource = configurationResourceCustom.getConfigurationResource();
1363 if(configResource==null)
1364 configResource = configRepo.findResourceByModelUUID(modelUUID);
1366 return configResource;
1369 protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) {
1370 ServiceProxyResource serviceProxyResource = null;
1371 for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){
1372 if (serviceProxyResourceCustom.getServiceProxyResource() != null
1373 && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) {
1374 serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource();
1377 if(serviceProxyResource==null)
1378 serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID);
1380 return serviceProxyResource;
1383 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1384 String vfModuleModelCustomizationUUID) {
1385 VfModuleCustomization vfModuleCustomization = null;
1386 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1387 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1388 vfModuleCustomization = vfModuleCustom;
1391 if(vfModuleCustomization==null)
1392 vfModuleCustomization = vfModuleCustomizationRepo
1393 .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
1395 return vfModuleCustomization;
1398 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1399 VfModule vfModule = null;
1400 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1401 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1402 vfModule = vfModuleCustom.getVfModule();
1406 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1411 protected VfModuleCustomization createVfModuleCustomization(Group group,
1412 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1413 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1415 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1417 vfModuleCustomization.setVfModule(vfModule);
1419 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1420 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1421 if (initialCount != null && initialCount.length() > 0) {
1422 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1425 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1426 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1428 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1429 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1430 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1431 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1434 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1435 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1437 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1438 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1439 if (maxInstances != null && maxInstances.length() > 0) {
1440 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1443 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1444 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1445 if (minInstances != null && minInstances.length() > 0) {
1446 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1448 return vfModuleCustomization;
1451 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1452 IVfModuleData vfModuleData, Metadata vfMetadata) {
1453 VfModule vfModule = new VfModule();
1454 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1456 if(vfModuleModelUUID == null) {
1457 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1458 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1459 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1460 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1463 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1464 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1465 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1466 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1467 vfModule.setModelUUID(vfModuleModelUUID);
1468 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1469 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1470 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1471 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1473 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1474 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1475 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1476 vfModule.setIsBase(true);
1478 vfModule.setIsBase(false);
1483 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
1484 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1485 Metadata vfMetadata) {
1487 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
1488 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
1489 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1490 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
1493 if (matchingObject.isPresent()) {
1494 List<HeatFiles> heatFilesList = new ArrayList<>();
1495 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
1496 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
1497 HeatTemplate parentHeatTemplate = new HeatTemplate();
1498 String parentArtifactType = null;
1499 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
1500 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1502 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
1504 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
1505 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
1506 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
1509 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
1510 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
1512 if(!childNestedHeatTemplates.isEmpty()){
1514 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
1515 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
1517 heatChildTemplates.add(childNestedHeatTemplates.get(0));
1523 if(!heatFilesList.isEmpty()){
1524 vfModule.setHeatFiles(heatFilesList);
1528 // Set all Child Templates related to HEAT_VOLUME
1529 if(!volumeHeatChildTemplates.isEmpty()){
1530 if(vfModule.getVolumeHeatTemplate() != null){
1531 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
1533 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
1537 // Set all Child Templates related to HEAT
1538 if(!heatChildTemplates.isEmpty()){
1539 if(vfModule.getModuleHeatTemplate() != null){
1540 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
1542 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
1548 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1549 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
1550 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
1551 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
1552 vfModuleArtifact.incrementDeployedInDB();
1553 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
1554 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
1555 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
1556 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1557 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
1558 vfModuleArtifact.incrementDeployedInDB();
1559 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1560 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
1561 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
1563 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
1565 vfModuleArtifact.incrementDeployedInDB();
1566 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
1567 heatFilesList.add(vfModuleArtifact.getHeatFiles());
1568 vfModuleArtifact.incrementDeployedInDB();
1569 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
1570 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
1571 vfModuleArtifact.incrementDeployedInDB();
1575 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
1576 ToscaResourceStructure toscaResourceStructure, Service service) {
1577 VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
1578 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1579 if(vnfResourceCustomization == null){
1580 VnfResource vnfResource = findExistingVnfResource(service,
1581 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1583 if(vnfResource==null)
1584 vnfResource=createVnfResource(vfNodeTemplate);
1586 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
1588 vnfResourceCustomization.setVnfResources(vnfResource);
1589 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
1591 // Fetch VNFC Instance Group Info
1592 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1593 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
1594 "org.openecomp.groups.VfcInstanceGroup");
1596 for (Group group : groupList) {
1598 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization);
1600 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1603 return vnfResourceCustomization;
1606 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1607 VnfResource vnfResource = null;
1608 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1609 if (vnfResourceCustom.getVnfResources() != null
1610 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1611 vnfResource = vnfResourceCustom.getVnfResources();
1614 if(vnfResource==null)
1615 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1620 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1621 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1622 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1623 vnfResourceCustomization.setModelCustomizationUUID(
1624 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1625 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1627 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1628 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1629 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1630 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1631 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1632 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1633 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1634 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1636 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1637 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1639 vnfResourceCustomization.setVnfResources(vnfResource);
1640 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1641 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1643 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1644 .getCapabilitiesOf(vfNodeTemplate);
1646 if (vnfCustomizationCapability != null) {
1647 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1649 if (capAssign != null) {
1650 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1651 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1652 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1653 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1658 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1660 return vnfResourceCustomization;
1663 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1664 VnfResource vnfResource = new VnfResource();
1665 vnfResource.setModelInvariantUUID(
1666 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1667 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1668 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1670 vnfResource.setModelVersion(
1671 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1672 vnfResource.setDescription(
1673 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1674 vnfResource.setOrchestrationMode(HEAT);
1675 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1676 vnfResource.setAicVersionMax(
1677 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1678 vnfResource.setAicVersionMin(
1679 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1680 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1681 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
1686 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1687 ToscaResourceStructure toscaResourceStructure, Service service) {
1688 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1689 .findOneByModelCustomizationUUID(
1690 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1692 if(allottedResourceCustomization == null){
1693 AllottedResource allottedResource = findExistingAllottedResource(service,
1694 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1696 if(allottedResource==null)
1697 allottedResource=createAR(nodeTemplate);
1699 toscaResourceStructure.setAllottedResource(allottedResource);
1700 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1701 allottedResourceCustomization.setAllottedResource(allottedResource);
1702 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1704 return allottedResourceCustomization;
1707 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1708 AllottedResource allottedResource = null;
1709 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1710 if (allottedResourceCustom.getAllottedResource() != null
1711 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1712 allottedResource = allottedResourceCustom.getAllottedResource();
1715 if(allottedResource==null)
1716 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1718 return allottedResource;
1721 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1722 ToscaResourceStructure toscaResourceStructure) {
1723 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1724 allottedResourceCustomization.setModelCustomizationUUID(
1725 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1726 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1729 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1730 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1731 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1732 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1733 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1734 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1735 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1736 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1738 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1740 if(vfcNodes != null){
1741 for(NodeTemplate vfcNode : vfcNodes){
1743 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1744 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1745 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1750 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1751 .getCapabilitiesOf(nodeTemplate);
1753 if (arCustomizationCapability != null) {
1754 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1756 if (capAssign != null) {
1757 allottedResourceCustomization.setMinInstances(
1758 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1759 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1760 allottedResourceCustomization.setMaxInstances(
1761 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1762 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1765 return allottedResourceCustomization;
1768 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1769 AllottedResource allottedResource = new AllottedResource();
1771 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1772 allottedResource.setModelInvariantUUID(
1773 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1775 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1777 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1778 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1779 allottedResource.setSubcategory(
1780 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1782 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1783 return allottedResource;
1786 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1787 // Scan the payload downloadResult and extract the HeatTemplate
1789 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1790 return yamlEditor.getParameterList(artifactUUID);
1793 protected String testNull(Object object) {
1795 if (object == null) {
1797 } else if (object.equals("NULL")) {
1799 } else if (object instanceof Integer) {
1800 return object.toString();
1801 } else if (object instanceof String) {
1802 return (String) object;
1804 return "Type not recognized";
1808 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1809 VfModuleArtifact heatNestedArtifact) {
1811 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1812 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1813 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1814 .getArtifactInfo().getRelatedArtifacts()) {
1815 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1816 return ASDCConfiguration.HEAT;
1822 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1823 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1824 .getRelatedArtifacts() != null) {
1825 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1826 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1827 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1828 return ASDCConfiguration.HEAT_VOL;
1834 // Does not belong to anything
1839 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1841 return vfResourceStructure.getNotification().getServiceName() + "/"
1842 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1845 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1847 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1848 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1852 protected static Timestamp getCurrentTimeStamp() {
1854 return new Timestamp(new Date().getTime());