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 * Modifications Copyright (c) 2019 Samsung
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.so.asdc.installer.heat;
27 import java.sql.Timestamp;
28 import java.util.ArrayList;
29 import java.util.Date;
30 import java.util.HashMap;
31 import java.util.HashSet;
32 import java.util.LinkedHashMap;
33 import java.util.List;
35 import java.util.Optional;
37 import java.util.stream.Collectors;
39 import org.hibernate.exception.ConstraintViolationException;
40 import org.hibernate.exception.LockAcquisitionException;
41 import org.onap.sdc.api.notification.IArtifactInfo;
42 import org.onap.sdc.api.notification.IResourceInstance;
43 import org.onap.sdc.api.notification.IStatusData;
44 import org.onap.sdc.tosca.parser.api.IEntityDetails;
45 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
46 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
47 import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
48 import org.onap.sdc.tosca.parser.enums.SdcTypes;
49 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
50 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
51 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
52 import org.onap.sdc.toscaparser.api.Group;
53 import org.onap.sdc.toscaparser.api.NodeTemplate;
54 import org.onap.sdc.toscaparser.api.Policy;
55 import org.onap.sdc.toscaparser.api.Property;
56 import org.onap.sdc.toscaparser.api.RequirementAssignment;
57 import org.onap.sdc.toscaparser.api.RequirementAssignments;
58 import org.onap.sdc.toscaparser.api.elements.Metadata;
59 import org.onap.sdc.toscaparser.api.elements.StatefulEntityType;
60 import org.onap.sdc.toscaparser.api.functions.GetInput;
61 import org.onap.sdc.toscaparser.api.parameters.Input;
62 import org.onap.sdc.utils.DistributionStatusEnum;
63 import org.onap.so.asdc.client.ASDCConfiguration;
64 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
65 import org.onap.so.asdc.installer.ASDCElementInfo;
66 import org.onap.so.asdc.installer.BigDecimalVersion;
67 import org.onap.so.asdc.installer.IVfModuleData;
68 import org.onap.so.asdc.installer.PnfResourceStructure;
69 import org.onap.so.asdc.installer.ResourceStructure;
70 import org.onap.so.asdc.installer.ToscaResourceStructure;
71 import org.onap.so.asdc.installer.VfModuleArtifact;
72 import org.onap.so.asdc.installer.VfModuleStructure;
73 import org.onap.so.asdc.installer.VfResourceStructure;
74 import org.onap.so.asdc.util.YamlEditor;
75 import org.onap.so.db.catalog.beans.AllottedResource;
76 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
77 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
78 import org.onap.so.db.catalog.beans.CollectionResource;
79 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
80 import org.onap.so.db.catalog.beans.ConfigurationResource;
81 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
82 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
83 import org.onap.so.db.catalog.beans.CvnfcCustomization;
84 import org.onap.so.db.catalog.beans.HeatEnvironment;
85 import org.onap.so.db.catalog.beans.HeatFiles;
86 import org.onap.so.db.catalog.beans.HeatTemplate;
87 import org.onap.so.db.catalog.beans.HeatTemplateParam;
88 import org.onap.so.db.catalog.beans.InstanceGroupType;
89 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
90 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
91 import org.onap.so.db.catalog.beans.NetworkResource;
92 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
93 import org.onap.so.db.catalog.beans.PnfResource;
94 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
95 import org.onap.so.db.catalog.beans.Service;
96 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
97 import org.onap.so.db.catalog.beans.SubType;
98 import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
99 import org.onap.so.db.catalog.beans.ToscaCsar;
100 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
101 import org.onap.so.db.catalog.beans.VfModule;
102 import org.onap.so.db.catalog.beans.VfModuleCustomization;
103 import org.onap.so.db.catalog.beans.VnfResource;
104 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
105 import org.onap.so.db.catalog.beans.VnfcCustomization;
106 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
107 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
108 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
109 import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
110 import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
111 import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
112 import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
113 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
114 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
115 import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
116 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
117 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
118 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
119 import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
120 import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
121 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
122 import org.onap.so.db.catalog.data.repository.ServiceRepository;
123 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
124 import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
125 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
126 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
127 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
128 import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
129 import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
130 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
131 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
132 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
133 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
134 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
135 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
136 import org.onap.so.logger.ErrorCode;
137 import org.onap.so.logger.MessageEnum;
138 import org.slf4j.Logger;
139 import org.slf4j.LoggerFactory;
140 import org.springframework.beans.factory.annotation.Autowired;
141 import org.springframework.orm.ObjectOptimisticLockingFailureException;
142 import org.springframework.stereotype.Component;
143 import org.springframework.transaction.annotation.Transactional;
145 import com.fasterxml.jackson.core.JsonProcessingException;
146 import com.fasterxml.jackson.databind.ObjectMapper;
149 public class ToscaResourceInstaller {
151 protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
153 protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
155 protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
157 protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
159 protected static final String SCALABLE = "scalable";
161 protected static final String BASIC = "BASIC";
163 protected static final String PROVIDER = "PROVIDER";
165 protected static final String HEAT = "HEAT";
167 protected static final String MANUAL_RECORD = "MANUAL_RECORD";
169 protected static final String MSO = "SO";
171 protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
173 protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
175 private static String CUSTOMIZATION_UUID = "customizationUUID";
179 protected ServiceRepository serviceRepo;
182 protected InstanceGroupRepository instanceGroupRepo;
185 protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
188 protected CollectionResourceRepository collectionRepo;
191 protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
194 protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
197 protected ConfigurationResourceRepository configRepo;
200 protected VnfResourceRepository vnfRepo;
203 protected VFModuleRepository vfModuleRepo;
206 protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
209 protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
212 protected VnfcCustomizationRepository vnfcCustomizationRepo;
215 protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
218 protected AllottedResourceRepository allottedRepo;
221 protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
224 protected NetworkResourceRepository networkRepo;
227 protected HeatTemplateRepository heatRepo;
230 protected NetworkResourceCustomizationRepository networkCustomizationRepo;
233 protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
235 protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
237 protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
240 protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
243 protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
246 protected PnfResourceRepository pnfResourceRepository;
249 protected PnfCustomizationRepository pnfCustomizationRepository;
251 protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
253 public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
254 boolean status = false;
255 VfResourceStructure vfResourceStructure = vfResourceStruct;
257 status = vfResourceStructure.isDeployedSuccessfully();
258 } catch (RuntimeException e) {
262 Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
263 if(existingService != null)
266 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
267 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
268 vfResourceStructure.getNotification().getServiceName(),
269 BigDecimalVersion.castAndCheckNotificationVersionToString(
270 vfResourceStructure.getNotification().getServiceVersion()),
271 vfResourceStructure.getNotification().getServiceUUID(),
272 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
273 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
274 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
275 watchdogCDStatusRepository.saveAndFlush(wdStatus);
277 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
278 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
279 vfResourceStructure.getNotification().getServiceName(),
280 BigDecimalVersion.castAndCheckNotificationVersionToString(
281 vfResourceStructure.getNotification().getServiceVersion()),
282 vfResourceStructure.getNotification().getServiceUUID(),
283 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
286 } catch (Exception e) {
288 .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
289 "Exception - isResourceAlreadyDeployed");
290 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
294 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
295 logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
296 iStatus.getDistributionID(), iStatus.getComponentName());
299 WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
300 iStatus.getComponentName());
301 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
302 watchdogCDStatusRepository.save(cdStatus);
304 } catch (Exception e) {
305 logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
306 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
310 @Transactional(rollbackFor = {ArtifactInstallerException.class})
311 public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
312 throws ArtifactInstallerException {
313 if (resourceStruct instanceof VfResourceStructure) {
314 installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
315 } else if (resourceStruct instanceof PnfResourceStructure) {
316 installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
318 logger.warn("Unrecognized resource type");
322 private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
323 throws ArtifactInstallerException {
325 // PCLO: in case of deployment failure, use a string that will represent
326 // the type of artifact that failed...
327 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
329 createToscaCsar(toscaResourceStruct);
330 Service service = createService(toscaResourceStruct, resourceStruct);
332 processResourceSequence(toscaResourceStruct, service);
333 processPnfResources(toscaResourceStruct, service, resourceStruct);
334 serviceRepo.save(service);
336 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
337 resourceStruct.getNotification().getDistributionID(), MSO);
338 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
339 watchdogCDStatusRepository.save(status);
341 toscaResourceStruct.setSuccessfulDeployment();
343 } catch (Exception e) {
344 logger.debug("Exception :", e);
345 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
346 resourceStruct.getNotification().getDistributionID(), MSO);
347 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
348 watchdogCDStatusRepository.save(status);
349 Throwable dbExceptionToCapture = e;
350 while (!(dbExceptionToCapture instanceof ConstraintViolationException
351 || dbExceptionToCapture instanceof LockAcquisitionException)
352 && (dbExceptionToCapture.getCause() != null)) {
353 dbExceptionToCapture = dbExceptionToCapture.getCause();
356 if (dbExceptionToCapture instanceof ConstraintViolationException
357 || dbExceptionToCapture instanceof LockAcquisitionException) {
358 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
359 resourceStruct.getResourceInstance().getResourceName(),
360 resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
361 "Exception - ASCDC Artifact already deployed", e);
363 String elementToLog = (!artifactListForLogging.isEmpty()
364 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
365 : "No element listed");
366 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
367 ErrorCode.DataError.getValue(),
368 "Exception caught during installation of " + resourceStruct.getResourceInstance()
370 + ". Transaction rollback", e);
371 throw new ArtifactInstallerException("Exception caught during installation of "
372 + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
376 @Transactional(rollbackFor = { ArtifactInstallerException.class })
377 public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
378 throws ArtifactInstallerException {
379 VfResourceStructure vfResourceStructure = vfResourceStruct;
380 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
382 // PCLO: in case of deployment failure, use a string that will represent
383 // the type of artifact that failed...
384 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
386 createToscaCsar(toscaResourceStruct);
387 Service service = createService(toscaResourceStruct, vfResourceStruct);
388 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
391 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
393 Metadata metadata = nodeTemplate.getMetaData();
394 String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
395 String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
396 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
397 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
398 vfCustomizationCategory);
401 processResourceSequence(toscaResourceStruct, service);
402 processVFResources(toscaResourceStruct, service, vfResourceStructure);
403 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
404 processAllottedResources(toscaResourceStruct, service, allottedResourceList);
405 processNetworks(toscaResourceStruct, service);
406 // process Network Collections
407 processNetworkCollections(toscaResourceStruct, service);
408 // Process Service Proxy & Configuration
409 processServiceProxyAndConfiguration(toscaResourceStruct, service);
411 serviceRepo.save(service);
413 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
414 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
415 watchdogCDStatusRepository.save(status);
417 toscaResourceStruct.setSuccessfulDeployment();
419 } catch (Exception e) {
420 logger.debug("Exception :", e);
421 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
422 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
423 watchdogCDStatusRepository.save(status);
424 Throwable dbExceptionToCapture = e;
425 while (!(dbExceptionToCapture instanceof ConstraintViolationException
426 || dbExceptionToCapture instanceof LockAcquisitionException)
427 && (dbExceptionToCapture.getCause() != null)) {
428 dbExceptionToCapture = dbExceptionToCapture.getCause();
431 if (dbExceptionToCapture instanceof ConstraintViolationException
432 || dbExceptionToCapture instanceof LockAcquisitionException) {
433 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
434 vfResourceStructure.getResourceInstance().getResourceName(),
435 vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
436 "Exception - ASCDC Artifact already deployed", e);
438 String elementToLog = (!artifactListForLogging.isEmpty()
439 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
440 : "No element listed");
441 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
442 ErrorCode.DataError.getValue(),
443 "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
444 + ". Transaction rollback", e);
445 throw new ArtifactInstallerException("Exception caught during installation of "
446 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
452 List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
453 ISdcCsarHelper iSdcCsarHelper) {
455 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
456 nodes.addAll(nodeTemplates);
458 for (NodeTemplate nodeTemplate : nodeTemplates) {
459 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
460 List<RequirementAssignment> reqAs = requirement.getAll();
461 for (RequirementAssignment ra : reqAs) {
462 String reqNode = ra.getNodeTemplateName();
463 for (NodeTemplate rNode : resultList) {
464 if (rNode.getName().equals(reqNode)) {
465 if(!resultList.contains(nodeTemplate)) {
466 resultList.add(nodeTemplate);
468 if(nodes.contains(nodeTemplate)) {
469 nodes.remove(nodeTemplate);
477 if (!nodes.isEmpty()) {
478 getRequirementList(resultList, nodes, iSdcCsarHelper);
484 // This method retrieve resource sequence from csar file
485 void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
486 List<String> resouceSequence = new ArrayList<String>();
487 List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
489 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
490 List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
491 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
492 nodes.addAll(nodeTemplates);
494 for (NodeTemplate nodeTemplate : nodeTemplates) {
495 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
497 if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
498 resultList.add(nodeTemplate);
499 nodes.remove(nodeTemplate);
503 resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
505 for (NodeTemplate node : resultList) {
506 String templateName = node.getMetaData().getValue("name");
507 if (!resouceSequence.contains(templateName)) {
508 resouceSequence.add(templateName);
512 String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
513 service.setResourceOrder(resourceSeqStr);
514 logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
517 private static String getValue(Object value, List<Input> servInputs) {
518 String output = null;
519 if(value instanceof Map) {
520 // currently this logic handles only one level of nesting.
521 return ((LinkedHashMap) value).values().toArray()[0].toString();
522 } else if(value instanceof GetInput) {
523 String inputName = ((GetInput)value).getInputName();
525 for(Input input : servInputs) {
526 if(input.getName().equals(inputName)) {
527 // keep both input name and default value
528 // if service input does not supplies value the use default value
529 String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
530 output = inputName + "|" + defaultValue;// return default value
535 output = value != null ? value.toString() : "";
537 return output; // return property value
540 String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException {
541 Map<String, String> resouceRequest = new HashMap<>();
542 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
544 List<Input> serInput = iSdcCsarHelper.getServiceInputs();
545 Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
546 .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
547 if(nodeTemplateOpt.isPresent()) {
548 NodeTemplate nodeTemplate = nodeTemplateOpt.get();
549 LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
551 for(String key : resourceProperties.keySet()) {
552 Property property = resourceProperties.get(key);
554 String value = getValue(property.getValue(), serInput);
555 resouceRequest.put(key, value);
560 ObjectMapper objectMapper = new ObjectMapper();
561 String jsonStr = objectMapper.writeValueAsString(resouceRequest);
563 jsonStr = jsonStr.replace("\"", "\\\"");
564 logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
566 } catch (JsonProcessingException e) {
567 logger.error("resource input could not be deserialized for resource customization id ("
568 + resourceCustomizationUuid + ")");
569 throw new ArtifactInstallerException("resource input could not be parsed", e);
573 protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
574 Service service) throws ArtifactInstallerException {
575 List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
577 if (nodeTemplatesVLList != null) {
578 for (NodeTemplate vlNode : nodeTemplatesVLList) {
579 String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
581 TempNetworkHeatTemplateLookup tempNetworkLookUp =
582 tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
584 if (tempNetworkLookUp != null) {
585 HeatTemplate heatTemplate =
586 heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
587 if (heatTemplate != null) {
588 NetworkResourceCustomization networkCustomization =
589 createNetwork (vlNode,
592 tempNetworkLookUp.getAicVersionMax (),
593 tempNetworkLookUp.getAicVersionMin (),
595 service.getNetworkCustomizations ().add (networkCustomization);
597 throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
598 + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
601 NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
607 service.getNetworkCustomizations().add (networkCustomization);
608 logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
609 + networkResourceModelName);
616 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
617 List<NodeTemplate> allottedResourceList) {
618 if (allottedResourceList != null) {
619 for (NodeTemplate allottedNode : allottedResourceList) {
620 service.getAllottedCustomizations()
621 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
627 protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
628 Metadata metadata = nodeTemplate.getMetaData();
629 ConfigurationResource configResource = new ConfigurationResource();
630 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
631 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
632 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
633 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
634 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
635 configResource.setToscaNodeType(nodeTemplate.getType());
636 return configResource;
639 protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure,
640 ServiceProxyResourceCustomization spResourceCustomization ) {
641 Metadata metadata = nodeTemplate.getMetaData();
643 ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
645 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
647 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
649 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
650 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
652 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
653 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
654 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
655 configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
657 configCustomizationResource.setConfigurationResource(configResource);
658 configResourceCustomizationSet.add(configCustomizationResource);
660 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
661 return configCustomizationResource;
665 protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(List<NodeTemplate> configurationNodeTemplatesList,
666 ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
667 Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
668 for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
669 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
670 String type = entityType.getType();
672 if(VLAN_NETWORK_RECEPTOR.equals(type)) {
673 configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate,
674 toscaResourceStructure,spResourceCustomization));
679 return configurationResourceCust;
682 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
684 List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
686 List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
688 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
689 List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
691 ServiceProxyResourceCustomization serviceProxy = null;
693 if (serviceProxyResourceList != null) {
694 for (NodeTemplate spNode : serviceProxyResourceList) {
695 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
696 serviceProxyList.add(serviceProxy);
697 Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy);
699 for (NodeTemplate configNode : configurationNodeTemplatesList) {
701 List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
702 for (RequirementAssignment requirement : requirementsList) {
703 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
704 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
706 Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
707 .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
709 if(!matchingObject.isPresent()){
710 configurationResourceList.add(configurationResource);
721 service.setConfigurationCustomizations(configurationResourceList);
722 service.setServiceProxyCustomizations(serviceProxyList);
725 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
727 List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
729 if (networkCollectionList != null) {
730 for (NodeTemplate crNode : networkCollectionList) {
732 createNetworkCollection(crNode, toscaResourceStruct, service);
733 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
735 List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
736 for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
737 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
742 service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
746 protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
748 logger.debug("processVFResources");
750 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
751 // String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
752 // String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
754 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
755 Metadata metadata = nodeTemplate.getMetaData();
756 String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
757 logger.debug("VF Category is : " + vfCustomizationCategory);
759 // Do not treat Allotted Resources as VNF resources
760 if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
764 String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
765 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
767 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
769 // Make sure the VF ResourceCustomizationUUID from the notification and tosca
770 // customizations match before comparing their VF Modules UUID's
771 logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
772 + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
773 + vfCustomizationUUID);
775 if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
776 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
777 + " matches vfNotificationResource CustomizationUUID");
779 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
780 vfCustomizationCategory);
782 logger.debug("Notification VF ResourceCustomizationUUID: "
783 + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
784 + "Tosca VF Customization UUID: " + vfCustomizationUUID);
790 * This is used to process the PNF specific resource, including resource and resource_customization. {@link
791 * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
793 protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
794 PnfResourceStructure resourceStructure) throws Exception {
795 logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
797 ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
798 EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
799 TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
801 List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
802 for (IEntityDetails entityDetails : entityDetailsList) {
803 Metadata metadata = entityDetails.getMetadata();
804 String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
805 String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
806 String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
807 if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
808 logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
809 customizationUUID, notifCustomizationUUID);
811 if (checkExistingPnfResourceCutomization(customizationUUID)) {
812 logger.info("Resource customization UUID: {} already deployed", customizationUUID);
814 PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
815 if (pnfResource == null) {
816 pnfResource = createPnfResource(entityDetails);
818 PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
820 pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
821 toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
822 service.getPnfCustomizations().add(pnfResourceCustomization);
826 .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
827 customizationUUID, notifCustomizationUUID);
832 private PnfResource findExistingPnfResource(Service service, String modelUuid) {
833 PnfResource pnfResource = null;
834 for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
835 if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
836 .getModelUUID().equals(modelUuid)) {
837 pnfResource = pnfResourceCustomization.getPnfResources();
840 if (pnfResource == null) {
841 pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
846 private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
847 return pnfCustomizationRepository.findById(customizationUUID).isPresent();
851 * Construct the {@link PnfResource} from {@link IEntityDetails} object.
853 private PnfResource createPnfResource(IEntityDetails entity) {
854 PnfResource pnfResource = new PnfResource();
855 Metadata metadata = entity.getMetadata();
856 pnfResource.setModelInvariantUUID(
857 testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
858 pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
859 pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
860 pnfResource.setModelVersion(
861 testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
862 pnfResource.setDescription(
863 testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
864 pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
865 pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
866 pnfResource.setToscaNodeType(entity.getToscaType());
871 * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
873 private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
874 PnfResource pnfResource) {
876 PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
877 Metadata metadata = entityDetails.getMetadata();
878 Map<String, Property> properties = entityDetails.getProperties();
879 pnfResourceCustomization
880 .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
881 pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
882 pnfResourceCustomization
883 .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
884 pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
885 pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
886 pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
887 pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
888 pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
889 pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
891 pnfResourceCustomization.setPnfResources(pnfResource);
893 return pnfResourceCustomization;
897 * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
899 private String getStringValue(Property property) {
900 if (null == property) {
903 Object value = property.getValue();
904 return String.valueOf(value);
907 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
908 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
910 logger.debug("VF Category is : " + vfCustomizationCategory);
912 if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
915 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
916 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
917 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
919 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
921 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
922 logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
923 " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
925 if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
927 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
929 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
931 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
932 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
934 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
936 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
937 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
938 .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
939 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
941 logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
943 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
944 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
945 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
947 if(matchingObject.isPresent()){
948 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
949 vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
950 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
952 throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
957 // Check for VNFC Instance Group info and add it if there is
958 List<Group> groupList = toscaResourceStruct.getSdcCsarHelper()
959 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate,
960 "org.openecomp.groups.VfcInstanceGroup");
962 for (Group group : groupList) {
963 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(nodeTemplate, group, vnfResource, toscaResourceStruct);
964 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
968 service.getVnfCustomizations().add(vnfResource);
970 logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
971 "Tosca VF Customization UUID: " + vfCustomizationUUID);
976 public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
978 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
979 distributionNotification, consumerId);
980 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
984 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
985 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
987 } catch(ObjectOptimisticLockingFailureException e){
988 logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
993 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
994 VfResourceStructure vfResourceStructure) {
995 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
997 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
998 case ASDCConfiguration.HEAT:
999 case ASDCConfiguration.HEAT_NESTED:
1000 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
1003 case ASDCConfiguration.HEAT_VOL:
1004 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
1006 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1007 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
1009 case ASDCConfiguration.HEAT_ENV:
1010 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
1012 case ASDCConfiguration.HEAT_ARTIFACT:
1013 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
1014 toscaResourceStruct);
1016 case ASDCConfiguration.HEAT_NET:
1017 case ASDCConfiguration.OTHER:
1018 logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
1019 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
1020 .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
1029 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
1030 VfModuleArtifact vfModuleArtifact) {
1031 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
1032 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
1033 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1034 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
1035 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1036 return moduleArtifact;
1042 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
1043 List<String> listTypes) {
1044 String newFileBody = filebody;
1045 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1047 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
1049 newFileBody = verifyTheFilePrefixInString(newFileBody,
1050 moduleArtifact.getArtifactInfo().getArtifactName());
1056 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
1058 String needlePrefix = "file:///";
1059 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
1061 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
1065 StringBuilder sb = new StringBuilder(body.length());
1067 int currentIndex = 0;
1070 while (currentIndex != -1) {
1071 startIndex = currentIndex;
1072 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
1074 if (currentIndex == -1) {
1077 // We append from the startIndex up to currentIndex (start of File
1079 sb.append(body.substring(startIndex, currentIndex));
1080 sb.append(filenameToVerify);
1082 currentIndex += prefixedFilenameToVerify.length();
1085 sb.append(body.substring(startIndex));
1087 return sb.toString();
1090 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
1091 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
1092 HeatTemplate heatTemplate = new HeatTemplate();
1093 List<String> typeList = new ArrayList<>();
1094 typeList.add(ASDCConfiguration.HEAT_NESTED);
1095 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
1097 heatTemplate.setTemplateBody(
1098 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1099 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1101 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
1102 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
1104 heatTemplate.setTimeoutMinutes(240);
1107 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1108 heatTemplate.setVersion(BigDecimalVersion
1109 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1110 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1112 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1113 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1115 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
1118 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
1119 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1120 heatTemplate.setParameters(heatParam);
1121 vfModuleArtifact.setHeatTemplate(heatTemplate);
1124 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
1125 VfModuleArtifact vfModuleArtifact) {
1126 HeatEnvironment heatEnvironment = new HeatEnvironment();
1127 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1128 List<String> typeList = new ArrayList<>();
1129 typeList.add(ASDCConfiguration.HEAT);
1130 typeList.add(ASDCConfiguration.HEAT_VOL);
1131 heatEnvironment.setEnvironment(
1132 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1133 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1134 heatEnvironment.setVersion(BigDecimalVersion
1135 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1136 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1138 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1139 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1141 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
1143 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
1146 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
1147 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
1149 HeatFiles heatFile = new HeatFiles();
1150 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1151 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1152 heatFile.setFileBody(vfModuleArtifact.getResult());
1153 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1154 heatFile.setVersion(BigDecimalVersion
1155 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1156 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1157 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1158 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1160 heatFile.setArtifactChecksum(MANUAL_RECORD);
1162 vfModuleArtifact.setHeatFiles(heatFile);
1165 protected Service createService(ToscaResourceStructure toscaResourceStructure,
1166 ResourceStructure resourceStructure) {
1168 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
1170 Service service = new Service();
1172 if (serviceMetadata != null) {
1174 if (toscaResourceStructure.getServiceVersion() != null) {
1175 service.setModelVersion(toscaResourceStructure.getServiceVersion());
1178 service.setServiceType(serviceMetadata.getValue("serviceType"));
1179 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
1180 service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1182 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1183 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1184 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1185 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
1187 if (resourceStructure != null)
1188 service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
1190 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1191 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
1195 toscaResourceStructure.setCatalogService(service);
1199 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
1201 Metadata spMetadata = nodeTemplate.getMetaData();
1203 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
1205 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
1207 spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1208 spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1209 spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1210 spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1211 spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1213 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1214 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
1215 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1217 String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
1219 Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
1221 spCustomizationResource.setSourceService(sourceService);
1222 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1223 serviceProxyCustomizationSet.add(spCustomizationResource);
1226 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
1228 return spCustomizationResource;
1231 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
1232 ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
1233 Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
1235 ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate,
1236 toscaResourceStructure,spResourceCustomization);
1238 ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
1240 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
1242 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
1243 String type = entityType.getType();
1245 if(NODES_VRF_ENTRY.equals(type)) {
1246 configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
1249 configCustomizationResource.setConfigurationResource(configResource);
1251 configResourceCustomizationSet.add(configCustomizationResource);
1253 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
1255 toscaResourceStructure.setCatalogConfigurationResource(configResource);
1257 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
1259 return configCustomizationResource;
1262 protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
1264 Metadata fabricMetadata = nodeTemplate.getMetaData();
1266 ConfigurationResource configResource = new ConfigurationResource();
1268 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1269 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1270 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1271 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1272 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1273 configResource.setToscaNodeType(nodeTemplate.getType());
1275 return configResource;
1278 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
1279 ToscaCsar toscaCsar = new ToscaCsar();
1280 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
1281 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
1283 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
1285 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
1286 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
1287 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
1288 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
1289 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
1291 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
1294 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
1295 VnfcCustomization vnfcCustomization = null;
1296 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
1297 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
1298 vnfcCustomization = vnfcCustom;
1302 if(vnfcCustomization==null)
1303 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
1304 //vnfcCustomization = new VnfcCustomization();
1306 return vnfcCustomization;
1309 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
1310 CvnfcCustomization cvnfcCustomization = null;
1311 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
1312 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
1313 cvnfcCustomization = cvnfcCustom;
1317 if(cvnfcCustomization==null)
1318 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
1320 return cvnfcCustomization;
1323 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
1324 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
1326 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1328 boolean networkUUIDsMatch = true;
1329 // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
1330 // If not we'll update the Customization record with latest from the distribution
1331 if(networkResourceCustomization != null){
1332 String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
1333 String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
1335 if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){
1336 networkUUIDsMatch = false;
1341 if (networkResourceCustomization!=null && !networkUUIDsMatch){
1343 NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
1346 networkResourceCustomization.setNetworkResource(networkResource);
1348 networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
1351 else if(networkResourceCustomization==null){
1352 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
1353 toscaResourceStructure);
1355 NetworkResource networkResource = findExistingNetworkResource(service,
1356 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1357 if(networkResource == null)
1358 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
1361 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
1362 networkResourceCustomization.setNetworkResource(networkResource);
1365 return networkResourceCustomization;
1368 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
1369 NetworkResource networkResource = null;
1370 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
1371 if (networkCustom.getNetworkResource() != null
1372 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
1373 networkResource = networkCustom.getNetworkResource();
1376 if(networkResource==null)
1377 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
1379 return networkResource;
1382 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
1383 ToscaResourceStructure toscaResourceStructure) {
1384 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
1385 networkResourceCustomization.setModelInstanceName(
1386 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1387 networkResourceCustomization.setModelCustomizationUUID(
1388 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1390 networkResourceCustomization.setNetworkTechnology(
1391 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1392 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
1393 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
1394 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
1395 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1396 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
1397 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
1398 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
1399 return networkResourceCustomization;
1402 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
1403 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
1404 NetworkResource networkResource = new NetworkResource();
1405 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1406 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1408 if ("true".equalsIgnoreCase(providerNetwork)) {
1409 networkResource.setNeutronNetworkType(PROVIDER);
1411 networkResource.setNeutronNetworkType(BASIC);
1414 networkResource.setModelName(
1415 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1417 networkResource.setModelInvariantUUID(
1418 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1419 networkResource.setModelUUID(
1420 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1421 networkResource.setModelVersion(
1422 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1424 networkResource.setAicVersionMax(aicMax);
1425 networkResource.setAicVersionMin(aicMin);
1426 networkResource.setToscaNodeType(networkNodeTemplate.getType());
1427 networkResource.setDescription(
1428 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1429 networkResource.setOrchestrationMode(HEAT);
1430 networkResource.setHeatTemplate(heatTemplate);
1431 return networkResource;
1434 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
1435 ToscaResourceStructure toscaResourceStructure, Service service) {
1437 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
1439 // **** Build Object to populate Collection_Resource table
1440 CollectionResource collectionResource = new CollectionResource();
1443 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1444 collectionResource.setModelInvariantUUID(
1445 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1447 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1449 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1451 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1452 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
1454 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
1456 // **** Build object to populate Collection_Resource_Customization table
1457 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
1459 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1461 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1463 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1466 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1467 ncfc.setModelCustomizationUUID(
1468 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1470 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
1471 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
1473 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1475 ncfc.setCollectionResource(collectionResource);
1476 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1478 //*** Build object to populate the Instance_Group table
1479 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1480 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
1481 "org.openecomp.groups.NetworkCollection");
1483 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1485 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
1487 for (Group group : groupList) {
1489 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1490 Metadata instanceMetadata = group.getMetadata();
1491 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1492 networkInstanceGroup
1493 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1494 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1495 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1496 networkInstanceGroup.setToscaNodeType(group.getType());
1497 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1499 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1501 networkInstanceGroup.setCollectionResource(collectionResource);
1503 // ****Build object to populate
1504 // Collection_Resource_Instance_Group_Customization table
1505 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1506 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1507 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1508 crInstanceGroupCustomization.setModelCustomizationUUID(
1509 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1511 // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
1512 List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
1514 if(policyList != null){
1515 for(Policy policy : policyList){
1516 for(String policyNetworkCollection : policy.getTargets()){
1518 if(policyNetworkCollection.equalsIgnoreCase(group.getName())){
1520 Map<String, Object> propMap = policy.getPolicyProperties();
1522 if(propMap.get("quantity") != null){
1524 String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString()));
1526 if(quantity != null){
1527 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
1537 crInstanceGroupCustomization.setDescription(
1538 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1539 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1540 + "_network_collection_description"));
1541 crInstanceGroupCustomization.setFunction(
1542 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1543 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1544 + "_network_collection_function"));
1545 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1546 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1548 networkInstanceGroup
1549 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1551 networkInstanceGroupList.add(networkInstanceGroup);
1554 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1556 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1557 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1559 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1561 //*****Build object to populate the NetworkResource table
1562 NetworkResource networkResource = new NetworkResource();
1564 for(NodeTemplate vlNodeTemplate : vlNodeList){
1566 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1567 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1569 if ("true".equalsIgnoreCase(providerNetwork)) {
1570 networkResource.setNeutronNetworkType(PROVIDER);
1572 networkResource.setNeutronNetworkType(BASIC);
1575 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1577 networkResource.setModelInvariantUUID(
1578 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1579 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1581 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1583 networkResource.setAicVersionMax(
1584 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1586 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1587 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1589 if (tempNetworkLookUp != null ) {
1591 HeatTemplate heatTemplate = heatRepo
1592 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1593 networkResource.setHeatTemplate(heatTemplate);
1595 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1599 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1601 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1602 networkResource.setOrchestrationMode(HEAT);
1604 // Build object to populate the
1605 // Collection_Network_Resource_Customization table
1606 for (NodeTemplate memberNode : group.getMemberNodes()) {
1607 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1610 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1611 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1613 collectionNetworkResourceCustomization.setNetworkTechnology(
1614 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1615 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1616 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1617 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1618 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1619 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1620 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1621 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1622 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1623 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1624 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1626 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1631 return collectionNetworkResourceCustomization;
1634 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1635 VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
1637 Metadata instanceMetadata = group.getMetadata();
1638 // Populate InstanceGroup
1639 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1641 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1642 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1643 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1644 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1645 vfcInstanceGroup.setToscaNodeType(group.getType());
1646 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1647 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1649 //Populate VNFCInstanceGroupCustomization
1650 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1652 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1653 vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1655 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1656 vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1658 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1660 String getInputName = null;
1661 String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function");
1662 if (groupProperty != null) {
1663 int getInputIndex = groupProperty.indexOf("{get_input=");
1664 if (getInputIndex > -1) {
1665 getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
1668 vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
1669 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1672 return vfcInstanceGroupCustom;
1676 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
1677 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1678 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
1679 Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1681 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1682 vfModuleData.getVfModuleModelCustomizationUUID());
1683 if (vfModuleCustomization == null) {
1684 VfModule vfModule = findExistingVfModule(vnfResource,
1685 vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1686 Metadata vfMetadata = group.getMetadata();
1687 if (vfModule == null)
1688 vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1690 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1691 vfModuleCustomization.setVnfCustomization(vnfResource);
1692 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1694 vfModuleCustomization.setVfModule(vfModule);
1695 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1696 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1698 vfResourceStructure.setAlreadyDeployed(true);
1701 // ******************************************************************************************************************
1702 // * Extract VFC's and CVFC's then add them to VFModule
1703 // ******************************************************************************************************************
1705 Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new HashSet<CvnfcConfigurationCustomization>();
1706 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1707 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1709 // Only set the CVNFC if this vfModule group is a member of it.
1710 List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate,
1712 String vfModuleMemberName = null;
1714 for (NodeTemplate node : groupMembers) {
1715 vfModuleMemberName = node.getName();
1718 // Extract CVFC lists
1719 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate,
1722 for (NodeTemplate cvfcTemplate : cvfcList) {
1723 boolean cvnfcVfModuleNameMatch = false;
1725 for(NodeTemplate node : groupMembers){
1726 vfModuleMemberName = node.getName();
1728 if(vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
1729 cvnfcVfModuleNameMatch = true;
1734 if(vfModuleMemberName != null && cvnfcVfModuleNameMatch){
1736 // Extract associated VFC - Should always be just one
1737 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper()
1738 .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1740 for (NodeTemplate vfcTemplate : vfcList) {
1742 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1743 VnfcCustomization existingVnfcCustomization = null;
1745 existingVnfcCustomization = findExistingVfc(existingVnfcSet,
1746 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1748 if (existingVnfcCustomization == null) {
1749 vnfcCustomization = new VnfcCustomization();
1751 vnfcCustomization = existingVnfcCustomization;
1754 // Only Add Abstract VNFC's to our DB, ignore all others
1755 if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
1756 .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
1757 vnfcCustomization.setModelCustomizationUUID(
1758 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1759 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1760 vnfcCustomization.setModelInvariantUUID(
1761 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1763 .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1765 .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1767 vnfcCustomization.setModelVersion(
1768 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1769 vnfcCustomization.setDescription(testNull(
1770 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1771 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1773 vnfcCustomizations.add(vnfcCustomization);
1774 existingVnfcSet.add(vnfcCustomization);
1777 // This check is needed incase the VFC subcategory is
1778 // something other than Abstract. In that case we want to
1779 // skip adding that record to our DB.
1780 if (vnfcCustomization.getModelCustomizationUUID() != null) {
1781 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1782 cvnfcCustomization.setModelCustomizationUUID(
1783 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1784 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1785 cvnfcCustomization.setModelInvariantUUID(
1786 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1788 .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1790 .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1792 cvnfcCustomization.setModelVersion(
1793 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1794 cvnfcCustomization.setDescription(testNull(
1795 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1796 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1798 if (existingVnfcCustomization != null) {
1799 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1801 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1804 cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
1805 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
1806 cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
1807 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
1808 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1810 cvnfcCustomizations.add(cvnfcCustomization);
1811 existingCvnfcSet.add(cvnfcCustomization);
1813 // *****************************************************************************************************************************************
1814 // * Extract Fabric Configuration
1815 // *****************************************************************************************************************************************
1817 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
1818 .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
1820 for (NodeTemplate fabricTemplate : fabricConfigList) {
1822 ConfigurationResource fabricConfig = null;
1824 ConfigurationResource existingConfig = findExistingConfiguration(service,
1825 fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1827 if (existingConfig == null) {
1829 fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1832 fabricConfig = existingConfig;
1835 CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(
1836 fabricTemplate, toscaResourceStructure, vnfResource, vfModuleCustomization,
1837 cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
1838 cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
1840 fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1842 cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1849 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1851 return vfModuleCustomization;
1854 protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1855 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1856 ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
1858 Metadata fabricMetadata = fabricTemplate.getMetaData();
1860 CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
1862 cvnfcConfigurationCustomization.setConfigurationResource(configResource);
1864 cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
1866 cvnfcConfigurationCustomization.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1867 cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
1869 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
1871 if(policyList != null){
1872 for(Policy policy : policyList){
1874 for(String policyCvfcTarget : policy.getTargets()){
1876 if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
1878 Map<String, Object> propMap = policy.getPolicyProperties();
1880 if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
1881 cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
1888 cvnfcConfigurationCustomization.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
1889 cvnfcConfigurationCustomization.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
1890 cvnfcConfigurationCustomization.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
1892 return cvnfcConfigurationCustomization;
1895 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1896 ConfigurationResource configResource = null;
1897 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1898 if (configurationResourceCustom.getConfigurationResource() != null
1899 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1900 configResource = configurationResourceCustom.getConfigurationResource();
1904 return configResource;
1907 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1908 String vfModuleModelCustomizationUUID) {
1909 VfModuleCustomization vfModuleCustomization = null;
1910 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1911 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1912 vfModuleCustomization = vfModuleCustom;
1915 return vfModuleCustomization;
1918 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1919 VfModule vfModule = null;
1920 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1921 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1922 vfModule = vfModuleCustom.getVfModule();
1926 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1931 protected VfModuleCustomization createVfModuleCustomization(Group group,
1932 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1933 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1935 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1937 vfModuleCustomization.setVfModule(vfModule);
1939 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1940 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1941 if (initialCount != null && initialCount.length() > 0) {
1942 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1945 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1946 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1948 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1949 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1950 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1951 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1954 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1955 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1957 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1958 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1959 if (maxInstances != null && maxInstances.length() > 0) {
1960 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1963 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1964 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1965 if (minInstances != null && minInstances.length() > 0) {
1966 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1968 return vfModuleCustomization;
1971 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1972 IVfModuleData vfModuleData, Metadata vfMetadata) {
1973 VfModule vfModule = new VfModule();
1974 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1976 if(vfModuleModelUUID == null) {
1977 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1978 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1979 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1980 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1983 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1984 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1985 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1986 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1987 vfModule.setModelUUID(vfModuleModelUUID);
1988 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1989 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1990 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1991 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1993 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1994 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1995 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1996 vfModule.setIsBase(true);
1998 vfModule.setIsBase(false);
2003 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
2004 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2005 Metadata vfMetadata) {
2007 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
2008 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
2009 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2010 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
2013 if (matchingObject.isPresent()) {
2014 List<HeatFiles> heatFilesList = new ArrayList<>();
2015 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
2016 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
2017 HeatTemplate parentHeatTemplate = new HeatTemplate();
2018 String parentArtifactType = null;
2019 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
2020 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
2022 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
2024 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
2025 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
2026 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
2029 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
2030 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
2032 if(!childNestedHeatTemplates.isEmpty()){
2034 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
2035 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
2037 heatChildTemplates.add(childNestedHeatTemplates.get(0));
2043 if(!heatFilesList.isEmpty()){
2044 vfModule.setHeatFiles(heatFilesList);
2048 // Set all Child Templates related to HEAT_VOLUME
2049 if(!volumeHeatChildTemplates.isEmpty()){
2050 if(vfModule.getVolumeHeatTemplate() != null){
2051 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
2053 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
2057 // Set all Child Templates related to HEAT
2058 if(!heatChildTemplates.isEmpty()){
2059 if(vfModule.getModuleHeatTemplate() != null){
2060 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
2062 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
2068 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2069 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
2070 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
2071 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
2072 vfModuleArtifact.incrementDeployedInDB();
2073 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
2074 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
2075 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
2076 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
2077 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
2078 vfModuleArtifact.incrementDeployedInDB();
2079 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
2080 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
2081 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
2083 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
2085 vfModuleArtifact.incrementDeployedInDB();
2086 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
2087 heatFilesList.add(vfModuleArtifact.getHeatFiles());
2088 vfModuleArtifact.incrementDeployedInDB();
2089 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
2090 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
2091 vfModuleArtifact.incrementDeployedInDB();
2095 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
2096 ToscaResourceStructure toscaResourceStructure, Service service) {
2097 VnfResourceCustomization vnfResourceCustomization = null;
2098 if(vnfResourceCustomization == null){
2099 VnfResource vnfResource = findExistingVnfResource(service,
2100 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2102 if(vnfResource==null)
2103 vnfResource=createVnfResource(vfNodeTemplate);
2105 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
2107 vnfResourceCustomization.setVnfResources(vnfResource);
2108 vnfResourceCustomization.setService(service);
2109 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
2112 return vnfResourceCustomization;
2115 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
2116 VnfResource vnfResource = null;
2117 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
2118 if (vnfResourceCustom.getVnfResources() != null
2119 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
2120 vnfResource = vnfResourceCustom.getVnfResources();
2123 if(vnfResource==null)
2124 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
2129 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
2130 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
2131 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
2132 vnfResourceCustomization.setModelCustomizationUUID(
2133 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2134 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
2136 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2137 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2138 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2139 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
2140 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2141 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2142 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2143 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2145 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
2146 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
2148 vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
2149 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
2151 vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
2152 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
2154 vnfResourceCustomization.setVnfResources(vnfResource);
2155 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
2156 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
2158 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
2159 .getCapabilitiesOf(vfNodeTemplate);
2161 if (vnfCustomizationCapability != null) {
2162 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
2164 if (capAssign != null) {
2165 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2166 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2167 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2168 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2173 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
2175 return vnfResourceCustomization;
2178 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
2179 VnfResource vnfResource = new VnfResource();
2180 vnfResource.setModelInvariantUUID(
2181 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2182 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2183 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2185 vnfResource.setModelVersion(
2186 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2187 vnfResource.setDescription(
2188 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
2189 vnfResource.setOrchestrationMode(HEAT);
2190 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
2191 vnfResource.setAicVersionMax(
2192 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2193 vnfResource.setAicVersionMin(
2194 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2195 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
2196 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
2201 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
2202 ToscaResourceStructure toscaResourceStructure, Service service) {
2203 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
2204 .findOneByModelCustomizationUUID(
2205 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
2207 if(allottedResourceCustomization == null){
2208 AllottedResource allottedResource = findExistingAllottedResource(service,
2209 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2211 if(allottedResource==null)
2212 allottedResource=createAR(nodeTemplate);
2214 toscaResourceStructure.setAllottedResource(allottedResource);
2215 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
2216 allottedResourceCustomization.setAllottedResource(allottedResource);
2217 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
2219 return allottedResourceCustomization;
2222 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
2223 AllottedResource allottedResource = null;
2224 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
2225 if (allottedResourceCustom.getAllottedResource() != null
2226 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
2227 allottedResource = allottedResourceCustom.getAllottedResource();
2230 if(allottedResource==null)
2231 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
2233 return allottedResource;
2236 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
2237 ToscaResourceStructure toscaResourceStructure) {
2238 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
2239 allottedResourceCustomization.setModelCustomizationUUID(
2240 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2241 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
2244 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2245 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2246 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2247 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
2248 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2249 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2250 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2251 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2253 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
2255 if(vfcNodes != null){
2256 for(NodeTemplate vfcNode : vfcNodes){
2258 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
2259 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
2260 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
2265 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
2266 .getCapabilitiesOf(nodeTemplate);
2268 if (arCustomizationCapability != null) {
2269 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
2271 if (capAssign != null) {
2272 allottedResourceCustomization.setMinInstances(
2273 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2274 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2275 allottedResourceCustomization.setMaxInstances(
2276 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2277 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2280 return allottedResourceCustomization;
2283 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
2284 AllottedResource allottedResource = new AllottedResource();
2286 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2287 allottedResource.setModelInvariantUUID(
2288 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2290 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2292 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2293 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
2294 allottedResource.setSubcategory(
2295 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
2297 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
2298 return allottedResource;
2301 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
2302 // Scan the payload downloadResult and extract the HeatTemplate
2304 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
2305 return yamlEditor.getParameterList(artifactUUID);
2308 protected String testNull(Object object) {
2310 if (object == null) {
2312 } else if (object.equals("NULL")) {
2314 } else if (object instanceof Integer) {
2315 return object.toString();
2316 } else if (object instanceof String) {
2317 return (String) object;
2319 return "Type not recognized";
2323 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
2324 VfModuleArtifact heatNestedArtifact) {
2326 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
2327 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
2328 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
2329 .getArtifactInfo().getRelatedArtifacts()) {
2330 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2331 return ASDCConfiguration.HEAT;
2337 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
2338 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
2339 .getRelatedArtifacts() != null) {
2340 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
2341 .get(0).getArtifactInfo().getRelatedArtifacts()) {
2342 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2343 return ASDCConfiguration.HEAT_VOL;
2349 // Does not belong to anything
2354 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
2356 return vfResourceStructure.getNotification().getServiceName() + "/"
2357 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
2360 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
2362 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
2363 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
2366 protected String getPropertyInput(String propertyName){
2368 String inputName = new String();
2370 if (propertyName != null) {
2371 int getInputIndex = propertyName.indexOf("{get_input=");
2372 if (getInputIndex > -1) {
2373 inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1);
2381 protected static Timestamp getCurrentTimeStamp() {
2383 return new Timestamp(new Date().getTime());