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) {
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));
1187 vfcInstanceGroupCustom.setFunction("FUNCTION");
1188 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1189 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1191 return vfcInstanceGroupCustom;
1195 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1196 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1197 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1199 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1200 vfModuleData.getVfModuleModelCustomizationUUID());
1201 if(vfModuleCustomization == null){
1202 VfModule vfModule = findExistingVfModule(vnfResource,
1203 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1204 Metadata vfMetadata = group.getMetadata();
1206 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1208 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1209 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1211 vfModuleCustomization.setVfModule(vfModule);
1212 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1213 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1215 vfResourceStructure.setAlreadyDeployed(true);
1218 //******************************************************************************************************************
1219 //* Extract VFC's and CVFC's then add them to VFModule
1220 //******************************************************************************************************************
1222 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1223 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1224 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1226 // Extract CVFC lists
1227 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1229 for(NodeTemplate cvfcTemplate : cvfcList) {
1231 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1233 if(existingCvnfcCustomization == null){
1235 //Extract associated VFC - Should always be just one
1236 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1238 for(NodeTemplate vfcTemplate : vfcList) {
1240 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1241 VnfcCustomization existingVnfcCustomization = null;
1243 existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1245 // Only Add Abstract VNFC's to our DB, ignore all others
1246 if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
1247 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1248 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1249 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1250 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1251 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1253 vnfcCustomization.setModelVersion(
1254 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1255 vnfcCustomization.setDescription(
1256 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1257 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1259 vnfcCustomizations.add(vnfcCustomization);
1260 existingVnfcSet.add(vnfcCustomization);
1263 // 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.
1264 if(vnfcCustomization.getModelCustomizationUUID() != null){
1266 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1267 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1268 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1269 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1270 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1271 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1273 cvnfcCustomization.setModelVersion(
1274 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1275 cvnfcCustomization.setDescription(
1276 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1277 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1279 if(existingVnfcCustomization != null){
1280 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1282 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1285 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1286 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1288 cvnfcCustomizations.add(cvnfcCustomization);
1289 existingCvnfcSet.add(cvnfcCustomization);
1291 //*****************************************************************************************************************************************
1292 //* Extract Fabric Configuration
1293 //*****************************************************************************************************************************************
1295 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1297 for(NodeTemplate fabricTemplate : fabricConfigList) {
1299 ConfigurationResource fabricConfig = null;
1301 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1303 if(existingConfig == null){
1305 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1307 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1309 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1311 fabricConfig = existingConfig;
1315 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1316 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1318 vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
1329 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1330 vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
1332 return vfModuleCustomization;
1335 protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1336 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1337 ConfigurationResource configResource) {
1339 Metadata fabricMetadata = fabricTemplate.getMetaData();
1342 VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
1344 vfModuleToCvnfc.setConfigurationResource(configResource);
1345 vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
1346 vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1347 vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
1348 vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
1349 vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
1350 vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
1352 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
1354 if(policyList != null){
1355 for(Policy policy : policyList){
1356 vfModuleToCvnfc.setPolicyName(policy.getName());
1360 vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
1361 vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
1362 vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
1364 return vfModuleToCvnfc;
1367 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1368 ConfigurationResource configResource = null;
1369 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1370 if (configurationResourceCustom.getConfigurationResource() != null
1371 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1372 configResource = configurationResourceCustom.getConfigurationResource();
1375 if(configResource==null)
1376 configResource = configRepo.findResourceByModelUUID(modelUUID);
1378 return configResource;
1381 protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) {
1382 ServiceProxyResource serviceProxyResource = null;
1383 for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){
1384 if (serviceProxyResourceCustom.getServiceProxyResource() != null
1385 && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) {
1386 serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource();
1389 if(serviceProxyResource==null)
1390 serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID);
1392 return serviceProxyResource;
1395 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1396 String vfModuleModelCustomizationUUID) {
1397 VfModuleCustomization vfModuleCustomization = null;
1398 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1399 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1400 vfModuleCustomization = vfModuleCustom;
1403 if(vfModuleCustomization==null)
1404 vfModuleCustomization = vfModuleCustomizationRepo
1405 .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
1407 return vfModuleCustomization;
1410 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1411 VfModule vfModule = null;
1412 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1413 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1414 vfModule = vfModuleCustom.getVfModule();
1418 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1423 protected VfModuleCustomization createVfModuleCustomization(Group group,
1424 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1425 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1427 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1429 vfModuleCustomization.setVfModule(vfModule);
1431 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1432 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1433 if (initialCount != null && initialCount.length() > 0) {
1434 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1437 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1438 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1440 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1441 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1442 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1443 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1446 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1447 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1449 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1450 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1451 if (maxInstances != null && maxInstances.length() > 0) {
1452 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1455 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1456 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1457 if (minInstances != null && minInstances.length() > 0) {
1458 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1460 return vfModuleCustomization;
1463 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1464 IVfModuleData vfModuleData, Metadata vfMetadata) {
1465 VfModule vfModule = new VfModule();
1466 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1468 if(vfModuleModelUUID == null) {
1469 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1470 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1471 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1472 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1475 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1476 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1477 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1478 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1479 vfModule.setModelUUID(vfModuleModelUUID);
1480 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1481 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1482 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1483 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1485 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1486 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1487 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1488 vfModule.setIsBase(true);
1490 vfModule.setIsBase(false);
1495 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
1496 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1497 Metadata vfMetadata) {
1499 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
1500 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
1501 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1502 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
1505 if (matchingObject.isPresent()) {
1506 List<HeatFiles> heatFilesList = new ArrayList<>();
1507 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
1508 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
1509 HeatTemplate parentHeatTemplate = new HeatTemplate();
1510 String parentArtifactType = null;
1511 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
1512 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1514 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
1516 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
1517 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
1518 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
1521 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
1522 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
1524 if(!childNestedHeatTemplates.isEmpty()){
1526 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
1527 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
1529 heatChildTemplates.add(childNestedHeatTemplates.get(0));
1535 if(!heatFilesList.isEmpty()){
1536 vfModule.setHeatFiles(heatFilesList);
1540 // Set all Child Templates related to HEAT_VOLUME
1541 if(!volumeHeatChildTemplates.isEmpty()){
1542 if(vfModule.getVolumeHeatTemplate() != null){
1543 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
1545 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
1549 // Set all Child Templates related to HEAT
1550 if(!heatChildTemplates.isEmpty()){
1551 if(vfModule.getModuleHeatTemplate() != null){
1552 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
1554 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
1560 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1561 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
1562 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
1563 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
1564 vfModuleArtifact.incrementDeployedInDB();
1565 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
1566 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
1567 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
1568 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1569 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
1570 vfModuleArtifact.incrementDeployedInDB();
1571 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1572 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
1573 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
1575 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
1577 vfModuleArtifact.incrementDeployedInDB();
1578 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
1579 heatFilesList.add(vfModuleArtifact.getHeatFiles());
1580 vfModuleArtifact.incrementDeployedInDB();
1581 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
1582 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
1583 vfModuleArtifact.incrementDeployedInDB();
1587 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
1588 ToscaResourceStructure toscaResourceStructure, Service service) {
1589 VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
1590 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1591 if(vnfResourceCustomization == null){
1592 VnfResource vnfResource = findExistingVnfResource(service,
1593 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1595 if(vnfResource==null)
1596 vnfResource=createVnfResource(vfNodeTemplate);
1598 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
1600 vnfResourceCustomization.setVnfResources(vnfResource);
1601 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
1603 // Fetch VNFC Instance Group Info
1604 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1605 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
1606 "org.openecomp.groups.VfcInstanceGroup");
1608 for (Group group : groupList) {
1610 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization);
1612 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1615 return vnfResourceCustomization;
1618 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1619 VnfResource vnfResource = null;
1620 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1621 if (vnfResourceCustom.getVnfResources() != null
1622 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1623 vnfResource = vnfResourceCustom.getVnfResources();
1626 if(vnfResource==null)
1627 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1632 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1633 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1634 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1635 vnfResourceCustomization.setModelCustomizationUUID(
1636 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1637 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1639 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1640 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1641 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1642 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1643 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1644 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1645 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1646 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1648 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1649 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1651 vnfResourceCustomization.setVnfResources(vnfResource);
1652 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1653 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1655 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1656 .getCapabilitiesOf(vfNodeTemplate);
1658 if (vnfCustomizationCapability != null) {
1659 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1661 if (capAssign != null) {
1662 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1663 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1664 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1665 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1670 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1672 return vnfResourceCustomization;
1675 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1676 VnfResource vnfResource = new VnfResource();
1677 vnfResource.setModelInvariantUUID(
1678 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1679 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1680 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1682 vnfResource.setModelVersion(
1683 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1684 vnfResource.setDescription(
1685 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1686 vnfResource.setOrchestrationMode(HEAT);
1687 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1688 vnfResource.setAicVersionMax(
1689 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1690 vnfResource.setAicVersionMin(
1691 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1692 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1693 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
1698 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1699 ToscaResourceStructure toscaResourceStructure, Service service) {
1700 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1701 .findOneByModelCustomizationUUID(
1702 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1704 if(allottedResourceCustomization == null){
1705 AllottedResource allottedResource = findExistingAllottedResource(service,
1706 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1708 if(allottedResource==null)
1709 allottedResource=createAR(nodeTemplate);
1711 toscaResourceStructure.setAllottedResource(allottedResource);
1712 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1713 allottedResourceCustomization.setAllottedResource(allottedResource);
1714 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1716 return allottedResourceCustomization;
1719 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1720 AllottedResource allottedResource = null;
1721 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1722 if (allottedResourceCustom.getAllottedResource() != null
1723 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1724 allottedResource = allottedResourceCustom.getAllottedResource();
1727 if(allottedResource==null)
1728 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1730 return allottedResource;
1733 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1734 ToscaResourceStructure toscaResourceStructure) {
1735 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1736 allottedResourceCustomization.setModelCustomizationUUID(
1737 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1738 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1741 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1742 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1743 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1744 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1745 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1746 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1747 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1748 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1750 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1752 if(vfcNodes != null){
1753 for(NodeTemplate vfcNode : vfcNodes){
1755 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1756 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1757 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1762 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1763 .getCapabilitiesOf(nodeTemplate);
1765 if (arCustomizationCapability != null) {
1766 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1768 if (capAssign != null) {
1769 allottedResourceCustomization.setMinInstances(
1770 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1771 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1772 allottedResourceCustomization.setMaxInstances(
1773 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1774 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1777 return allottedResourceCustomization;
1780 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1781 AllottedResource allottedResource = new AllottedResource();
1783 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1784 allottedResource.setModelInvariantUUID(
1785 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1787 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1789 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1790 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1791 allottedResource.setSubcategory(
1792 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1794 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1795 return allottedResource;
1798 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1799 // Scan the payload downloadResult and extract the HeatTemplate
1801 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1802 return yamlEditor.getParameterList(artifactUUID);
1805 protected String testNull(Object object) {
1807 if (object == null) {
1809 } else if (object.equals("NULL")) {
1811 } else if (object instanceof Integer) {
1812 return object.toString();
1813 } else if (object instanceof String) {
1814 return (String) object;
1816 return "Type not recognized";
1820 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1821 VfModuleArtifact heatNestedArtifact) {
1823 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1824 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1825 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1826 .getArtifactInfo().getRelatedArtifacts()) {
1827 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1828 return ASDCConfiguration.HEAT;
1834 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1835 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1836 .getRelatedArtifacts() != null) {
1837 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1838 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1839 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1840 return ASDCConfiguration.HEAT_VOL;
1846 // Does not belong to anything
1851 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1853 return vfResourceStructure.getNotification().getServiceName() + "/"
1854 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1857 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1859 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1860 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1864 protected static Timestamp getCurrentTimeStamp() {
1866 return new Timestamp(new Date().getTime());