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.CollectionResourceInstanceGroupCustomization;
63 import org.onap.so.db.catalog.beans.ConfigurationResource;
64 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
65 import org.onap.so.db.catalog.beans.CvnfcCustomization;
66 import org.onap.so.db.catalog.beans.HeatEnvironment;
67 import org.onap.so.db.catalog.beans.HeatFiles;
68 import org.onap.so.db.catalog.beans.HeatTemplate;
69 import org.onap.so.db.catalog.beans.HeatTemplateParam;
70 import org.onap.so.db.catalog.beans.InstanceGroupType;
71 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
72 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
73 import org.onap.so.db.catalog.beans.NetworkResource;
74 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
75 import org.onap.so.db.catalog.beans.Service;
76 import org.onap.so.db.catalog.beans.ServiceProxyResource;
77 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
78 import org.onap.so.db.catalog.beans.SubType;
79 import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
80 import org.onap.so.db.catalog.beans.ToscaCsar;
81 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
82 import org.onap.so.db.catalog.beans.VfModule;
83 import org.onap.so.db.catalog.beans.VfModuleCustomization;
84 import org.onap.so.db.catalog.beans.VnfResource;
85 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
86 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
87 import org.onap.so.db.catalog.beans.VnfcCustomization;
88 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
89 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
90 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
91 import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
92 import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
93 import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
94 import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
95 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
96 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
97 import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
98 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
99 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
100 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
101 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
102 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceRepository;
103 import org.onap.so.db.catalog.data.repository.ServiceRepository;
104 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
105 import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
106 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
107 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
108 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
109 import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
110 import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
111 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
112 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
113 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
114 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
115 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
116 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
117 import org.onap.so.logger.MessageEnum;
118 import org.onap.so.logger.MsoLogger;
119 import org.springframework.beans.factory.annotation.Autowired;
120 import org.springframework.stereotype.Component;
121 import org.springframework.transaction.annotation.Transactional;
124 public class ToscaResourceInstaller {
126 protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
128 protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
130 protected static final String SCALABLE = "scalable";
132 protected static final String BASIC = "BASIC";
134 protected static final String PROVIDER = "PROVIDER";
136 protected static final String HEAT = "HEAT";
138 protected static final String MANUAL_RECORD = "MANUAL_RECORD";
140 protected static final String MSO = "SO";
143 protected ServiceRepository serviceRepo;
146 protected InstanceGroupRepository instanceGroupRepo;
149 protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
152 protected ServiceProxyResourceRepository serviceProxyRepo;
155 protected CollectionResourceRepository collectionRepo;
158 protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
161 protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
164 protected ConfigurationResourceRepository configRepo;
167 protected VnfResourceRepository vnfRepo;
170 protected VnfCustomizationRepository vnfCustomizationRepo;
173 protected VFModuleRepository vfModuleRepo;
176 protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
179 protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
182 protected VnfcCustomizationRepository vnfcCustomizationRepo;
185 protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
188 protected AllottedResourceRepository allottedRepo;
191 protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
194 protected NetworkResourceRepository networkRepo;
197 protected HeatTemplateRepository heatRepo;
200 protected NetworkResourceCustomizationRepository networkCustomizationRepo;
203 protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
205 protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
207 protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
210 protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
213 protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
215 protected static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ToscaResourceInstaller.class);
217 public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
218 boolean status = false;
219 VfResourceStructure vfResourceStructure = vfResourceStruct;
221 status = vfResourceStructure.isDeployedSuccessfully();
222 } catch (RuntimeException e) {
226 Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
227 if(existingService != null)
230 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
231 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
232 vfResourceStructure.getNotification().getServiceName(),
233 BigDecimalVersion.castAndCheckNotificationVersionToString(
234 vfResourceStructure.getNotification().getServiceVersion()),
235 vfResourceStructure.getNotification().getServiceUUID(),
236 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
237 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
238 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
239 watchdogCDStatusRepository.saveAndFlush(wdStatus);
241 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
242 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
243 vfResourceStructure.getNotification().getServiceName(),
244 BigDecimalVersion.castAndCheckNotificationVersionToString(
245 vfResourceStructure.getNotification().getServiceVersion()),
246 vfResourceStructure.getNotification().getServiceUUID(),
247 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
250 } catch (Exception e) {
251 logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError,
252 "Exception - isResourceAlreadyDeployed");
253 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
257 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
258 logger.debug("Entering installTheComponentStatus for distributionId " + iStatus.getDistributionID()
259 + " and ComponentName " + iStatus.getComponentName());
262 WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
263 iStatus.getComponentName());
264 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
265 watchdogCDStatusRepository.save(cdStatus);
267 } catch (Exception e) {
268 logger.debug("Exception caught in installTheComponentStatus " + e.getMessage());
269 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
273 @Transactional(rollbackFor = { ArtifactInstallerException.class })
274 public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
275 throws ArtifactInstallerException {
276 VfResourceStructure vfResourceStructure = vfResourceStruct;
277 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
279 // PCLO: in case of deployment failure, use a string that will represent
280 // the type of artifact that failed...
281 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
283 createToscaCsar(toscaResourceStruct);
284 createService(toscaResourceStruct, vfResourceStruct);
285 Service service = toscaResourceStruct.getCatalogService();
287 processVFResources(toscaResourceStruct, service, vfResourceStructure);
288 processAllottedResources(toscaResourceStruct, service);
289 processNetworks(toscaResourceStruct, service);
290 // process Network Collections
291 processNetworkCollections(toscaResourceStruct, service);
292 // Process Service Proxy & Configuration
293 processServiceProxyAndConfiguration(toscaResourceStruct, service);
295 serviceRepo.save(service);
297 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
298 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
299 watchdogCDStatusRepository.save(status);
301 toscaResourceStruct.setSuccessfulDeployment();
303 } catch (Exception e) {
304 logger.debug("Exception :", e);
305 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
306 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
307 watchdogCDStatusRepository.save(status);
308 Throwable dbExceptionToCapture = e;
309 while (!(dbExceptionToCapture instanceof ConstraintViolationException
310 || dbExceptionToCapture instanceof LockAcquisitionException)
311 && (dbExceptionToCapture.getCause() != null)) {
312 dbExceptionToCapture = dbExceptionToCapture.getCause();
315 if (dbExceptionToCapture instanceof ConstraintViolationException
316 || dbExceptionToCapture instanceof LockAcquisitionException) {
317 logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED,
318 vfResourceStructure.getResourceInstance().getResourceName(),
319 vfResourceStructure.getNotification().getServiceVersion(), "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
321 String elementToLog = (!artifactListForLogging.isEmpty()
322 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
323 : "No element listed");
324 logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError,
325 "Exception caught during installation of "
326 + vfResourceStructure.getResourceInstance().getResourceName()
327 + ". Transaction rollback",
329 throw new ArtifactInstallerException("Exception caught during installation of "
330 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
335 protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
336 Service service) throws ArtifactInstallerException {
337 List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
339 if (nodeTemplatesVLList != null) {
340 for (NodeTemplate vlNode : nodeTemplatesVLList) {
341 String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
343 TempNetworkHeatTemplateLookup tempNetworkLookUp =
344 tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
346 if (tempNetworkLookUp != null) {
347 HeatTemplate heatTemplate =
348 heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
349 if (heatTemplate != null) {
350 NetworkResourceCustomization networkCustomization =
351 createNetwork (vlNode,
354 tempNetworkLookUp.getAicVersionMax (),
355 tempNetworkLookUp.getAicVersionMin (),
357 service.getNetworkCustomizations ().add (networkCustomization);
359 throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
360 + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
363 NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
369 service.getNetworkCustomizations().add (networkCustomization);
370 logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
371 + networkResourceModelName);
378 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) {
379 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
381 if (allottedResourceList != null) {
382 for (NodeTemplate allottedNode : allottedResourceList) {
383 service.getAllottedCustomizations()
384 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
389 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
391 List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
393 List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
395 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
396 List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
398 ServiceProxyResourceCustomization serviceProxy = null;
400 if (serviceProxyResourceList != null) {
401 for (NodeTemplate spNode : serviceProxyResourceList) {
402 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
404 ServiceProxyResource serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getServiceProxyResource().getModelUUID());
406 if(serviceProxyResource == null){
408 serviceProxyList.add(serviceProxy);
410 for (NodeTemplate configNode : configurationNodeTemplatesList) {
412 List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
413 for (RequirementAssignment requirement : requirementsList) {
414 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
415 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy);
417 configurationResourceList.add(configurationResource);
428 service.setConfigurationCustomizations(configurationResourceList);
429 service.setServiceProxyCustomizations(serviceProxyList);
432 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
434 List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
436 if (networkCollectionList != null) {
437 for (NodeTemplate crNode : networkCollectionList) {
439 createNetworkCollection(crNode, toscaResourceStruct, service);
440 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
442 List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
443 for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
444 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
449 service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
453 protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
455 logger.debug("processVFResources");
457 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
458 // String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
459 // String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
461 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
462 Metadata metadata = nodeTemplate.getMetaData();
463 String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
464 logger.debug("VF Category is : " + vfCustomizationCategory);
466 // Do not treat Allotted Resources as VNF resources
467 if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
471 String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
472 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
474 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
476 // Make sure the VF ResourceCustomizationUUID from the notification and tosca
477 // customizations match before comparing their VF Modules UUID's
478 logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
479 + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
480 + vfCustomizationUUID);
482 if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
483 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
484 + " matches vfNotificationResource CustomizationUUID");
486 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, vfCustomizationUUID);
489 logger.debug("Notification VF ResourceCustomizationUUID: "
490 + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
491 + "Tosca VF Customization UUID: " + vfCustomizationUUID);
497 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
498 Service service, NodeTemplate nodeTemplate, String vfCustomizationUUID)
500 logger.debug("processVfModules for vfCustomizationUUID: " + vfCustomizationUUID);
502 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
504 if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
505 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
506 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
508 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
510 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
511 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct.getSdcCsarHelper()
512 .getVfModulesByVf(vfCustomizationUUID);
513 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
515 logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
517 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
518 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
519 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
521 if (matchingObject.isPresent()) {
522 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
523 vfResourceStructure, vfMetadata, vnfResource,service, existingCvnfcSet, existingVnfcSet);
524 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
526 throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
531 service.getVnfCustomizations().add(vnfResource);
534 public void processWatchdog(String distributionId, String servideUUID) {
535 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
536 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
538 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
539 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
542 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
543 VfResourceStructure vfResourceStructure) {
544 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
546 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
547 case ASDCConfiguration.HEAT:
548 case ASDCConfiguration.HEAT_NESTED:
549 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
552 case ASDCConfiguration.HEAT_VOL:
553 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
555 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
556 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
558 case ASDCConfiguration.HEAT_ENV:
559 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
561 case ASDCConfiguration.HEAT_ARTIFACT:
562 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
563 toscaResourceStruct);
565 case ASDCConfiguration.HEAT_NET:
566 case ASDCConfiguration.OTHER:
567 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
568 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
569 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
570 "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
579 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
580 VfModuleArtifact vfModuleArtifact) {
581 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
582 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
583 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
584 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
585 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
586 return moduleArtifact;
592 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
593 List<String> listTypes) {
594 String newFileBody = filebody;
595 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
597 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
599 newFileBody = verifyTheFilePrefixInString(newFileBody,
600 moduleArtifact.getArtifactInfo().getArtifactName());
606 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
608 String needlePrefix = "file:///";
609 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
611 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
615 StringBuilder sb = new StringBuilder(body.length());
617 int currentIndex = 0;
620 while (currentIndex != -1) {
621 startIndex = currentIndex;
622 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
624 if (currentIndex == -1) {
627 // We append from the startIndex up to currentIndex (start of File
629 sb.append(body.substring(startIndex, currentIndex));
630 sb.append(filenameToVerify);
632 currentIndex += prefixedFilenameToVerify.length();
635 sb.append(body.substring(startIndex));
637 return sb.toString();
640 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
641 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
642 HeatTemplate heatTemplate = new HeatTemplate();
643 List<String> typeList = new ArrayList<>();
644 typeList.add(ASDCConfiguration.HEAT_NESTED);
645 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
647 heatTemplate.setTemplateBody(
648 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
649 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
651 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
652 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
654 heatTemplate.setTimeoutMinutes(240);
657 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
658 heatTemplate.setVersion(BigDecimalVersion
659 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
660 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
662 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
663 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
665 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
668 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
669 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
670 heatTemplate.setParameters(heatParam);
671 vfModuleArtifact.setHeatTemplate(heatTemplate);
674 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
675 VfModuleArtifact vfModuleArtifact) {
676 HeatEnvironment heatEnvironment = new HeatEnvironment();
677 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
678 List<String> typeList = new ArrayList<>();
679 typeList.add(ASDCConfiguration.HEAT);
680 typeList.add(ASDCConfiguration.HEAT_VOL);
681 heatEnvironment.setEnvironment(
682 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
683 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
684 heatEnvironment.setVersion(BigDecimalVersion
685 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
686 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
688 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
689 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
691 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
693 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
696 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
697 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
699 HeatFiles heatFile = new HeatFiles();
700 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
701 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
702 heatFile.setFileBody(vfModuleArtifact.getResult());
703 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
704 heatFile.setVersion(BigDecimalVersion
705 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
706 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
707 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
708 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
710 heatFile.setArtifactChecksum(MANUAL_RECORD);
712 vfModuleArtifact.setHeatFiles(heatFile);
715 protected Service createService(ToscaResourceStructure toscaResourceStructure,
716 VfResourceStructure vfResourceStructure) {
718 toscaResourceStructure.getServiceMetadata();
720 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
722 Service service = new Service();
724 if (serviceMetadata != null) {
726 if (toscaResourceStructure.getServiceVersion() != null) {
727 service.setModelVersion(toscaResourceStructure.getServiceVersion());
730 service.setServiceType(serviceMetadata.getValue("serviceType"));
731 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
733 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
734 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
735 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
736 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
738 if (vfResourceStructure != null)
739 service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
741 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
742 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
746 toscaResourceStructure.setCatalogService(service);
750 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
752 Metadata spMetadata = nodeTemplate.getMetaData();
754 ServiceProxyResource spResource = new ServiceProxyResource();
756 spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
757 spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
758 spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
759 spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
760 spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
762 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
764 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
766 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
767 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
768 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
769 spCustomizationResource.setSourceService(service);
770 spCustomizationResource.setServiceProxyResource(spResource);
771 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
772 spCustomizationResource.setServiceProxyResource(spResource);
773 serviceProxyCustomizationSet.add(spCustomizationResource);
775 toscaResourceStructure.setCatalogServiceProxyResource(spResource);
777 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
779 return spCustomizationResource;
782 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
784 Metadata metadata = nodeTemplate.getMetaData();
786 ConfigurationResource configResource = new ConfigurationResource();
788 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
789 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
790 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
791 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
792 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
793 configResource.setToscaNodeType(nodeTemplate.getType());
795 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
797 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
799 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
800 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
802 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
803 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
804 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
805 configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
806 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
807 configCustomizationResource.setConfigurationResource(configResource);
808 configResourceCustomizationSet.add(configCustomizationResource);
810 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
812 toscaResourceStructure.setCatalogConfigurationResource(configResource);
814 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
816 return configCustomizationResource;
819 protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
821 Metadata fabricMetadata = nodeTemplate.getMetaData();
823 ConfigurationResource configResource = new ConfigurationResource();
825 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
826 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
827 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
828 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
829 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
830 configResource.setToscaNodeType(nodeTemplate.getType());
832 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
834 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
836 configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
837 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
839 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
840 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
841 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
842 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
843 configCustomizationResource.setConfigurationResource(configResource);
844 configResourceCustomizationSet.add(configCustomizationResource);
846 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
848 return configCustomizationResource;
851 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
852 ToscaCsar toscaCsar = new ToscaCsar();
853 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
854 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
856 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
858 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
859 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
860 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
861 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
862 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
864 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
867 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
868 VnfcCustomization vnfcCustomization = null;
869 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
870 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
871 vnfcCustomization = vnfcCustom;
875 if(vnfcCustomization==null)
876 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
878 return vnfcCustomization;
881 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
882 CvnfcCustomization cvnfcCustomization = null;
883 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
884 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
885 cvnfcCustomization = cvnfcCustom;
889 if(cvnfcCustomization==null)
890 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
892 return cvnfcCustomization;
895 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
896 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
898 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
899 if(networkResourceCustomization==null){
900 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
901 toscaResourceStructure);
903 NetworkResource networkResource = findExistingNetworkResource(service,
904 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
905 if(networkResource == null)
906 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
909 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
910 networkResourceCustomization.setNetworkResource(networkResource);
912 return networkResourceCustomization;
915 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
916 NetworkResource networkResource = null;
917 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
918 if (networkCustom.getNetworkResource() != null
919 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
920 networkResource = networkCustom.getNetworkResource();
923 if(networkResource==null)
924 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
926 return networkResource;
929 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
930 ToscaResourceStructure toscaResourceStructure) {
931 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
932 networkResourceCustomization.setModelInstanceName(
933 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
934 networkResourceCustomization.setModelCustomizationUUID(
935 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
937 networkResourceCustomization.setNetworkTechnology(
938 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
939 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
940 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
941 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
942 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
943 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
944 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
945 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
946 return networkResourceCustomization;
949 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
950 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
951 NetworkResource networkResource = new NetworkResource();
952 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
953 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
955 if ("true".equalsIgnoreCase(providerNetwork)) {
956 networkResource.setNeutronNetworkType(PROVIDER);
958 networkResource.setNeutronNetworkType(BASIC);
961 networkResource.setModelName(
962 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
964 networkResource.setModelInvariantUUID(
965 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
966 networkResource.setModelUUID(
967 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
968 networkResource.setModelVersion(
969 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
971 networkResource.setAicVersionMax(aicMax);
972 networkResource.setAicVersionMin(aicMin);
973 networkResource.setToscaNodeType(networkNodeTemplate.getType());
974 networkResource.setDescription(
975 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
976 networkResource.setOrchestrationMode(HEAT);
977 networkResource.setHeatTemplate(heatTemplate);
978 return networkResource;
981 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
982 ToscaResourceStructure toscaResourceStructure, Service service) {
984 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
986 // **** Build Object to populate Collection_Resource table
987 CollectionResource collectionResource = new CollectionResource();
990 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
991 collectionResource.setModelInvariantUUID(
992 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
994 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
996 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
998 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
999 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
1001 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
1003 // **** Build object to populate Collection_Resource_Customization table
1004 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
1006 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1008 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1010 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1013 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1014 ncfc.setModelCustomizationUUID(
1015 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1017 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
1018 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
1020 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1022 ncfc.setCollectionResource(collectionResource);
1023 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1025 //*** Build object to populate the Instance_Group table
1026 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1027 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
1028 "org.openecomp.groups.NetworkCollection");
1030 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1032 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
1034 for (Group group : groupList) {
1036 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1037 Metadata instanceMetadata = group.getMetadata();
1038 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1039 networkInstanceGroup
1040 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1041 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1042 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1043 networkInstanceGroup.setToscaNodeType(group.getType());
1044 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1046 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1048 networkInstanceGroup.setCollectionResource(collectionResource);
1050 // ****Build object to populate
1051 // Collection_Resource_Instance_Group_Customization table
1052 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1053 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1054 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1055 crInstanceGroupCustomization.setModelCustomizationUUID(
1056 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1058 String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
1059 String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
1060 if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1061 fixedQuantity + "_quantity") != null) {
1063 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
1064 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1065 fixedQuantity + "_quantity")));
1068 crInstanceGroupCustomization.setDescription(
1069 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1070 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1071 + "_network_collection_description"));
1072 crInstanceGroupCustomization.setFunction(
1073 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1074 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1075 + "_network_collection_function"));
1076 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1077 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1079 networkInstanceGroup
1080 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1082 networkInstanceGroupList.add(networkInstanceGroup);
1086 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1088 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1089 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1091 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1093 //*****Build object to populate the NetworkResource table
1094 NetworkResource networkResource = new NetworkResource();
1096 for(NodeTemplate vlNodeTemplate : vlNodeList){
1098 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1099 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1101 if ("true".equalsIgnoreCase(providerNetwork)) {
1102 networkResource.setNeutronNetworkType(PROVIDER);
1104 networkResource.setNeutronNetworkType(BASIC);
1107 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1109 networkResource.setModelInvariantUUID(
1110 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1111 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1113 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1115 networkResource.setAicVersionMax(
1116 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1118 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1119 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1121 if (tempNetworkLookUp != null ) {
1123 HeatTemplate heatTemplate = heatRepo
1124 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1125 networkResource.setHeatTemplate(heatTemplate);
1127 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1131 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1133 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1134 networkResource.setOrchestrationMode(HEAT);
1136 // Build object to populate the
1137 // Collection_Network_Resource_Customization table
1138 for (NodeTemplate memberNode : group.getMemberNodes()) {
1139 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1142 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1143 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1145 collectionNetworkResourceCustomization.setNetworkTechnology(
1146 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1147 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1148 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1149 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1150 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1151 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1152 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1153 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1154 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1155 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1156 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1158 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1163 return collectionNetworkResourceCustomization;
1166 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1167 VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
1169 Metadata instanceMetadata = group.getMetadata();
1170 // Populate InstanceGroup
1171 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1173 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1174 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1175 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1176 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1177 vfcInstanceGroup.setToscaNodeType(group.getType());
1178 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1179 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1181 //Populate VNFCInstanceGroupCustomization
1182 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1184 vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
1185 vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1186 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1188 String getInputName = null;
1189 String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function");
1190 if (groupProperty != null) {
1191 int getInputIndex = groupProperty.indexOf("{get_input=");
1192 if (getInputIndex > -1) {
1193 getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
1196 vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
1198 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1199 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1201 return vfcInstanceGroupCustom;
1205 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1206 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1207 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1209 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1210 vfModuleData.getVfModuleModelCustomizationUUID());
1211 if(vfModuleCustomization == null){
1212 VfModule vfModule = findExistingVfModule(vnfResource,
1213 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1214 Metadata vfMetadata = group.getMetadata();
1216 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1218 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1219 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1221 vfModuleCustomization.setVfModule(vfModule);
1222 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1223 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1225 vfResourceStructure.setAlreadyDeployed(true);
1228 //******************************************************************************************************************
1229 //* Extract VFC's and CVFC's then add them to VFModule
1230 //******************************************************************************************************************
1232 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1233 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1234 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1236 // Extract CVFC lists
1237 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1239 for(NodeTemplate cvfcTemplate : cvfcList) {
1241 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1243 if(existingCvnfcCustomization == null){
1245 //Extract associated VFC - Should always be just one
1246 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1248 for(NodeTemplate vfcTemplate : vfcList) {
1250 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1251 VnfcCustomization existingVnfcCustomization = null;
1253 existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1255 // Only Add Abstract VNFC's to our DB, ignore all others
1256 if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
1257 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1258 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1259 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1260 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1261 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1263 vnfcCustomization.setModelVersion(
1264 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1265 vnfcCustomization.setDescription(
1266 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1267 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1269 vnfcCustomizations.add(vnfcCustomization);
1270 existingVnfcSet.add(vnfcCustomization);
1273 // 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.
1274 if(vnfcCustomization.getModelCustomizationUUID() != null){
1276 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1277 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1278 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1279 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1280 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1281 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1283 cvnfcCustomization.setModelVersion(
1284 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1285 cvnfcCustomization.setDescription(
1286 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1287 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1289 if(existingVnfcCustomization != null){
1290 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1292 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1295 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1296 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1298 cvnfcCustomizations.add(cvnfcCustomization);
1299 existingCvnfcSet.add(cvnfcCustomization);
1301 //*****************************************************************************************************************************************
1302 //* Extract Fabric Configuration
1303 //*****************************************************************************************************************************************
1305 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1307 for(NodeTemplate fabricTemplate : fabricConfigList) {
1309 ConfigurationResource fabricConfig = null;
1311 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1313 if(existingConfig == null){
1315 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1317 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1319 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1321 fabricConfig = existingConfig;
1325 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1326 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1328 vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
1339 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1340 vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
1342 return vfModuleCustomization;
1345 protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1346 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1347 ConfigurationResource configResource) {
1349 Metadata fabricMetadata = fabricTemplate.getMetaData();
1352 VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
1354 vfModuleToCvnfc.setConfigurationResource(configResource);
1355 vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
1356 vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1357 vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
1358 vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
1359 vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
1360 vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
1362 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
1364 if(policyList != null){
1365 for(Policy policy : policyList){
1366 vfModuleToCvnfc.setPolicyName(policy.getName());
1370 vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
1371 vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
1372 vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
1374 return vfModuleToCvnfc;
1377 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1378 ConfigurationResource configResource = null;
1379 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1380 if (configurationResourceCustom.getConfigurationResource() != null
1381 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1382 configResource = configurationResourceCustom.getConfigurationResource();
1385 if(configResource==null)
1386 configResource = configRepo.findResourceByModelUUID(modelUUID);
1388 return configResource;
1391 protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) {
1392 ServiceProxyResource serviceProxyResource = null;
1393 for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){
1394 if (serviceProxyResourceCustom.getServiceProxyResource() != null
1395 && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) {
1396 serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource();
1399 if(serviceProxyResource==null)
1400 serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID);
1402 return serviceProxyResource;
1405 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1406 String vfModuleModelCustomizationUUID) {
1407 VfModuleCustomization vfModuleCustomization = null;
1408 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1409 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1410 vfModuleCustomization = vfModuleCustom;
1413 if(vfModuleCustomization==null)
1414 vfModuleCustomization = vfModuleCustomizationRepo
1415 .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
1417 return vfModuleCustomization;
1420 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1421 VfModule vfModule = null;
1422 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1423 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1424 vfModule = vfModuleCustom.getVfModule();
1428 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1433 protected VfModuleCustomization createVfModuleCustomization(Group group,
1434 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1435 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1437 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1439 vfModuleCustomization.setVfModule(vfModule);
1441 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1442 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1443 if (initialCount != null && initialCount.length() > 0) {
1444 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1447 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1448 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1450 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1451 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1452 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1453 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1456 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1457 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1459 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1460 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1461 if (maxInstances != null && maxInstances.length() > 0) {
1462 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1465 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1466 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1467 if (minInstances != null && minInstances.length() > 0) {
1468 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1470 return vfModuleCustomization;
1473 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1474 IVfModuleData vfModuleData, Metadata vfMetadata) {
1475 VfModule vfModule = new VfModule();
1476 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1478 if(vfModuleModelUUID == null) {
1479 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1480 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1481 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1482 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1485 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1486 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1487 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1488 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1489 vfModule.setModelUUID(vfModuleModelUUID);
1490 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1491 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1492 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1493 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1495 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1496 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1497 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1498 vfModule.setIsBase(true);
1500 vfModule.setIsBase(false);
1505 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
1506 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1507 Metadata vfMetadata) {
1509 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
1510 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
1511 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1512 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
1515 if (matchingObject.isPresent()) {
1516 List<HeatFiles> heatFilesList = new ArrayList<>();
1517 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
1518 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
1519 HeatTemplate parentHeatTemplate = new HeatTemplate();
1520 String parentArtifactType = null;
1521 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
1522 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1524 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
1526 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
1527 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
1528 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
1531 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
1532 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
1534 if(!childNestedHeatTemplates.isEmpty()){
1536 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
1537 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
1539 heatChildTemplates.add(childNestedHeatTemplates.get(0));
1545 if(!heatFilesList.isEmpty()){
1546 vfModule.setHeatFiles(heatFilesList);
1550 // Set all Child Templates related to HEAT_VOLUME
1551 if(!volumeHeatChildTemplates.isEmpty()){
1552 if(vfModule.getVolumeHeatTemplate() != null){
1553 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
1555 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
1559 // Set all Child Templates related to HEAT
1560 if(!heatChildTemplates.isEmpty()){
1561 if(vfModule.getModuleHeatTemplate() != null){
1562 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
1564 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
1570 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1571 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
1572 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
1573 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
1574 vfModuleArtifact.incrementDeployedInDB();
1575 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
1576 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
1577 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
1578 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1579 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
1580 vfModuleArtifact.incrementDeployedInDB();
1581 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1582 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
1583 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
1585 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
1587 vfModuleArtifact.incrementDeployedInDB();
1588 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
1589 heatFilesList.add(vfModuleArtifact.getHeatFiles());
1590 vfModuleArtifact.incrementDeployedInDB();
1591 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
1592 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
1593 vfModuleArtifact.incrementDeployedInDB();
1597 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
1598 ToscaResourceStructure toscaResourceStructure, Service service) {
1599 VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
1600 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1601 if(vnfResourceCustomization == null){
1602 VnfResource vnfResource = findExistingVnfResource(service,
1603 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1605 if(vnfResource==null)
1606 vnfResource=createVnfResource(vfNodeTemplate);
1608 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
1610 vnfResourceCustomization.setVnfResources(vnfResource);
1611 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
1613 // Fetch VNFC Instance Group Info
1614 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1615 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
1616 "org.openecomp.groups.VfcInstanceGroup");
1618 for (Group group : groupList) {
1620 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization, toscaResourceStructure);
1622 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1625 return vnfResourceCustomization;
1628 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1629 VnfResource vnfResource = null;
1630 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1631 if (vnfResourceCustom.getVnfResources() != null
1632 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1633 vnfResource = vnfResourceCustom.getVnfResources();
1636 if(vnfResource==null)
1637 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1642 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1643 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1644 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1645 vnfResourceCustomization.setModelCustomizationUUID(
1646 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1647 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1649 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1650 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1651 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1652 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1653 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1654 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1655 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1656 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1658 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1659 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1661 vnfResourceCustomization.setVnfResources(vnfResource);
1662 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1663 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1665 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1666 .getCapabilitiesOf(vfNodeTemplate);
1668 if (vnfCustomizationCapability != null) {
1669 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1671 if (capAssign != null) {
1672 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1673 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1674 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1675 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1680 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1682 return vnfResourceCustomization;
1685 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1686 VnfResource vnfResource = new VnfResource();
1687 vnfResource.setModelInvariantUUID(
1688 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1689 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1690 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1692 vnfResource.setModelVersion(
1693 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1694 vnfResource.setDescription(
1695 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1696 vnfResource.setOrchestrationMode(HEAT);
1697 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1698 vnfResource.setAicVersionMax(
1699 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1700 vnfResource.setAicVersionMin(
1701 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1702 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1703 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
1708 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1709 ToscaResourceStructure toscaResourceStructure, Service service) {
1710 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1711 .findOneByModelCustomizationUUID(
1712 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1714 if(allottedResourceCustomization == null){
1715 AllottedResource allottedResource = findExistingAllottedResource(service,
1716 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1718 if(allottedResource==null)
1719 allottedResource=createAR(nodeTemplate);
1721 toscaResourceStructure.setAllottedResource(allottedResource);
1722 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1723 allottedResourceCustomization.setAllottedResource(allottedResource);
1724 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1726 return allottedResourceCustomization;
1729 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1730 AllottedResource allottedResource = null;
1731 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1732 if (allottedResourceCustom.getAllottedResource() != null
1733 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1734 allottedResource = allottedResourceCustom.getAllottedResource();
1737 if(allottedResource==null)
1738 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1740 return allottedResource;
1743 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1744 ToscaResourceStructure toscaResourceStructure) {
1745 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1746 allottedResourceCustomization.setModelCustomizationUUID(
1747 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1748 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1751 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1752 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1753 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1754 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1755 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1756 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1757 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1758 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1760 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1762 if(vfcNodes != null){
1763 for(NodeTemplate vfcNode : vfcNodes){
1765 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1766 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1767 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1772 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1773 .getCapabilitiesOf(nodeTemplate);
1775 if (arCustomizationCapability != null) {
1776 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1778 if (capAssign != null) {
1779 allottedResourceCustomization.setMinInstances(
1780 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1781 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1782 allottedResourceCustomization.setMaxInstances(
1783 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1784 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1787 return allottedResourceCustomization;
1790 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1791 AllottedResource allottedResource = new AllottedResource();
1793 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1794 allottedResource.setModelInvariantUUID(
1795 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1797 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1799 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1800 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1801 allottedResource.setSubcategory(
1802 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1804 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1805 return allottedResource;
1808 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1809 // Scan the payload downloadResult and extract the HeatTemplate
1811 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1812 return yamlEditor.getParameterList(artifactUUID);
1815 protected String testNull(Object object) {
1817 if (object == null) {
1819 } else if (object.equals("NULL")) {
1821 } else if (object instanceof Integer) {
1822 return object.toString();
1823 } else if (object instanceof String) {
1824 return (String) object;
1826 return "Type not recognized";
1830 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1831 VfModuleArtifact heatNestedArtifact) {
1833 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1834 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1835 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1836 .getArtifactInfo().getRelatedArtifacts()) {
1837 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1838 return ASDCConfiguration.HEAT;
1844 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1845 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1846 .getRelatedArtifacts() != null) {
1847 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1848 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1849 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1850 return ASDCConfiguration.HEAT_VOL;
1856 // Does not belong to anything
1861 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1863 return vfResourceStructure.getNotification().getServiceName() + "/"
1864 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1867 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1869 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1870 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1874 protected static Timestamp getCurrentTimeStamp() {
1876 return new Timestamp(new Date().getTime());