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 (!vfCustomizationCategory.equalsIgnoreCase(ALLOTTED_RESOURCE))
463 if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
466 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
467 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
468 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
470 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
472 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
473 logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
474 " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
476 if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
478 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
480 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
482 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
483 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
485 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
487 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
488 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
489 .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
490 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
492 logger.debug("Comparing VFModule Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
493 for(Group group : vfGroups){
494 logger.debug("To Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
497 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream().
498 filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).
500 if(matchingObject.isPresent()){
501 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
502 vfResourceStructure,vfMetadata, vnfResource, service, cvnfcCustomizations, vnfcCustomizations);
503 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
505 throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
508 service.getVnfCustomizations().add(vnfResource);
513 public void processWatchdog(String distributionId, String servideUUID) {
514 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
515 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
517 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
518 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
521 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
522 VfResourceStructure vfResourceStructure) {
523 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
525 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
526 case ASDCConfiguration.HEAT:
527 case ASDCConfiguration.HEAT_NESTED:
528 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
531 case ASDCConfiguration.HEAT_VOL:
532 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
534 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
535 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
537 case ASDCConfiguration.HEAT_ENV:
538 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
540 case ASDCConfiguration.HEAT_ARTIFACT:
541 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
542 toscaResourceStruct);
544 case ASDCConfiguration.HEAT_NET:
545 case ASDCConfiguration.OTHER:
546 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
547 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
548 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
549 "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
558 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
559 VfModuleArtifact vfModuleArtifact) {
560 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
561 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
562 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
563 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
564 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
565 return moduleArtifact;
571 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
572 List<String> listTypes) {
573 String newFileBody = filebody;
574 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
576 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
578 newFileBody = verifyTheFilePrefixInString(newFileBody,
579 moduleArtifact.getArtifactInfo().getArtifactName());
585 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
587 String needlePrefix = "file:///";
588 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
590 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
594 StringBuilder sb = new StringBuilder(body.length());
596 int currentIndex = 0;
599 while (currentIndex != -1) {
600 startIndex = currentIndex;
601 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
603 if (currentIndex == -1) {
606 // We append from the startIndex up to currentIndex (start of File
608 sb.append(body.substring(startIndex, currentIndex));
609 sb.append(filenameToVerify);
611 currentIndex += prefixedFilenameToVerify.length();
614 sb.append(body.substring(startIndex));
616 return sb.toString();
619 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
620 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
621 HeatTemplate heatTemplate = new HeatTemplate();
622 List<String> typeList = new ArrayList<>();
623 typeList.add(ASDCConfiguration.HEAT_NESTED);
624 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
626 heatTemplate.setTemplateBody(
627 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
628 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
630 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
631 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
633 heatTemplate.setTimeoutMinutes(240);
636 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
637 heatTemplate.setVersion(BigDecimalVersion
638 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
639 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
641 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
642 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
644 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
647 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
648 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
649 heatTemplate.setParameters(heatParam);
650 vfModuleArtifact.setHeatTemplate(heatTemplate);
653 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
654 VfModuleArtifact vfModuleArtifact) {
655 HeatEnvironment heatEnvironment = new HeatEnvironment();
656 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
657 List<String> typeList = new ArrayList<>();
658 typeList.add(ASDCConfiguration.HEAT);
659 typeList.add(ASDCConfiguration.HEAT_VOL);
660 heatEnvironment.setEnvironment(
661 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
662 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
663 heatEnvironment.setVersion(BigDecimalVersion
664 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
665 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
667 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
668 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
670 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
672 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
675 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
676 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
678 HeatFiles heatFile = new HeatFiles();
679 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
680 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
681 heatFile.setFileBody(vfModuleArtifact.getResult());
682 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
683 heatFile.setVersion(BigDecimalVersion
684 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
685 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
686 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
687 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
689 heatFile.setArtifactChecksum(MANUAL_RECORD);
691 vfModuleArtifact.setHeatFiles(heatFile);
694 protected Service createService(ToscaResourceStructure toscaResourceStructure,
695 VfResourceStructure vfResourceStructure) {
697 toscaResourceStructure.getServiceMetadata();
699 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
701 Service service = new Service();
703 if (serviceMetadata != null) {
705 if (toscaResourceStructure.getServiceVersion() != null) {
706 service.setModelVersion(toscaResourceStructure.getServiceVersion());
709 service.setServiceType(serviceMetadata.getValue("serviceType"));
710 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
712 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
713 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
714 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
715 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
717 if (vfResourceStructure != null)
718 service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
720 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
721 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
725 toscaResourceStructure.setCatalogService(service);
729 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
731 Metadata spMetadata = nodeTemplate.getMetaData();
733 ServiceProxyResource spResource = new ServiceProxyResource();
735 spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
736 spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
737 spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
738 spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
739 spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
741 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
743 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
745 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
746 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
747 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
748 spCustomizationResource.setSourceService(service);
749 spCustomizationResource.setServiceProxyResource(spResource);
750 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
751 spCustomizationResource.setServiceProxyResource(spResource);
752 serviceProxyCustomizationSet.add(spCustomizationResource);
754 toscaResourceStructure.setCatalogServiceProxyResource(spResource);
756 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
758 return spCustomizationResource;
761 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
763 Metadata metadata = nodeTemplate.getMetaData();
765 ConfigurationResource configResource = new ConfigurationResource();
767 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
768 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
769 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
770 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
771 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
772 configResource.setToscaNodeType(nodeTemplate.getType());
774 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
776 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
778 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
779 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
781 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
782 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
783 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
784 configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
785 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
786 configCustomizationResource.setConfigurationResource(configResource);
787 configResourceCustomizationSet.add(configCustomizationResource);
789 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
791 toscaResourceStructure.setCatalogConfigurationResource(configResource);
793 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
795 return configCustomizationResource;
798 protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
800 Metadata fabricMetadata = nodeTemplate.getMetaData();
802 ConfigurationResource configResource = new ConfigurationResource();
804 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
805 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
806 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
807 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
808 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
809 configResource.setToscaNodeType(nodeTemplate.getType());
811 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
813 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
815 configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
816 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
818 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
819 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
820 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
821 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
822 configCustomizationResource.setConfigurationResource(configResource);
823 configResourceCustomizationSet.add(configCustomizationResource);
825 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
827 return configCustomizationResource;
830 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
831 ToscaCsar toscaCsar = new ToscaCsar();
832 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
833 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
835 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
837 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
838 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
839 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
840 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
841 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
843 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
846 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
847 VnfcCustomization vnfcCustomization = null;
848 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
849 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
850 vnfcCustomization = vnfcCustom;
854 if(vnfcCustomization==null)
855 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
857 return vnfcCustomization;
860 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
861 CvnfcCustomization cvnfcCustomization = null;
862 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
863 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
864 cvnfcCustomization = cvnfcCustom;
868 if(cvnfcCustomization==null)
869 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
871 return cvnfcCustomization;
874 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
875 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
877 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
878 if(networkResourceCustomization==null){
879 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
880 toscaResourceStructure);
882 NetworkResource networkResource = findExistingNetworkResource(service,
883 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
884 if(networkResource == null)
885 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
888 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
889 networkResourceCustomization.setNetworkResource(networkResource);
891 return networkResourceCustomization;
894 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
895 NetworkResource networkResource = null;
896 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
897 if (networkCustom.getNetworkResource() != null
898 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
899 networkResource = networkCustom.getNetworkResource();
902 if(networkResource==null)
903 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
905 return networkResource;
908 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
909 ToscaResourceStructure toscaResourceStructure) {
910 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
911 networkResourceCustomization.setModelInstanceName(
912 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
913 networkResourceCustomization.setModelCustomizationUUID(
914 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
916 networkResourceCustomization.setNetworkTechnology(
917 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
918 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
919 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
920 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
921 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
922 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
923 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
924 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
925 return networkResourceCustomization;
928 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
929 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
930 NetworkResource networkResource = new NetworkResource();
931 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
932 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
934 if ("true".equalsIgnoreCase(providerNetwork)) {
935 networkResource.setNeutronNetworkType(PROVIDER);
937 networkResource.setNeutronNetworkType(BASIC);
940 networkResource.setModelName(
941 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
943 networkResource.setModelInvariantUUID(
944 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
945 networkResource.setModelUUID(
946 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
947 networkResource.setModelVersion(
948 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
950 networkResource.setAicVersionMax(aicMax);
951 networkResource.setAicVersionMin(aicMin);
952 networkResource.setToscaNodeType(networkNodeTemplate.getType());
953 networkResource.setDescription(
954 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
955 networkResource.setOrchestrationMode(HEAT);
956 networkResource.setHeatTemplate(heatTemplate);
957 return networkResource;
960 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
961 ToscaResourceStructure toscaResourceStructure, Service service) {
963 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
965 // **** Build Object to populate Collection_Resource table
966 CollectionResource collectionResource = new CollectionResource();
969 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
970 collectionResource.setModelInvariantUUID(
971 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
973 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
975 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
977 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
978 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
980 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
982 // **** Build object to populate Collection_Resource_Customization table
983 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
985 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
987 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
989 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
992 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
993 ncfc.setModelCustomizationUUID(
994 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
996 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
997 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
999 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1001 ncfc.setCollectionResource(collectionResource);
1002 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1004 //*** Build object to populate the Instance_Group table
1005 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1006 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
1007 "org.openecomp.groups.NetworkCollection");
1009 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1011 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
1013 for (Group group : groupList) {
1015 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1016 Metadata instanceMetadata = group.getMetadata();
1017 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1018 networkInstanceGroup
1019 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1020 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1021 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1022 networkInstanceGroup.setToscaNodeType(group.getType());
1023 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1025 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1027 networkInstanceGroup.setCollectionResource(collectionResource);
1029 // ****Build object to populate
1030 // Collection_Resource_Instance_Group_Customization table
1031 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1032 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1033 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1034 crInstanceGroupCustomization.setModelCustomizationUUID(
1035 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1037 String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
1038 String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
1039 if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1040 fixedQuantity + "_quantity") != null) {
1042 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
1043 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1044 fixedQuantity + "_quantity")));
1047 crInstanceGroupCustomization.setDescription(
1048 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1049 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1050 + "_network_collection_description"));
1051 crInstanceGroupCustomization.setFunction(
1052 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1053 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1054 + "_network_collection_function"));
1055 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1056 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1058 networkInstanceGroup
1059 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1061 networkInstanceGroupList.add(networkInstanceGroup);
1065 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1067 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1068 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1070 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1072 //*****Build object to populate the NetworkResource table
1073 NetworkResource networkResource = new NetworkResource();
1075 for(NodeTemplate vlNodeTemplate : vlNodeList){
1077 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1078 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1080 if ("true".equalsIgnoreCase(providerNetwork)) {
1081 networkResource.setNeutronNetworkType(PROVIDER);
1083 networkResource.setNeutronNetworkType(BASIC);
1086 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1088 networkResource.setModelInvariantUUID(
1089 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1090 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1092 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1094 networkResource.setAicVersionMax(
1095 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1097 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1098 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1100 if (tempNetworkLookUp != null ) {
1102 HeatTemplate heatTemplate = heatRepo
1103 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1104 networkResource.setHeatTemplate(heatTemplate);
1106 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1110 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1112 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1113 networkResource.setOrchestrationMode(HEAT);
1115 // Build object to populate the
1116 // Collection_Network_Resource_Customization table
1117 for (NodeTemplate memberNode : group.getMemberNodes()) {
1118 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1121 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1122 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1124 collectionNetworkResourceCustomization.setNetworkTechnology(
1125 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1126 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1127 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1128 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1129 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1130 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1131 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1132 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1133 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1134 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1135 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1137 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1142 return collectionNetworkResourceCustomization;
1145 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1146 VnfResourceCustomization vnfResourceCustomization) {
1148 Metadata instanceMetadata = group.getMetadata();
1149 // Populate InstanceGroup
1150 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1152 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1153 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1154 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1155 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1156 vfcInstanceGroup.setToscaNodeType(group.getType());
1157 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1158 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1160 //Populate VNFCInstanceGroupCustomization
1161 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1163 vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
1164 vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1165 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1166 vfcInstanceGroupCustom.setFunction("FUNCTION");
1167 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1168 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1170 return vfcInstanceGroupCustom;
1174 protected VFCInstanceGroup findExistingVnfcInstanceGroup(VnfResourceCustomization vnfResourceCustomization,
1176 VFCInstanceGroup vfcInstanceGroup = null;
1177 List<VnfcInstanceGroupCustomization> vnfInstanceGroupCustomizations = vnfResourceCustomization
1178 .getVnfcInstanceGroupCustomizations();
1179 if(vnfInstanceGroupCustomizations != null){
1180 for (VnfcInstanceGroupCustomization vnfcInstanceGroupCustom : vnfResourceCustomization
1181 .getVnfcInstanceGroupCustomizations()) {
1182 if (vnfcInstanceGroupCustom.getInstanceGroup() != null
1183 && vnfcInstanceGroupCustom.getInstanceGroup().getModelUUID().equals(modelUUID)) {
1184 vfcInstanceGroup = (VFCInstanceGroup)vnfcInstanceGroupCustom.getInstanceGroup();
1188 if (vfcInstanceGroup == null)
1189 vfcInstanceGroup = (VFCInstanceGroup) instanceGroupRepo.findByModelUUID(modelUUID);
1191 return vfcInstanceGroup;
1194 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1195 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1196 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> cvnfcCustomizations, Set<VnfcCustomization> vnfcCustomizations) {
1197 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1198 vfModuleData.getVfModuleModelCustomizationUUID());
1199 if(vfModuleCustomization == null){
1200 VfModule vfModule = findExistingVfModule(vnfResource,
1201 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1202 Metadata vfMetadata = group.getMetadata();
1204 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1206 vfModuleCustomization = createVfModuleCustomzation(group, toscaResourceStructure, vfModule, vfModuleData);
1207 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1209 vfModuleCustomization.setVfModule(vfModule);
1210 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1211 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1213 vfResourceStructure.setAlreadyDeployed(true);
1216 //******************************************************************************************************************
1217 //* Extract VFC's and CVFC's then add them to VFModule
1218 //******************************************************************************************************************
1220 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1222 // Extract CVFC lists
1223 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1225 for(NodeTemplate cvfcTemplate : cvfcList) {
1227 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(cvnfcCustomizations, 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 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1235 VnfcCustomization existingVnfcCustomization = null;
1237 for(NodeTemplate vfcTemplate : vfcList) {
1239 existingVnfcCustomization = findExistingVfc(vnfcCustomizations, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1241 if(existingVnfcCustomization == null){
1242 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1243 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1244 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1245 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1246 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1248 vnfcCustomization.setModelVersion(
1249 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1250 vnfcCustomization.setDescription(
1251 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1252 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1254 vnfcCustomizations.add(vnfcCustomization);
1257 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1258 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1259 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1260 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1261 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1262 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1264 cvnfcCustomization.setModelVersion(
1265 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1266 cvnfcCustomization.setDescription(
1267 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1268 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1270 if(existingVnfcCustomization != null){
1271 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1273 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1276 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1277 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1279 cvnfcCustomizations.add(cvnfcCustomization);
1281 //*****************************************************************************************************************************************
1282 //* Extract Fabric Configuration
1283 //*****************************************************************************************************************************************
1285 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1287 for(NodeTemplate fabricTemplate : fabricConfigList) {
1289 ConfigurationResource fabricConfig = null;
1291 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1293 if(existingConfig == null){
1295 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1297 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1299 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1301 fabricConfig = existingConfig;
1305 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1306 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1308 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 createVfModuleCustomzation(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 VFCInstanceGroup vfcInstanceGroup = findExistingVnfcInstanceGroup(vnfResourceCustomization,
1599 group.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1600 if(vfcInstanceGroup == null){
1601 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(
1602 vfNodeTemplate, group, vnfResourceCustomization);
1604 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1609 return vnfResourceCustomization;
1612 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1613 VnfResource vnfResource = null;
1614 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1615 if (vnfResourceCustom.getVnfResources() != null
1616 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1617 vnfResource = vnfResourceCustom.getVnfResources();
1620 if(vnfResource==null)
1621 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1626 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1627 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1628 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1629 vnfResourceCustomization.setModelCustomizationUUID(
1630 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1631 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1633 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1634 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1635 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1636 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1637 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1638 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1639 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1640 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1642 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1643 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1645 vnfResourceCustomization.setVnfResources(vnfResource);
1646 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1647 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1649 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1650 .getCapabilitiesOf(vfNodeTemplate);
1652 if (vnfCustomizationCapability != null) {
1653 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1655 if (capAssign != null) {
1656 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1657 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1658 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1659 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1664 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1666 return vnfResourceCustomization;
1669 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1670 VnfResource vnfResource = new VnfResource();
1671 vnfResource.setModelInvariantUUID(
1672 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1673 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1674 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1676 vnfResource.setModelVersion(
1677 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1678 vnfResource.setDescription(
1679 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1680 vnfResource.setOrchestrationMode(HEAT);
1681 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1682 vnfResource.setAicVersionMax(
1683 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1684 vnfResource.setAicVersionMin(
1685 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1690 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1691 ToscaResourceStructure toscaResourceStructure, Service service) {
1692 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1693 .findOneByModelCustomizationUUID(
1694 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1696 if(allottedResourceCustomization == null){
1697 AllottedResource allottedResource = findExistingAllottedResource(service,
1698 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1700 if(allottedResource==null)
1701 allottedResource=createAR(nodeTemplate);
1703 toscaResourceStructure.setAllottedResource(allottedResource);
1704 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1705 allottedResourceCustomization.setAllottedResource(allottedResource);
1706 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1708 return allottedResourceCustomization;
1711 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1712 AllottedResource allottedResource = null;
1713 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1714 if (allottedResourceCustom.getAllottedResource() != null
1715 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1716 allottedResource = allottedResourceCustom.getAllottedResource();
1719 if(allottedResource==null)
1720 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1722 return allottedResource;
1725 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1726 ToscaResourceStructure toscaResourceStructure) {
1727 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1728 allottedResourceCustomization.setModelCustomizationUUID(
1729 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1730 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1733 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1734 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1735 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1736 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1737 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1738 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1739 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1740 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1742 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1744 if(vfcNodes != null){
1745 for(NodeTemplate vfcNode : vfcNodes){
1747 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1748 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1749 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1754 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1755 .getCapabilitiesOf(nodeTemplate);
1757 if (arCustomizationCapability != null) {
1758 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1760 if (capAssign != null) {
1761 allottedResourceCustomization.setMinInstances(
1762 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1763 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1764 allottedResourceCustomization.setMaxInstances(
1765 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1766 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1769 return allottedResourceCustomization;
1772 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1773 AllottedResource allottedResource = new AllottedResource();
1775 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1776 allottedResource.setModelInvariantUUID(
1777 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1779 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1781 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1782 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1783 allottedResource.setSubcategory(
1784 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1786 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1787 return allottedResource;
1790 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1791 // Scan the payload downloadResult and extract the HeatTemplate
1793 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1794 return yamlEditor.getParameterList(artifactUUID);
1797 protected String testNull(Object object) {
1799 if (object == null) {
1801 } else if (object.equals("NULL")) {
1803 } else if (object instanceof Integer) {
1804 return object.toString();
1805 } else if (object instanceof String) {
1806 return (String) object;
1808 return "Type not recognized";
1812 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1813 VfModuleArtifact heatNestedArtifact) {
1815 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1816 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1817 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1818 .getArtifactInfo().getRelatedArtifacts()) {
1819 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1820 return ASDCConfiguration.HEAT;
1826 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1827 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1828 .getRelatedArtifacts() != null) {
1829 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1830 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1831 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1832 return ASDCConfiguration.HEAT_VOL;
1838 // Does not belong to anything
1843 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1845 return vfResourceStructure.getNotification().getServiceName() + "/"
1846 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1849 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1851 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1852 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1856 protected static Timestamp getCurrentTimeStamp() {
1858 return new Timestamp(new Date().getTime());