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;
38 import org.hibernate.exception.ConstraintViolationException;
39 import org.hibernate.exception.LockAcquisitionException;
40 import org.onap.sdc.api.notification.IArtifactInfo;
41 import org.onap.sdc.api.notification.IResourceInstance;
42 import org.onap.sdc.api.notification.IStatusData;
43 import org.onap.sdc.tosca.parser.api.IEntityDetails;
44 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
45 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
46 import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
47 import org.onap.sdc.tosca.parser.enums.SdcTypes;
48 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
49 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
50 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
51 import org.onap.sdc.toscaparser.api.Group;
52 import org.onap.sdc.toscaparser.api.NodeTemplate;
53 import org.onap.sdc.toscaparser.api.Policy;
54 import org.onap.sdc.toscaparser.api.Property;
55 import org.onap.sdc.toscaparser.api.RequirementAssignment;
56 import org.onap.sdc.toscaparser.api.RequirementAssignments;
57 import org.onap.sdc.toscaparser.api.elements.Metadata;
58 import org.onap.sdc.toscaparser.api.elements.StatefulEntityType;
59 import org.onap.sdc.toscaparser.api.functions.GetInput;
60 import org.onap.sdc.toscaparser.api.parameters.Input;
61 import org.onap.sdc.utils.DistributionStatusEnum;
62 import org.onap.so.asdc.client.ASDCConfiguration;
63 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
64 import org.onap.so.asdc.installer.ASDCElementInfo;
65 import org.onap.so.asdc.installer.BigDecimalVersion;
66 import org.onap.so.asdc.installer.IVfModuleData;
67 import org.onap.so.asdc.installer.PnfResourceStructure;
68 import org.onap.so.asdc.installer.ResourceStructure;
69 import org.onap.so.asdc.installer.ToscaResourceStructure;
70 import org.onap.so.asdc.installer.VfModuleArtifact;
71 import org.onap.so.asdc.installer.VfModuleStructure;
72 import org.onap.so.asdc.installer.VfResourceStructure;
73 import org.onap.so.asdc.util.YamlEditor;
74 import org.onap.so.db.catalog.beans.AllottedResource;
75 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
76 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
77 import org.onap.so.db.catalog.beans.CollectionResource;
78 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
79 import org.onap.so.db.catalog.beans.ConfigurationResource;
80 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
81 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
82 import org.onap.so.db.catalog.beans.CvnfcCustomization;
83 import org.onap.so.db.catalog.beans.HeatEnvironment;
84 import org.onap.so.db.catalog.beans.HeatFiles;
85 import org.onap.so.db.catalog.beans.HeatTemplate;
86 import org.onap.so.db.catalog.beans.HeatTemplateParam;
87 import org.onap.so.db.catalog.beans.InstanceGroupType;
88 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
89 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
90 import org.onap.so.db.catalog.beans.NetworkResource;
91 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
92 import org.onap.so.db.catalog.beans.PnfResource;
93 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
94 import org.onap.so.db.catalog.beans.Service;
95 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
96 import org.onap.so.db.catalog.beans.SubType;
97 import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
98 import org.onap.so.db.catalog.beans.ToscaCsar;
99 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
100 import org.onap.so.db.catalog.beans.VfModule;
101 import org.onap.so.db.catalog.beans.VfModuleCustomization;
102 import org.onap.so.db.catalog.beans.VnfResource;
103 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
104 import org.onap.so.db.catalog.beans.VnfcCustomization;
105 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
106 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
107 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
108 import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
109 import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
110 import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
111 import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
112 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
113 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
114 import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
115 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
116 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
117 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
118 import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
119 import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
120 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
121 import org.onap.so.db.catalog.data.repository.ServiceRepository;
122 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
123 import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
124 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
125 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
126 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
127 import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
128 import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
129 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
130 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
131 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
132 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
133 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
134 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
135 import org.onap.so.logger.ErrorCode;
136 import org.onap.so.logger.MessageEnum;
137 import org.slf4j.Logger;
138 import org.slf4j.LoggerFactory;
139 import org.springframework.beans.factory.annotation.Autowired;
140 import org.springframework.orm.ObjectOptimisticLockingFailureException;
141 import org.springframework.stereotype.Component;
142 import org.springframework.transaction.annotation.Transactional;
143 import com.fasterxml.jackson.core.JsonProcessingException;
144 import com.fasterxml.jackson.databind.ObjectMapper;
147 public class ToscaResourceInstaller {
149 protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
151 protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
153 protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
155 protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
157 protected static final String SCALABLE = "scalable";
159 protected static final String BASIC = "BASIC";
161 protected static final String PROVIDER = "PROVIDER";
163 protected static final String HEAT = "HEAT";
165 protected static final String MANUAL_RECORD = "MANUAL_RECORD";
167 protected static final String MSO = "SO";
169 protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
171 protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
173 private static String CUSTOMIZATION_UUID = "customizationUUID";
175 protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration";
178 protected ServiceRepository serviceRepo;
181 protected InstanceGroupRepository instanceGroupRepo;
184 protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
187 protected CollectionResourceRepository collectionRepo;
190 protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
193 protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
196 protected ConfigurationResourceRepository configRepo;
199 protected VnfResourceRepository vnfRepo;
202 protected VFModuleRepository vfModuleRepo;
205 protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
208 protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
211 protected VnfcCustomizationRepository vnfcCustomizationRepo;
214 protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
217 protected AllottedResourceRepository allottedRepo;
220 protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
223 protected NetworkResourceRepository networkRepo;
226 protected HeatTemplateRepository heatRepo;
229 protected NetworkResourceCustomizationRepository networkCustomizationRepo;
232 protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
234 protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
236 protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
239 protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
242 protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
245 protected PnfResourceRepository pnfResourceRepository;
248 protected PnfCustomizationRepository pnfCustomizationRepository;
250 protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
252 public boolean isResourceAlreadyDeployed(ResourceStructure vfResourceStruct, boolean serviceDeployed)
253 throws ArtifactInstallerException {
254 boolean status = false;
255 ResourceStructure vfResourceStructure = vfResourceStruct;
257 status = vfResourceStructure.isDeployedSuccessfully();
258 } catch (RuntimeException e) {
262 Service existingService =
263 serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
264 if (existingService != null && !serviceDeployed)
267 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
268 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
269 vfResourceStructure.getNotification().getServiceName(),
270 BigDecimalVersion.castAndCheckNotificationVersionToString(
271 vfResourceStructure.getNotification().getServiceVersion()),
272 vfResourceStructure.getNotification().getServiceUUID(),
273 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
274 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(
275 vfResourceStruct.getNotification().getDistributionID(), MSO);
276 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
277 watchdogCDStatusRepository.saveAndFlush(wdStatus);
279 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
280 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
281 vfResourceStructure.getNotification().getServiceName(),
282 BigDecimalVersion.castAndCheckNotificationVersionToString(
283 vfResourceStructure.getNotification().getServiceVersion()),
284 vfResourceStructure.getNotification().getServiceUUID(),
285 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
288 } catch (Exception e) {
289 logger.error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
290 "Exception - isResourceAlreadyDeployed");
291 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
295 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
296 logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
297 iStatus.getDistributionID(), iStatus.getComponentName());
300 WatchdogComponentDistributionStatus cdStatus =
301 new WatchdogComponentDistributionStatus(iStatus.getDistributionID(), iStatus.getComponentName());
302 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
303 watchdogCDStatusRepository.save(cdStatus);
305 } catch (Exception e) {
306 logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
307 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
311 @Transactional(rollbackFor = {ArtifactInstallerException.class})
312 public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
313 throws ArtifactInstallerException {
314 if (resourceStruct instanceof VfResourceStructure) {
315 installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
316 } else if (resourceStruct instanceof PnfResourceStructure) {
317 installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
319 logger.warn("Unrecognized resource type");
323 private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
324 throws ArtifactInstallerException {
326 // PCLO: in case of deployment failure, use a string that will represent
327 // the type of artifact that failed...
328 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
330 createToscaCsar(toscaResourceStruct);
331 Service service = createService(toscaResourceStruct, resourceStruct);
333 processResourceSequence(toscaResourceStruct, service);
334 processPnfResources(toscaResourceStruct, service, resourceStruct);
335 serviceRepo.save(service);
337 WatchdogComponentDistributionStatus status =
338 new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
339 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
340 watchdogCDStatusRepository.save(status);
342 toscaResourceStruct.setSuccessfulDeployment();
344 } catch (Exception e) {
345 logger.debug("Exception :", e);
346 WatchdogComponentDistributionStatus status =
347 new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
348 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
349 watchdogCDStatusRepository.save(status);
350 Throwable dbExceptionToCapture = e;
351 while (!(dbExceptionToCapture instanceof ConstraintViolationException
352 || dbExceptionToCapture instanceof LockAcquisitionException)
353 && (dbExceptionToCapture.getCause() != null)) {
354 dbExceptionToCapture = dbExceptionToCapture.getCause();
357 if (dbExceptionToCapture instanceof ConstraintViolationException
358 || dbExceptionToCapture instanceof LockAcquisitionException) {
359 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
360 resourceStruct.getResourceInstance().getResourceName(),
361 resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
362 "Exception - ASCDC Artifact already deployed", e);
364 String elementToLog = (!artifactListForLogging.isEmpty()
365 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
366 : "No element listed");
367 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
368 ErrorCode.DataError.getValue(), "Exception caught during installation of "
369 + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback",
371 throw new ArtifactInstallerException(
372 "Exception caught during installation of "
373 + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.",
379 @Transactional(rollbackFor = {ArtifactInstallerException.class})
380 public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
381 throws ArtifactInstallerException {
382 VfResourceStructure vfResourceStructure = vfResourceStruct;
383 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
385 // PCLO: in case of deployment failure, use a string that will represent
386 // the type of artifact that failed...
387 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
389 createToscaCsar(toscaResourceStruct);
390 createService(toscaResourceStruct, vfResourceStruct);
391 Service service = toscaResourceStruct.getCatalogService();
392 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
394 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
395 Metadata metadata = nodeTemplate.getMetaData();
396 String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
397 String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
398 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
399 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
400 vfCustomizationCategory);
403 processResourceSequence(toscaResourceStruct, service);
404 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
405 processAllottedResources(toscaResourceStruct, service, allottedResourceList);
406 processNetworks(toscaResourceStruct, service);
407 // process Network Collections
408 processNetworkCollections(toscaResourceStruct, service);
409 // Process Service Proxy & Configuration
410 processServiceProxyAndConfiguration(toscaResourceStruct, service);
411 logger.info("Saving Service: {} ", service.getModelName());
412 serviceRepo.save(service);
414 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
415 vfResourceStruct.getNotification().getDistributionID(), MSO);
416 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
417 watchdogCDStatusRepository.save(status);
419 toscaResourceStruct.setSuccessfulDeployment();
421 } catch (Exception e) {
422 logger.debug("Exception :", e);
423 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
424 vfResourceStruct.getNotification().getDistributionID(), MSO);
425 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
426 watchdogCDStatusRepository.save(status);
427 Throwable dbExceptionToCapture = e;
428 while (!(dbExceptionToCapture instanceof ConstraintViolationException
429 || dbExceptionToCapture instanceof LockAcquisitionException)
430 && (dbExceptionToCapture.getCause() != null)) {
431 dbExceptionToCapture = dbExceptionToCapture.getCause();
434 if (dbExceptionToCapture instanceof ConstraintViolationException
435 || dbExceptionToCapture instanceof LockAcquisitionException) {
436 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
437 vfResourceStructure.getResourceInstance().getResourceName(),
438 vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
439 "Exception - ASCDC Artifact already deployed", e);
441 String elementToLog = (!artifactListForLogging.isEmpty()
442 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
443 : "No element listed");
444 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
445 ErrorCode.DataError.getValue(),
446 "Exception caught during installation of "
447 + vfResourceStructure.getResourceInstance().getResourceName()
448 + ". Transaction rollback",
450 throw new ArtifactInstallerException("Exception caught during installation of "
451 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
457 List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
458 ISdcCsarHelper iSdcCsarHelper) {
460 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
461 nodes.addAll(nodeTemplates);
463 for (NodeTemplate nodeTemplate : nodeTemplates) {
464 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
465 List<RequirementAssignment> reqAs = requirement.getAll();
466 for (RequirementAssignment ra : reqAs) {
467 String reqNode = ra.getNodeTemplateName();
468 for (NodeTemplate rNode : resultList) {
469 if (rNode.getName().equals(reqNode)) {
470 if (!resultList.contains(nodeTemplate)) {
471 resultList.add(nodeTemplate);
473 if (nodes.contains(nodeTemplate)) {
474 nodes.remove(nodeTemplate);
482 if (!nodes.isEmpty()) {
483 getRequirementList(resultList, nodes, iSdcCsarHelper);
489 // This method retrieve resource sequence from csar file
490 void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
491 List<String> resouceSequence = new ArrayList<String>();
492 List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
494 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
495 List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
496 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
497 nodes.addAll(nodeTemplates);
499 for (NodeTemplate nodeTemplate : nodeTemplates) {
500 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
502 if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
503 resultList.add(nodeTemplate);
504 nodes.remove(nodeTemplate);
508 resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
510 for (NodeTemplate node : resultList) {
511 String templateName = node.getMetaData().getValue("name");
512 if (!resouceSequence.contains(templateName)) {
513 resouceSequence.add(templateName);
517 String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
518 service.setResourceOrder(resourceSeqStr);
519 logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
522 private static String getValue(Object value, List<Input> servInputs) {
523 String output = null;
524 if (value instanceof Map) {
525 // currently this logic handles only one level of nesting.
526 return ((LinkedHashMap) value).values().toArray()[0].toString();
527 } else if (value instanceof GetInput) {
528 String inputName = ((GetInput) value).getInputName();
530 for (Input input : servInputs) {
531 if (input.getName().equals(inputName)) {
532 // keep both input name and default value
533 // if service input does not supplies value the use default value
534 String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
535 output = inputName + "|" + defaultValue;// return default value
540 output = value != null ? value.toString() : "";
542 return output; // return property value
545 String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
546 throws ArtifactInstallerException {
547 Map<String, String> resouceRequest = new HashMap<>();
548 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
550 List<Input> serInput = iSdcCsarHelper.getServiceInputs();
551 Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
552 .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid))
554 if (nodeTemplateOpt.isPresent()) {
555 NodeTemplate nodeTemplate = nodeTemplateOpt.get();
556 LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
558 for (String key : resourceProperties.keySet()) {
559 Property property = resourceProperties.get(key);
561 String value = getValue(property.getValue(), serInput);
562 resouceRequest.put(key, value);
567 ObjectMapper objectMapper = new ObjectMapper();
568 String jsonStr = objectMapper.writeValueAsString(resouceRequest);
570 jsonStr = jsonStr.replace("\"", "\\\"");
572 "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
574 } catch (JsonProcessingException e) {
575 logger.error("resource input could not be deserialized for resource customization id ("
576 + resourceCustomizationUuid + ")");
577 throw new ArtifactInstallerException("resource input could not be parsed", e);
581 protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
582 throws ArtifactInstallerException {
583 List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
585 if (nodeTemplatesVLList != null) {
586 for (NodeTemplate vlNode : nodeTemplatesVLList) {
587 String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
589 TempNetworkHeatTemplateLookup tempNetworkLookUp =
590 tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
592 if (tempNetworkLookUp != null) {
593 HeatTemplate heatTemplate =
594 heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
595 if (heatTemplate != null) {
596 NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct,
597 heatTemplate, tempNetworkLookUp.getAicVersionMax(),
598 tempNetworkLookUp.getAicVersionMin(), service);
599 service.getNetworkCustomizations().add(networkCustomization);
601 throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
602 + tempNetworkLookUp.getHeatTemplateArtifactUuid());
605 NetworkResourceCustomization networkCustomization =
606 createNetwork(vlNode, toscaResourceStruct, null, null, null, service);
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,
640 ToscaResourceStructure toscaResourceStructure, 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
650 .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
651 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
653 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper()
654 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
655 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper()
656 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
657 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper()
658 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
659 configCustomizationResource
660 .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
662 configCustomizationResource.setConfigurationResource(configResource);
663 configResourceCustomizationSet.add(configCustomizationResource);
665 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
666 return configCustomizationResource;
670 protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(
671 List<NodeTemplate> configurationNodeTemplatesList, ToscaResourceStructure toscaResourceStructure,
672 ServiceProxyResourceCustomization spResourceCustomization) {
673 Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
674 for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
675 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
676 String type = entityType.getType();
678 if (VLAN_NETWORK_RECEPTOR.equals(type)) {
679 configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate,
680 toscaResourceStructure, spResourceCustomization));
685 return configurationResourceCust;
688 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
690 List<NodeTemplate> serviceProxyResourceList =
691 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
693 List<NodeTemplate> configurationNodeTemplatesList =
694 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
696 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
697 List<ConfigurationResourceCustomization> configurationResourceList =
698 new ArrayList<ConfigurationResourceCustomization>();
700 ServiceProxyResourceCustomization serviceProxy = null;
702 if (serviceProxyResourceList != null) {
703 for (NodeTemplate spNode : serviceProxyResourceList) {
704 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
705 serviceProxyList.add(serviceProxy);
706 Optional<ConfigurationResourceCustomization> vnrResourceCustomization =
707 getVnrNodeTemplate(configurationNodeTemplatesList, toscaResourceStruct, serviceProxy);
709 for (NodeTemplate configNode : configurationNodeTemplatesList) {
711 List<RequirementAssignment> requirementsList =
712 toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
713 for (RequirementAssignment requirement : requirementsList) {
714 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
715 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
716 toscaResourceStruct, serviceProxy, vnrResourceCustomization);
718 Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList
720 .filter(configurationResourceCustomization -> configNode.getMetaData()
721 .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
722 .equals(configurationResource.getModelCustomizationUUID()))
724 if (!matchingObject.isPresent()) {
725 configurationResourceList.add(configurationResource);
736 service.setConfigurationCustomizations(configurationResourceList);
737 service.setServiceProxyCustomizations(serviceProxyList);
740 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
742 List<NodeTemplate> networkCollectionList =
743 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
745 if (networkCollectionList != null) {
746 for (NodeTemplate crNode : networkCollectionList) {
748 createNetworkCollection(crNode, toscaResourceStruct, service);
749 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
751 List<NetworkInstanceGroup> networkInstanceGroupList =
752 toscaResourceStruct.getCatalogNetworkInstanceGroup();
753 for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
754 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
759 service.getCollectionResourceCustomizations()
760 .add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
766 * This is used to process the PNF specific resource, including resource and resource_customization.
767 * {@link IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for
770 protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
771 PnfResourceStructure resourceStructure) throws Exception {
772 logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
774 ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
775 EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
776 TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
778 List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
779 for (IEntityDetails entityDetails : entityDetailsList) {
780 Metadata metadata = entityDetails.getMetadata();
781 String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
782 String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
783 String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
784 if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
785 logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
786 customizationUUID, notifCustomizationUUID);
788 if (checkExistingPnfResourceCutomization(customizationUUID)) {
789 logger.info("Resource customization UUID: {} already deployed", customizationUUID);
791 PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
792 if (pnfResource == null) {
793 pnfResource = createPnfResource(entityDetails);
795 PnfResourceCustomization pnfResourceCustomization =
796 createPnfResourceCustomization(entityDetails, pnfResource);
797 pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
798 toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
799 service.getPnfCustomizations().add(pnfResourceCustomization);
803 "Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
804 customizationUUID, notifCustomizationUUID);
809 private PnfResource findExistingPnfResource(Service service, String modelUuid) {
810 PnfResource pnfResource = null;
811 for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
812 if (pnfResourceCustomization.getPnfResources() != null
813 && pnfResourceCustomization.getPnfResources().getModelUUID().equals(modelUuid)) {
814 pnfResource = pnfResourceCustomization.getPnfResources();
817 if (pnfResource == null) {
818 pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
823 private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
824 return pnfCustomizationRepository.findById(customizationUUID).isPresent();
828 * Construct the {@link PnfResource} from {@link IEntityDetails} object.
830 private PnfResource createPnfResource(IEntityDetails entity) {
831 PnfResource pnfResource = new PnfResource();
832 Metadata metadata = entity.getMetadata();
833 pnfResource.setModelInvariantUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
834 pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
835 pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
836 pnfResource.setModelVersion(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
837 pnfResource.setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
838 pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
839 pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
840 pnfResource.setToscaNodeType(entity.getToscaType());
845 * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
847 private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
848 PnfResource pnfResource) {
850 PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
851 Metadata metadata = entityDetails.getMetadata();
852 Map<String, Property> properties = entityDetails.getProperties();
853 pnfResourceCustomization.setModelCustomizationUUID(
854 testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
855 pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
856 pnfResourceCustomization
857 .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
858 pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
859 pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
860 pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
861 pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
862 pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
863 pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
864 pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
865 pnfResourceCustomization.setPnfResources(pnfResource);
867 return pnfResourceCustomization;
871 * Get value from {@link Property} and cast to boolean value. Return true if property is null.
873 private boolean getBooleanValue(Property property) {
874 if (null == property) {
877 Object value = property.getValue();
878 return new Boolean(String.valueOf(value));
882 * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
884 private String getStringValue(Property property) {
885 if (null == property) {
888 Object value = property.getValue();
889 return String.valueOf(value);
892 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
893 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
896 logger.debug("VF Category is : " + vfCustomizationCategory);
898 if (vfResourceStructure.getVfModuleStructure() != null
899 && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
901 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata,
902 SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
903 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
905 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
907 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
908 // comparing their VF Modules UUID's
909 logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
910 + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
911 + vfCustomizationUUID);
913 if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
915 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
916 + " matches vfNotificationResource CustomizationUUID");
918 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
920 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
921 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
923 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
925 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
926 List<org.onap.sdc.toscaparser.api.Group> vfGroups =
927 toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
928 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
930 logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : "
931 + vfMetadata.getVfModuleModelCustomizationUUID());
933 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
934 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID "
935 + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
936 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
937 .equals(vfMetadata.getVfModuleModelCustomizationUUID()))
939 if (matchingObject.isPresent()) {
940 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
941 nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource,
942 service, existingCvnfcSet, existingVnfcSet);
943 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
946 "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: "
947 + vfMetadata.getVfModuleModelCustomizationUUID());
952 // Check for VNFC Instance Group info and add it if there is
953 List<Group> groupList =
954 toscaResourceStruct.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
955 nodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
957 for (Group group : groupList) {
958 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
959 createVNFCInstanceGroup(nodeTemplate, group, vnfResource, toscaResourceStruct);
960 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
964 service.getVnfCustomizations().add(vnfResource);
966 logger.debug("Notification VF ResourceCustomizationUUID: "
967 + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
968 + "Tosca VF Customization UUID: " + vfCustomizationUUID);
973 public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
975 WatchdogServiceModVerIdLookup modVerIdLookup =
976 new WatchdogServiceModVerIdLookup(distributionId, servideUUID, distributionNotification, consumerId);
977 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
981 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
982 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
984 } catch (ObjectOptimisticLockingFailureException e) {
985 logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
990 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
991 VfResourceStructure vfResourceStructure) {
992 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
994 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
995 case ASDCConfiguration.HEAT:
996 case ASDCConfiguration.HEAT_NESTED:
997 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
999 case ASDCConfiguration.HEAT_VOL:
1000 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
1001 VfModuleArtifact envModuleArtifact =
1002 getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1003 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
1005 case ASDCConfiguration.HEAT_ENV:
1006 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
1008 case ASDCConfiguration.HEAT_ARTIFACT:
1009 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct);
1011 case ASDCConfiguration.HEAT_NET:
1012 case ASDCConfiguration.OTHER:
1013 logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
1014 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
1015 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
1016 ErrorCode.DataError.getValue(), "Artifact type not supported");
1025 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
1026 VfModuleArtifact vfModuleArtifact) {
1027 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
1028 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
1029 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1030 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
1031 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1032 return moduleArtifact;
1038 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
1039 List<String> listTypes) {
1040 String newFileBody = filebody;
1041 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1043 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
1046 verifyTheFilePrefixInString(newFileBody, moduleArtifact.getArtifactInfo().getArtifactName());
1052 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
1054 String needlePrefix = "file:///";
1055 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
1057 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
1061 StringBuilder sb = new StringBuilder(body.length());
1063 int currentIndex = 0;
1066 while (currentIndex != -1) {
1067 startIndex = currentIndex;
1068 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
1070 if (currentIndex == -1) {
1073 // We append from the startIndex up to currentIndex (start of File
1075 sb.append(body.substring(startIndex, currentIndex));
1076 sb.append(filenameToVerify);
1078 currentIndex += prefixedFilenameToVerify.length();
1081 sb.append(body.substring(startIndex));
1083 return sb.toString();
1086 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
1087 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
1088 HeatTemplate heatTemplate = new HeatTemplate();
1089 List<String> typeList = new ArrayList<>();
1090 typeList.add(ASDCConfiguration.HEAT_NESTED);
1091 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
1093 heatTemplate.setTemplateBody(
1094 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1095 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1097 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
1098 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
1100 heatTemplate.setTimeoutMinutes(240);
1103 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1104 heatTemplate.setVersion(BigDecimalVersion
1105 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1106 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1108 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1109 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1111 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
1114 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(vfModuleArtifact.getResult(),
1115 vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1116 heatTemplate.setParameters(heatParam);
1117 vfModuleArtifact.setHeatTemplate(heatTemplate);
1120 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
1121 VfModuleArtifact vfModuleArtifact) {
1122 HeatEnvironment heatEnvironment = new HeatEnvironment();
1123 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1124 List<String> typeList = new ArrayList<>();
1125 typeList.add(ASDCConfiguration.HEAT);
1126 typeList.add(ASDCConfiguration.HEAT_VOL);
1127 heatEnvironment.setEnvironment(
1128 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1129 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1130 heatEnvironment.setVersion(BigDecimalVersion
1131 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1132 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1134 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1135 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1137 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
1139 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
1142 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
1143 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
1145 HeatFiles heatFile = new HeatFiles();
1146 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1147 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1148 heatFile.setFileBody(vfModuleArtifact.getResult());
1149 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1150 heatFile.setVersion(BigDecimalVersion
1151 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1152 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1153 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1154 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1156 heatFile.setArtifactChecksum(MANUAL_RECORD);
1158 vfModuleArtifact.setHeatFiles(heatFile);
1161 protected Service createService(ToscaResourceStructure toscaResourceStructure,
1162 ResourceStructure resourceStructure) {
1164 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
1166 Service service = new Service();
1168 if (serviceMetadata != null) {
1170 if (toscaResourceStructure.getServiceVersion() != null) {
1171 service.setModelVersion(toscaResourceStructure.getServiceVersion());
1174 service.setServiceType(serviceMetadata.getValue("serviceType"));
1175 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
1176 service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1178 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1179 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1180 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1181 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
1183 if (resourceStructure != null)
1184 service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
1186 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1187 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
1191 toscaResourceStructure.setCatalogService(service);
1195 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
1196 ToscaResourceStructure toscaResourceStructure) {
1198 Metadata spMetadata = nodeTemplate.getMetaData();
1200 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
1202 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
1204 spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1205 spCustomizationResource
1206 .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1207 spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1208 spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1209 spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1211 spCustomizationResource
1212 .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1213 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
1214 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1216 String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
1218 Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
1220 spCustomizationResource.setSourceService(sourceService);
1221 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1222 serviceProxyCustomizationSet.add(spCustomizationResource);
1225 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
1227 return spCustomizationResource;
1230 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
1231 ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
1232 Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
1234 ConfigurationResourceCustomization configCustomizationResource =
1235 getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure, spResourceCustomization);
1237 ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
1239 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
1241 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
1242 String type = entityType.getType();
1244 if (NODES_VRF_ENTRY.equals(type)) {
1245 configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
1248 configCustomizationResource.setConfigurationResource(configResource);
1250 configResourceCustomizationSet.add(configCustomizationResource);
1252 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
1254 toscaResourceStructure.setCatalogConfigurationResource(configResource);
1256 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
1258 return configCustomizationResource;
1261 protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate,
1262 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,
1310 String customizationUUID) {
1311 CvnfcCustomization cvnfcCustomization = null;
1312 for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) {
1313 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
1314 cvnfcCustomization = cvnfcCustom;
1318 if (cvnfcCustomization == null)
1319 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
1321 return cvnfcCustomization;
1324 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
1325 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
1328 NetworkResourceCustomization networkResourceCustomization =
1329 networkCustomizationRepo.findOneByModelCustomizationUUID(
1330 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1332 boolean networkUUIDsMatch = true;
1333 // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from
1334 // the distribution.
1335 // If not we'll update the Customization record with latest from the distribution
1336 if (networkResourceCustomization != null) {
1337 String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
1338 String latestNetworkModelUUID =
1339 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
1341 if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
1342 networkUUIDsMatch = false;
1347 if (networkResourceCustomization != null && !networkUUIDsMatch) {
1349 NetworkResource networkResource =
1350 createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, aicMax, aicMin);
1352 networkResourceCustomization.setNetworkResource(networkResource);
1354 networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
1356 } else if (networkResourceCustomization == null) {
1357 networkResourceCustomization =
1358 createNetworkResourceCustomization(networkNodeTemplate, toscaResourceStructure);
1360 NetworkResource networkResource = findExistingNetworkResource(service,
1361 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1362 if (networkResource == null)
1363 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
1366 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
1367 networkResourceCustomization.setNetworkResource(networkResource);
1370 return networkResourceCustomization;
1373 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
1374 NetworkResource networkResource = null;
1375 for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) {
1376 if (networkCustom.getNetworkResource() != null
1377 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
1378 networkResource = networkCustom.getNetworkResource();
1381 if (networkResource == null)
1382 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
1384 return networkResource;
1387 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
1388 ToscaResourceStructure toscaResourceStructure) {
1389 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
1390 networkResourceCustomization.setModelInstanceName(
1391 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1392 networkResourceCustomization.setModelCustomizationUUID(
1393 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1395 networkResourceCustomization.setNetworkTechnology(
1396 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1397 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
1398 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
1399 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
1400 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1401 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
1402 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
1403 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
1404 return networkResourceCustomization;
1407 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
1408 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
1409 NetworkResource networkResource = new NetworkResource();
1410 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1411 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1413 if ("true".equalsIgnoreCase(providerNetwork)) {
1414 networkResource.setNeutronNetworkType(PROVIDER);
1416 networkResource.setNeutronNetworkType(BASIC);
1419 networkResource.setModelName(
1420 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1422 networkResource.setModelInvariantUUID(
1423 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1424 networkResource.setModelUUID(
1425 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1426 networkResource.setModelVersion(
1427 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1429 networkResource.setAicVersionMax(aicMax);
1430 networkResource.setAicVersionMin(aicMin);
1431 networkResource.setToscaNodeType(networkNodeTemplate.getType());
1432 networkResource.setDescription(
1433 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1434 networkResource.setOrchestrationMode(HEAT);
1435 networkResource.setHeatTemplate(heatTemplate);
1436 return networkResource;
1439 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
1440 ToscaResourceStructure toscaResourceStructure, Service service) {
1442 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization =
1443 new CollectionNetworkResourceCustomization();
1445 // **** Build Object to populate Collection_Resource table
1446 CollectionResource collectionResource = new CollectionResource();
1449 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1450 collectionResource.setModelInvariantUUID(
1451 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1453 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1455 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1457 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1458 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
1460 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
1462 // **** Build object to populate Collection_Resource_Customization table
1463 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
1465 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1467 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1469 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1472 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1473 ncfc.setModelCustomizationUUID(
1474 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1476 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
1477 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
1479 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1481 ncfc.setCollectionResource(collectionResource);
1482 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1484 // *** Build object to populate the Instance_Group table
1485 List<Group> groupList =
1486 toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
1487 networkNodeTemplate, "org.openecomp.groups.NetworkCollection");
1489 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1491 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList =
1492 new ArrayList<CollectionResourceInstanceGroupCustomization>();
1494 for (Group group : groupList) {
1496 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1497 Metadata instanceMetadata = group.getMetadata();
1498 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1499 networkInstanceGroup
1500 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1501 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1502 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1503 networkInstanceGroup.setToscaNodeType(group.getType());
1504 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1506 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1508 networkInstanceGroup.setCollectionResource(collectionResource);
1510 // ****Build object to populate
1511 // Collection_Resource_Instance_Group_Customization table
1512 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization =
1513 new CollectionResourceInstanceGroupCustomization();
1514 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1515 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1516 crInstanceGroupCustomization.setModelCustomizationUUID(
1517 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1519 // Loop through the template policy to find the subinterface_network_quantity property name. Then extract
1520 // the value for it.
1521 List<Policy> policyList =
1522 toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(
1523 networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
1525 if (policyList != null) {
1526 for (Policy policy : policyList) {
1527 for (String policyNetworkCollection : policy.getTargets()) {
1529 if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
1531 Map<String, Object> propMap = policy.getPolicyProperties();
1533 if (propMap.get("quantity") != null) {
1535 String quantity = toscaResourceStructure.getSdcCsarHelper()
1536 .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1537 getPropertyInput(propMap.get("quantity").toString()));
1539 if (quantity != null) {
1540 crInstanceGroupCustomization
1541 .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
1551 crInstanceGroupCustomization.setDescription(
1552 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1553 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1554 + "_network_collection_description"));
1555 crInstanceGroupCustomization.setFunction(
1556 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1557 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1558 + "_network_collection_function"));
1559 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1560 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1562 networkInstanceGroup
1563 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1565 networkInstanceGroupList.add(networkInstanceGroup);
1568 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1570 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1571 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1573 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1575 // *****Build object to populate the NetworkResource table
1576 NetworkResource networkResource = new NetworkResource();
1578 for (NodeTemplate vlNodeTemplate : vlNodeList) {
1580 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1581 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1583 if ("true".equalsIgnoreCase(providerNetwork)) {
1584 networkResource.setNeutronNetworkType(PROVIDER);
1586 networkResource.setNeutronNetworkType(BASIC);
1590 .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1592 networkResource.setModelInvariantUUID(
1593 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1595 .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1597 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1599 networkResource.setAicVersionMax(
1600 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1602 TempNetworkHeatTemplateLookup tempNetworkLookUp =
1603 tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1604 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1606 if (tempNetworkLookUp != null) {
1608 HeatTemplate heatTemplate =
1609 heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1610 networkResource.setHeatTemplate(heatTemplate);
1612 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1616 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1617 networkResource.setDescription(
1618 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1619 networkResource.setOrchestrationMode(HEAT);
1621 // Build object to populate the
1622 // Collection_Network_Resource_Customization table
1623 for (NodeTemplate memberNode : group.getMemberNodes()) {
1624 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1627 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1628 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1630 collectionNetworkResourceCustomization.setNetworkTechnology(
1631 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1632 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1633 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1634 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1635 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1636 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1637 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1638 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1639 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1640 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1641 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1643 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1648 return collectionNetworkResourceCustomization;
1651 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1652 VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
1654 Metadata instanceMetadata = group.getMetadata();
1655 // Populate InstanceGroup
1656 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1658 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1659 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1660 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1661 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1662 vfcInstanceGroup.setToscaNodeType(group.getType());
1663 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1664 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1666 // Populate VNFCInstanceGroupCustomization
1667 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1669 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1670 vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1672 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1673 vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1675 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1677 String getInputName = null;
1678 String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1679 "vfc_instance_group_function");
1680 if (groupProperty != null) {
1681 int getInputIndex = groupProperty.indexOf("{get_input=");
1682 if (getInputIndex > -1) {
1683 getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1);
1686 vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper()
1687 .getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
1688 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1691 return vfcInstanceGroupCustom;
1695 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
1696 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1697 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
1698 Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1700 VfModuleCustomization vfModuleCustomization =
1701 findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
1702 if (vfModuleCustomization == null) {
1703 VfModule vfModule = findExistingVfModule(vnfResource,
1704 vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1705 Metadata vfMetadata = group.getMetadata();
1706 if (vfModule == null)
1707 vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1709 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1710 vfModuleCustomization.setVnfCustomization(vnfResource);
1711 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1713 vfModuleCustomization.setVfModule(vfModule);
1714 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1715 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1717 vfResourceStructure.setAlreadyDeployed(true);
1720 // ******************************************************************************************************************
1721 // * Extract VFC's and CVFC's then add them to VFModule
1722 // ******************************************************************************************************************
1724 Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations =
1725 new HashSet<CvnfcConfigurationCustomization>();
1726 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1727 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1729 // Only set the CVNFC if this vfModule group is a member of it.
1730 List<NodeTemplate> groupMembers =
1731 toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
1732 String vfModuleMemberName = null;
1734 for (NodeTemplate node : groupMembers) {
1735 vfModuleMemberName = node.getName();
1738 // Extract CVFC lists
1739 List<NodeTemplate> cvfcList =
1740 toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
1742 for (NodeTemplate cvfcTemplate : cvfcList) {
1743 boolean cvnfcVfModuleNameMatch = false;
1745 for (NodeTemplate node : groupMembers) {
1746 vfModuleMemberName = node.getName();
1748 if (vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) {
1749 cvnfcVfModuleNameMatch = true;
1754 if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
1756 // Extract associated VFC - Should always be just one
1757 List<NodeTemplate> vfcList =
1758 toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1760 for (NodeTemplate vfcTemplate : vfcList) {
1762 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1763 VnfcCustomization existingVnfcCustomization = null;
1765 existingVnfcCustomization = findExistingVfc(existingVnfcSet,
1766 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1768 if (existingVnfcCustomization == null) {
1769 vnfcCustomization = new VnfcCustomization();
1771 vnfcCustomization = existingVnfcCustomization;
1774 // Only Add Abstract VNFC's to our DB, ignore all others
1775 if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
1776 .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
1777 vnfcCustomization.setModelCustomizationUUID(
1778 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1779 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1780 vnfcCustomization.setModelInvariantUUID(
1781 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1783 .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1785 .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1787 vnfcCustomization.setModelVersion(
1788 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1789 vnfcCustomization.setDescription(testNull(
1790 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1791 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1793 vnfcCustomizations.add(vnfcCustomization);
1794 existingVnfcSet.add(vnfcCustomization);
1797 // This check is needed incase the VFC subcategory is
1798 // something other than Abstract. In that case we want to
1799 // skip adding that record to our DB.
1800 if (vnfcCustomization.getModelCustomizationUUID() != null) {
1801 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1802 cvnfcCustomization.setModelCustomizationUUID(
1803 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1804 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1805 cvnfcCustomization.setModelInvariantUUID(
1806 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1808 .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1810 .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1812 cvnfcCustomization.setModelVersion(
1813 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1814 cvnfcCustomization.setDescription(testNull(
1815 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1816 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1818 if (existingVnfcCustomization != null) {
1819 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1821 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1824 cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
1825 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
1826 cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
1827 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
1828 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1830 cvnfcCustomizations.add(cvnfcCustomization);
1831 existingCvnfcSet.add(cvnfcCustomization);
1833 // *****************************************************************************************************************************************
1834 // * Extract Fabric Configuration
1835 // *****************************************************************************************************************************************
1837 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
1838 .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
1840 for (NodeTemplate fabricTemplate : fabricConfigList) {
1842 ConfigurationResource fabricConfig = null;
1844 ConfigurationResource existingConfig = findExistingConfiguration(service,
1845 fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1847 if (existingConfig == null) {
1849 fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1852 fabricConfig = existingConfig;
1855 CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
1856 createCvnfcConfigurationCustomization(fabricTemplate, toscaResourceStructure,
1857 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig,
1858 vfTemplate, vfModuleMemberName);
1859 cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
1861 fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1863 cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1870 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1872 return vfModuleCustomization;
1875 protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate,
1876 ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource,
1877 VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1878 ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
1880 Metadata fabricMetadata = fabricTemplate.getMetaData();
1882 CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
1884 cvnfcConfigurationCustomization.setConfigurationResource(configResource);
1886 cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
1888 cvnfcConfigurationCustomization
1889 .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1890 cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
1892 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper()
1893 .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
1895 if (policyList != null) {
1896 for (Policy policy : policyList) {
1898 for (String policyCvfcTarget : policy.getTargets()) {
1900 if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) {
1902 Map<String, Object> propMap = policy.getPolicyProperties();
1904 if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) {
1905 cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
1912 cvnfcConfigurationCustomization.setConfigurationFunction(
1913 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
1914 cvnfcConfigurationCustomization.setConfigurationRole(
1915 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
1916 cvnfcConfigurationCustomization.setConfigurationType(
1917 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
1919 return cvnfcConfigurationCustomization;
1922 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1923 ConfigurationResource configResource = null;
1924 for (ConfigurationResourceCustomization configurationResourceCustom : service
1925 .getConfigurationCustomizations()) {
1926 if (configurationResourceCustom.getConfigurationResource() != null
1927 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1928 configResource = configurationResourceCustom.getConfigurationResource();
1932 return configResource;
1935 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1936 String vfModuleModelCustomizationUUID) {
1937 VfModuleCustomization vfModuleCustomization = null;
1938 for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
1939 if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) {
1940 vfModuleCustomization = vfModuleCustom;
1943 return vfModuleCustomization;
1946 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1947 VfModule vfModule = null;
1948 for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
1949 if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) {
1950 vfModule = vfModuleCustom.getVfModule();
1953 if (vfModule == null)
1954 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1959 protected VfModuleCustomization createVfModuleCustomization(Group group,
1960 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1961 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1963 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1965 vfModuleCustomization.setVfModule(vfModule);
1967 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1968 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1969 if (initialCount != null && initialCount.length() > 0) {
1970 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1973 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1974 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1976 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1977 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1978 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1979 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1982 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1983 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1985 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1986 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1987 if (maxInstances != null && maxInstances.length() > 0) {
1988 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1991 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1992 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1993 if (minInstances != null && minInstances.length() > 0) {
1994 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1996 return vfModuleCustomization;
1999 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
2000 IVfModuleData vfModuleData, Metadata vfMetadata) {
2001 VfModule vfModule = new VfModule();
2002 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
2004 if (vfModuleModelUUID == null) {
2005 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2006 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
2007 } else if (vfModuleModelUUID.indexOf('.') > -1) {
2008 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
2011 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
2012 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
2013 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2014 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
2015 vfModule.setModelUUID(vfModuleModelUUID);
2016 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2017 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
2018 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2019 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
2021 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2022 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
2023 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
2024 vfModule.setIsBase(true);
2026 vfModule.setIsBase(false);
2031 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
2032 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2033 Metadata vfMetadata) {
2035 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
2036 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
2037 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2038 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
2041 if (matchingObject.isPresent()) {
2042 List<HeatFiles> heatFilesList = new ArrayList<>();
2043 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
2044 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
2045 HeatTemplate parentHeatTemplate = new HeatTemplate();
2046 String parentArtifactType = null;
2047 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
2048 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
2050 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
2052 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
2053 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
2054 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
2057 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
2058 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
2060 if (!childNestedHeatTemplates.isEmpty()) {
2062 if (parentArtifactType != null
2063 && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
2064 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
2066 heatChildTemplates.add(childNestedHeatTemplates.get(0));
2072 if (!heatFilesList.isEmpty()) {
2073 vfModule.setHeatFiles(heatFilesList);
2077 // Set all Child Templates related to HEAT_VOLUME
2078 if (!volumeHeatChildTemplates.isEmpty()) {
2079 if (vfModule.getVolumeHeatTemplate() != null) {
2080 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
2082 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
2086 // Set all Child Templates related to HEAT
2087 if (!heatChildTemplates.isEmpty()) {
2088 if (vfModule.getModuleHeatTemplate() != null) {
2089 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
2091 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
2097 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2098 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
2099 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
2100 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
2101 vfModuleArtifact.incrementDeployedInDB();
2102 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
2103 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
2104 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
2105 VfModuleArtifact volVfModuleArtifact =
2106 this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
2107 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
2108 vfModuleArtifact.incrementDeployedInDB();
2109 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
2110 if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
2111 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
2113 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
2115 vfModuleArtifact.incrementDeployedInDB();
2116 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
2117 heatFilesList.add(vfModuleArtifact.getHeatFiles());
2118 vfModuleArtifact.incrementDeployedInDB();
2119 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
2120 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
2121 vfModuleArtifact.incrementDeployedInDB();
2125 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
2126 ToscaResourceStructure toscaResourceStructure, Service service) {
2127 VnfResourceCustomization vnfResourceCustomization = null;
2128 if (vnfResourceCustomization == null) {
2129 VnfResource vnfResource = findExistingVnfResource(service,
2130 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2132 if (vnfResource == null)
2133 vnfResource = createVnfResource(vfNodeTemplate);
2135 vnfResourceCustomization =
2136 createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource);
2137 vnfResourceCustomization.setVnfResources(vnfResource);
2138 vnfResourceCustomization.setService(service);
2139 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
2142 return vnfResourceCustomization;
2145 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
2146 VnfResource vnfResource = null;
2147 for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
2148 if (vnfResourceCustom.getVnfResources() != null
2149 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
2150 vnfResource = vnfResourceCustom.getVnfResources();
2153 if (vnfResource == null)
2154 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
2159 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
2160 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
2161 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
2162 vnfResourceCustomization.setModelCustomizationUUID(
2163 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2164 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
2166 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2167 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2168 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2169 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
2170 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2171 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2172 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2173 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2175 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
2176 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
2178 vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
2179 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
2181 vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
2182 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
2184 String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper()
2185 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
2186 if (skipPostInstConfText != null) {
2187 vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
2190 vnfResourceCustomization.setVnfResources(vnfResource);
2191 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
2192 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
2194 CapabilityAssignments vnfCustomizationCapability =
2195 toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(vfNodeTemplate);
2197 if (vnfCustomizationCapability != null) {
2198 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
2200 if (capAssign != null) {
2201 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2202 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2203 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2204 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2209 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
2211 return vnfResourceCustomization;
2214 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
2215 VnfResource vnfResource = new VnfResource();
2216 vnfResource.setModelInvariantUUID(
2217 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2218 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2219 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2221 vnfResource.setModelVersion(
2222 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2223 vnfResource.setDescription(
2224 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
2225 vnfResource.setOrchestrationMode(HEAT);
2226 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
2227 vnfResource.setAicVersionMax(
2228 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2229 vnfResource.setAicVersionMin(
2230 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2231 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
2232 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
2237 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
2238 ToscaResourceStructure toscaResourceStructure, Service service) {
2239 AllottedResourceCustomization allottedResourceCustomization =
2240 allottedCustomizationRepo.findOneByModelCustomizationUUID(
2241 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
2243 if (allottedResourceCustomization == null) {
2244 AllottedResource allottedResource = findExistingAllottedResource(service,
2245 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2247 if (allottedResource == null)
2248 allottedResource = createAR(nodeTemplate);
2250 toscaResourceStructure.setAllottedResource(allottedResource);
2251 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
2252 allottedResourceCustomization.setAllottedResource(allottedResource);
2253 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
2255 return allottedResourceCustomization;
2258 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
2259 AllottedResource allottedResource = null;
2260 for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) {
2261 if (allottedResourceCustom.getAllottedResource() != null
2262 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
2263 allottedResource = allottedResourceCustom.getAllottedResource();
2266 if (allottedResource == null)
2267 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
2269 return allottedResource;
2272 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
2273 ToscaResourceStructure toscaResourceStructure) {
2274 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
2275 allottedResourceCustomization.setModelCustomizationUUID(
2276 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2277 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
2280 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2281 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2282 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2283 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
2284 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2285 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2286 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2287 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2289 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
2290 .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
2292 if (vfcNodes != null) {
2293 for (NodeTemplate vfcNode : vfcNodes) {
2295 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
2296 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
2297 allottedResourceCustomization
2298 .setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper()
2299 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
2300 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
2301 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
2306 CapabilityAssignments arCustomizationCapability =
2307 toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(nodeTemplate);
2309 if (arCustomizationCapability != null) {
2310 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
2312 if (capAssign != null) {
2313 allottedResourceCustomization.setMinInstances(
2314 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2315 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2316 allottedResourceCustomization.setMaxInstances(
2317 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2318 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2321 return allottedResourceCustomization;
2324 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
2325 AllottedResource allottedResource = new AllottedResource();
2327 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2328 allottedResource.setModelInvariantUUID(
2329 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2331 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2333 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2334 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
2335 allottedResource.setSubcategory(
2336 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
2338 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
2339 return allottedResource;
2342 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
2343 // Scan the payload downloadResult and extract the HeatTemplate
2345 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
2346 return yamlEditor.getParameterList(artifactUUID);
2349 protected String testNull(Object object) {
2351 if (object == null) {
2353 } else if (object.equals("NULL")) {
2355 } else if (object instanceof Integer) {
2356 return object.toString();
2357 } else if (object instanceof String) {
2358 return (String) object;
2360 return "Type not recognized";
2364 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
2365 VfModuleArtifact heatNestedArtifact) {
2367 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
2368 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
2369 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
2370 .getArtifactInfo().getRelatedArtifacts()) {
2371 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2372 return ASDCConfiguration.HEAT;
2378 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
2379 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
2380 .getRelatedArtifacts() != null) {
2381 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
2382 .get(0).getArtifactInfo().getRelatedArtifacts()) {
2383 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2384 return ASDCConfiguration.HEAT_VOL;
2390 // Does not belong to anything
2395 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
2397 return vfResourceStructure.getNotification().getServiceName() + "/"
2398 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
2401 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
2403 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
2404 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
2407 protected String getPropertyInput(String propertyName) {
2409 String inputName = new String();
2411 if (propertyName != null) {
2412 int getInputIndex = propertyName.indexOf("{get_input=");
2413 if (getInputIndex > -1) {
2414 inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
2422 protected static Timestamp getCurrentTimeStamp() {
2424 return new Timestamp(new Date().getTime());