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(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
253 boolean status = false;
254 VfResourceStructure vfResourceStructure = vfResourceStruct;
256 status = vfResourceStructure.isDeployedSuccessfully();
257 } catch (RuntimeException e) {
261 Service existingService =
262 serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
263 if (existingService != null)
266 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
267 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
268 vfResourceStructure.getNotification().getServiceName(),
269 BigDecimalVersion.castAndCheckNotificationVersionToString(
270 vfResourceStructure.getNotification().getServiceVersion()),
271 vfResourceStructure.getNotification().getServiceUUID(),
272 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
273 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(
274 vfResourceStruct.getNotification().getDistributionID(), MSO);
275 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
276 watchdogCDStatusRepository.saveAndFlush(wdStatus);
278 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
279 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
280 vfResourceStructure.getNotification().getServiceName(),
281 BigDecimalVersion.castAndCheckNotificationVersionToString(
282 vfResourceStructure.getNotification().getServiceVersion()),
283 vfResourceStructure.getNotification().getServiceUUID(),
284 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
287 } catch (Exception e) {
288 logger.error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
289 "Exception - isResourceAlreadyDeployed");
290 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
294 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
295 logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
296 iStatus.getDistributionID(), iStatus.getComponentName());
299 WatchdogComponentDistributionStatus cdStatus =
300 new WatchdogComponentDistributionStatus(iStatus.getDistributionID(), iStatus.getComponentName());
301 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
302 watchdogCDStatusRepository.save(cdStatus);
304 } catch (Exception e) {
305 logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
306 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
310 @Transactional(rollbackFor = {ArtifactInstallerException.class})
311 public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
312 throws ArtifactInstallerException {
313 if (resourceStruct instanceof VfResourceStructure) {
314 installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
315 } else if (resourceStruct instanceof PnfResourceStructure) {
316 installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
318 logger.warn("Unrecognized resource type");
322 private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
323 throws ArtifactInstallerException {
325 // PCLO: in case of deployment failure, use a string that will represent
326 // the type of artifact that failed...
327 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
329 createToscaCsar(toscaResourceStruct);
330 Service service = createService(toscaResourceStruct, resourceStruct);
332 processResourceSequence(toscaResourceStruct, service);
333 processPnfResources(toscaResourceStruct, service, resourceStruct);
334 serviceRepo.save(service);
336 WatchdogComponentDistributionStatus status =
337 new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
338 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
339 watchdogCDStatusRepository.save(status);
341 toscaResourceStruct.setSuccessfulDeployment();
343 } catch (Exception e) {
344 logger.debug("Exception :", e);
345 WatchdogComponentDistributionStatus status =
346 new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
347 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
348 watchdogCDStatusRepository.save(status);
349 Throwable dbExceptionToCapture = e;
350 while (!(dbExceptionToCapture instanceof ConstraintViolationException
351 || dbExceptionToCapture instanceof LockAcquisitionException)
352 && (dbExceptionToCapture.getCause() != null)) {
353 dbExceptionToCapture = dbExceptionToCapture.getCause();
356 if (dbExceptionToCapture instanceof ConstraintViolationException
357 || dbExceptionToCapture instanceof LockAcquisitionException) {
358 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
359 resourceStruct.getResourceInstance().getResourceName(),
360 resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
361 "Exception - ASCDC Artifact already deployed", e);
363 String elementToLog = (!artifactListForLogging.isEmpty()
364 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
365 : "No element listed");
366 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
367 ErrorCode.DataError.getValue(), "Exception caught during installation of "
368 + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback",
370 throw new ArtifactInstallerException(
371 "Exception caught during installation of "
372 + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.",
378 @Transactional(rollbackFor = {ArtifactInstallerException.class})
379 public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
380 throws ArtifactInstallerException {
381 VfResourceStructure vfResourceStructure = vfResourceStruct;
382 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
384 // PCLO: in case of deployment failure, use a string that will represent
385 // the type of artifact that failed...
386 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
388 createToscaCsar(toscaResourceStruct);
389 Service service = createService(toscaResourceStruct, vfResourceStruct);
390 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
393 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 processVFResources(toscaResourceStruct, service, vfResourceStructure);
405 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
406 processAllottedResources(toscaResourceStruct, service, allottedResourceList);
407 processNetworks(toscaResourceStruct, service);
408 // process Network Collections
409 processNetworkCollections(toscaResourceStruct, service);
410 // Process Service Proxy & Configuration
411 processServiceProxyAndConfiguration(toscaResourceStruct, service);
413 serviceRepo.save(service);
415 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
416 vfResourceStruct.getNotification().getDistributionID(), MSO);
417 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
418 watchdogCDStatusRepository.save(status);
420 toscaResourceStruct.setSuccessfulDeployment();
422 } catch (Exception e) {
423 logger.debug("Exception :", e);
424 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
425 vfResourceStruct.getNotification().getDistributionID(), MSO);
426 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
427 watchdogCDStatusRepository.save(status);
428 Throwable dbExceptionToCapture = e;
429 while (!(dbExceptionToCapture instanceof ConstraintViolationException
430 || dbExceptionToCapture instanceof LockAcquisitionException)
431 && (dbExceptionToCapture.getCause() != null)) {
432 dbExceptionToCapture = dbExceptionToCapture.getCause();
435 if (dbExceptionToCapture instanceof ConstraintViolationException
436 || dbExceptionToCapture instanceof LockAcquisitionException) {
437 logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
438 vfResourceStructure.getResourceInstance().getResourceName(),
439 vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
440 "Exception - ASCDC Artifact already deployed", e);
442 String elementToLog = (!artifactListForLogging.isEmpty()
443 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
444 : "No element listed");
445 logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
446 ErrorCode.DataError.getValue(),
447 "Exception caught during installation of "
448 + vfResourceStructure.getResourceInstance().getResourceName()
449 + ". Transaction rollback",
451 throw new ArtifactInstallerException("Exception caught during installation of "
452 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
458 List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
459 ISdcCsarHelper iSdcCsarHelper) {
461 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
462 nodes.addAll(nodeTemplates);
464 for (NodeTemplate nodeTemplate : nodeTemplates) {
465 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
466 List<RequirementAssignment> reqAs = requirement.getAll();
467 for (RequirementAssignment ra : reqAs) {
468 String reqNode = ra.getNodeTemplateName();
469 for (NodeTemplate rNode : resultList) {
470 if (rNode.getName().equals(reqNode)) {
471 if (!resultList.contains(nodeTemplate)) {
472 resultList.add(nodeTemplate);
474 if (nodes.contains(nodeTemplate)) {
475 nodes.remove(nodeTemplate);
483 if (!nodes.isEmpty()) {
484 getRequirementList(resultList, nodes, iSdcCsarHelper);
490 // This method retrieve resource sequence from csar file
491 void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
492 List<String> resouceSequence = new ArrayList<String>();
493 List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
495 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
496 List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
497 List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
498 nodes.addAll(nodeTemplates);
500 for (NodeTemplate nodeTemplate : nodeTemplates) {
501 RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
503 if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
504 resultList.add(nodeTemplate);
505 nodes.remove(nodeTemplate);
509 resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
511 for (NodeTemplate node : resultList) {
512 String templateName = node.getMetaData().getValue("name");
513 if (!resouceSequence.contains(templateName)) {
514 resouceSequence.add(templateName);
518 String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
519 service.setResourceOrder(resourceSeqStr);
520 logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
523 private static String getValue(Object value, List<Input> servInputs) {
524 String output = null;
525 if (value instanceof Map) {
526 // currently this logic handles only one level of nesting.
527 return ((LinkedHashMap) value).values().toArray()[0].toString();
528 } else if (value instanceof GetInput) {
529 String inputName = ((GetInput) value).getInputName();
531 for (Input input : servInputs) {
532 if (input.getName().equals(inputName)) {
533 // keep both input name and default value
534 // if service input does not supplies value the use default value
535 String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
536 output = inputName + "|" + defaultValue;// return default value
541 output = value != null ? value.toString() : "";
543 return output; // return property value
546 String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
547 throws ArtifactInstallerException {
548 Map<String, String> resouceRequest = new HashMap<>();
549 ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
551 List<Input> serInput = iSdcCsarHelper.getServiceInputs();
552 Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
553 .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid))
555 if (nodeTemplateOpt.isPresent()) {
556 NodeTemplate nodeTemplate = nodeTemplateOpt.get();
557 LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
559 for (String key : resourceProperties.keySet()) {
560 Property property = resourceProperties.get(key);
562 String value = getValue(property.getValue(), serInput);
563 resouceRequest.put(key, value);
568 ObjectMapper objectMapper = new ObjectMapper();
569 String jsonStr = objectMapper.writeValueAsString(resouceRequest);
571 jsonStr = jsonStr.replace("\"", "\\\"");
573 "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
575 } catch (JsonProcessingException e) {
576 logger.error("resource input could not be deserialized for resource customization id ("
577 + resourceCustomizationUuid + ")");
578 throw new ArtifactInstallerException("resource input could not be parsed", e);
582 protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
583 throws ArtifactInstallerException {
584 List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
586 if (nodeTemplatesVLList != null) {
587 for (NodeTemplate vlNode : nodeTemplatesVLList) {
588 String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
590 TempNetworkHeatTemplateLookup tempNetworkLookUp =
591 tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
593 if (tempNetworkLookUp != null) {
594 HeatTemplate heatTemplate =
595 heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
596 if (heatTemplate != null) {
597 NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct,
598 heatTemplate, tempNetworkLookUp.getAicVersionMax(),
599 tempNetworkLookUp.getAicVersionMin(), service);
600 service.getNetworkCustomizations().add(networkCustomization);
602 throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
603 + tempNetworkLookUp.getHeatTemplateArtifactUuid());
606 NetworkResourceCustomization networkCustomization =
607 createNetwork(vlNode, toscaResourceStruct, null, null, null, service);
608 service.getNetworkCustomizations().add(networkCustomization);
609 logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
610 + networkResourceModelName);
617 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
618 List<NodeTemplate> allottedResourceList) {
619 if (allottedResourceList != null) {
620 for (NodeTemplate allottedNode : allottedResourceList) {
621 service.getAllottedCustomizations()
622 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
628 protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
629 Metadata metadata = nodeTemplate.getMetaData();
630 ConfigurationResource configResource = new ConfigurationResource();
631 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
632 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
633 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
634 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
635 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
636 configResource.setToscaNodeType(nodeTemplate.getType());
637 return configResource;
640 protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate,
641 ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
642 Metadata metadata = nodeTemplate.getMetaData();
644 ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
646 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
648 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
650 configCustomizationResource
651 .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
652 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
654 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper()
655 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
656 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper()
657 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
658 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper()
659 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
660 configCustomizationResource
661 .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
663 configCustomizationResource.setConfigurationResource(configResource);
664 configResourceCustomizationSet.add(configCustomizationResource);
666 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
667 return configCustomizationResource;
671 protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(
672 List<NodeTemplate> configurationNodeTemplatesList, ToscaResourceStructure toscaResourceStructure,
673 ServiceProxyResourceCustomization spResourceCustomization) {
674 Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
675 for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
676 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
677 String type = entityType.getType();
679 if (VLAN_NETWORK_RECEPTOR.equals(type)) {
680 configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate,
681 toscaResourceStructure, spResourceCustomization));
686 return configurationResourceCust;
689 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
691 List<NodeTemplate> serviceProxyResourceList =
692 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
694 List<NodeTemplate> configurationNodeTemplatesList =
695 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
697 List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
698 List<ConfigurationResourceCustomization> configurationResourceList =
699 new ArrayList<ConfigurationResourceCustomization>();
701 ServiceProxyResourceCustomization serviceProxy = null;
703 if (serviceProxyResourceList != null) {
704 for (NodeTemplate spNode : serviceProxyResourceList) {
705 serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
706 serviceProxyList.add(serviceProxy);
707 Optional<ConfigurationResourceCustomization> vnrResourceCustomization =
708 getVnrNodeTemplate(configurationNodeTemplatesList, toscaResourceStruct, serviceProxy);
710 for (NodeTemplate configNode : configurationNodeTemplatesList) {
712 List<RequirementAssignment> requirementsList =
713 toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
714 for (RequirementAssignment requirement : requirementsList) {
715 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
716 ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
717 toscaResourceStruct, serviceProxy, vnrResourceCustomization);
719 Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList
721 .filter(configurationResourceCustomization -> configNode.getMetaData()
722 .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
723 .equals(configurationResource.getModelCustomizationUUID()))
725 if (!matchingObject.isPresent()) {
726 configurationResourceList.add(configurationResource);
737 service.setConfigurationCustomizations(configurationResourceList);
738 service.setServiceProxyCustomizations(serviceProxyList);
741 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
743 List<NodeTemplate> networkCollectionList =
744 toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
746 if (networkCollectionList != null) {
747 for (NodeTemplate crNode : networkCollectionList) {
749 createNetworkCollection(crNode, toscaResourceStruct, service);
750 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
752 List<NetworkInstanceGroup> networkInstanceGroupList =
753 toscaResourceStruct.getCatalogNetworkInstanceGroup();
754 for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
755 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
760 service.getCollectionResourceCustomizations()
761 .add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
765 protected void processVFResources(ToscaResourceStructure toscaResourceStruct, Service service,
766 VfResourceStructure vfResourceStructure) throws Exception {
767 logger.debug("processVFResources");
769 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
770 // String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
771 // String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
773 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
774 Metadata metadata = nodeTemplate.getMetaData();
775 String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
776 logger.debug("VF Category is : " + vfCustomizationCategory);
778 // Do not treat Allotted Resources as VNF resources
779 if (ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)) {
783 String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
784 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
786 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
788 // Make sure the VF ResourceCustomizationUUID from the notification and tosca
789 // customizations match before comparing their VF Modules UUID's
790 logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
791 + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
792 + vfCustomizationUUID);
794 if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
795 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
796 + " matches vfNotificationResource CustomizationUUID");
798 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
799 vfCustomizationCategory);
801 logger.debug("Notification VF ResourceCustomizationUUID: "
802 + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
803 + "Tosca VF Customization UUID: " + vfCustomizationUUID);
809 * This is used to process the PNF specific resource, including resource and resource_customization.
810 * {@link IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for
813 protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
814 PnfResourceStructure resourceStructure) throws Exception {
815 logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
817 ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
818 EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
819 TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
821 List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
822 for (IEntityDetails entityDetails : entityDetailsList) {
823 Metadata metadata = entityDetails.getMetadata();
824 String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
825 String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
826 String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
827 if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
828 logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
829 customizationUUID, notifCustomizationUUID);
831 if (checkExistingPnfResourceCutomization(customizationUUID)) {
832 logger.info("Resource customization UUID: {} already deployed", customizationUUID);
834 PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
835 if (pnfResource == null) {
836 pnfResource = createPnfResource(entityDetails);
838 PnfResourceCustomization pnfResourceCustomization =
839 createPnfResourceCustomization(entityDetails, pnfResource);
840 pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
841 toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
842 service.getPnfCustomizations().add(pnfResourceCustomization);
846 "Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
847 customizationUUID, notifCustomizationUUID);
852 private PnfResource findExistingPnfResource(Service service, String modelUuid) {
853 PnfResource pnfResource = null;
854 for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
855 if (pnfResourceCustomization.getPnfResources() != null
856 && pnfResourceCustomization.getPnfResources().getModelUUID().equals(modelUuid)) {
857 pnfResource = pnfResourceCustomization.getPnfResources();
860 if (pnfResource == null) {
861 pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
866 private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
867 return pnfCustomizationRepository.findById(customizationUUID).isPresent();
871 * Construct the {@link PnfResource} from {@link IEntityDetails} object.
873 private PnfResource createPnfResource(IEntityDetails entity) {
874 PnfResource pnfResource = new PnfResource();
875 Metadata metadata = entity.getMetadata();
876 pnfResource.setModelInvariantUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
877 pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
878 pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
879 pnfResource.setModelVersion(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
880 pnfResource.setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
881 pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
882 pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
883 pnfResource.setToscaNodeType(entity.getToscaType());
888 * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
890 private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
891 PnfResource pnfResource) {
893 PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
894 Metadata metadata = entityDetails.getMetadata();
895 Map<String, Property> properties = entityDetails.getProperties();
896 pnfResourceCustomization.setModelCustomizationUUID(
897 testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
898 pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
899 pnfResourceCustomization
900 .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
901 pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
902 pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
903 pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
904 pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
905 pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
906 pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
907 pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
908 pnfResourceCustomization.setPnfResources(pnfResource);
910 return pnfResourceCustomization;
914 * Get value from {@link Property} and cast to boolean value. Return true if property is null.
916 private boolean getBooleanValue(Property property) {
917 if (null == property) {
920 Object value = property.getValue();
921 return new Boolean(String.valueOf(value));
925 * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
927 private String getStringValue(Property property) {
928 if (null == property) {
931 Object value = property.getValue();
932 return String.valueOf(value);
935 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
936 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
939 logger.debug("VF Category is : " + vfCustomizationCategory);
941 if (vfResourceStructure.getVfModuleStructure() != null
942 && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
944 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata,
945 SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
946 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
948 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
950 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
951 // comparing their VF Modules UUID's
952 logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
953 + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
954 + vfCustomizationUUID);
956 if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
958 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
959 + " matches vfNotificationResource CustomizationUUID");
961 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
963 Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
964 Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
966 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
968 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
969 List<org.onap.sdc.toscaparser.api.Group> vfGroups =
970 toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
971 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
973 logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : "
974 + vfMetadata.getVfModuleModelCustomizationUUID());
976 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
977 .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID "
978 + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
979 .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
980 .equals(vfMetadata.getVfModuleModelCustomizationUUID()))
982 if (matchingObject.isPresent()) {
983 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
984 nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource,
985 service, existingCvnfcSet, existingVnfcSet);
986 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
989 "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: "
990 + vfMetadata.getVfModuleModelCustomizationUUID());
995 // Check for VNFC Instance Group info and add it if there is
996 List<Group> groupList =
997 toscaResourceStruct.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
998 nodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
1000 for (Group group : groupList) {
1001 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
1002 createVNFCInstanceGroup(nodeTemplate, group, vnfResource, toscaResourceStruct);
1003 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1007 service.getVnfCustomizations().add(vnfResource);
1009 logger.debug("Notification VF ResourceCustomizationUUID: "
1010 + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
1011 + "Tosca VF Customization UUID: " + vfCustomizationUUID);
1016 public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
1017 String consumerId) {
1018 WatchdogServiceModVerIdLookup modVerIdLookup =
1019 new WatchdogServiceModVerIdLookup(distributionId, servideUUID, distributionNotification, consumerId);
1020 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
1024 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
1025 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
1027 } catch (ObjectOptimisticLockingFailureException e) {
1028 logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
1033 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
1034 VfResourceStructure vfResourceStructure) {
1035 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1037 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
1038 case ASDCConfiguration.HEAT:
1039 case ASDCConfiguration.HEAT_NESTED:
1040 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
1042 case ASDCConfiguration.HEAT_VOL:
1043 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
1044 VfModuleArtifact envModuleArtifact =
1045 getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1046 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
1048 case ASDCConfiguration.HEAT_ENV:
1049 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
1051 case ASDCConfiguration.HEAT_ARTIFACT:
1052 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct);
1054 case ASDCConfiguration.HEAT_NET:
1055 case ASDCConfiguration.OTHER:
1056 logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
1057 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
1058 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
1059 ErrorCode.DataError.getValue(), "Artifact type not supported");
1068 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
1069 VfModuleArtifact vfModuleArtifact) {
1070 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
1071 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
1072 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1073 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
1074 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1075 return moduleArtifact;
1081 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
1082 List<String> listTypes) {
1083 String newFileBody = filebody;
1084 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1086 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
1089 verifyTheFilePrefixInString(newFileBody, moduleArtifact.getArtifactInfo().getArtifactName());
1095 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
1097 String needlePrefix = "file:///";
1098 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
1100 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
1104 StringBuilder sb = new StringBuilder(body.length());
1106 int currentIndex = 0;
1109 while (currentIndex != -1) {
1110 startIndex = currentIndex;
1111 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
1113 if (currentIndex == -1) {
1116 // We append from the startIndex up to currentIndex (start of File
1118 sb.append(body.substring(startIndex, currentIndex));
1119 sb.append(filenameToVerify);
1121 currentIndex += prefixedFilenameToVerify.length();
1124 sb.append(body.substring(startIndex));
1126 return sb.toString();
1129 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
1130 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
1131 HeatTemplate heatTemplate = new HeatTemplate();
1132 List<String> typeList = new ArrayList<>();
1133 typeList.add(ASDCConfiguration.HEAT_NESTED);
1134 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
1136 heatTemplate.setTemplateBody(
1137 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1138 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1140 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
1141 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
1143 heatTemplate.setTimeoutMinutes(240);
1146 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1147 heatTemplate.setVersion(BigDecimalVersion
1148 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1149 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1151 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1152 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1154 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
1157 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(vfModuleArtifact.getResult(),
1158 vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1159 heatTemplate.setParameters(heatParam);
1160 vfModuleArtifact.setHeatTemplate(heatTemplate);
1163 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
1164 VfModuleArtifact vfModuleArtifact) {
1165 HeatEnvironment heatEnvironment = new HeatEnvironment();
1166 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1167 List<String> typeList = new ArrayList<>();
1168 typeList.add(ASDCConfiguration.HEAT);
1169 typeList.add(ASDCConfiguration.HEAT_VOL);
1170 heatEnvironment.setEnvironment(
1171 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
1172 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1173 heatEnvironment.setVersion(BigDecimalVersion
1174 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1175 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1177 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1178 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1180 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
1182 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
1185 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
1186 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
1188 HeatFiles heatFile = new HeatFiles();
1189 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1190 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
1191 heatFile.setFileBody(vfModuleArtifact.getResult());
1192 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
1193 heatFile.setVersion(BigDecimalVersion
1194 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
1195 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
1196 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
1197 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
1199 heatFile.setArtifactChecksum(MANUAL_RECORD);
1201 vfModuleArtifact.setHeatFiles(heatFile);
1204 protected Service createService(ToscaResourceStructure toscaResourceStructure,
1205 ResourceStructure resourceStructure) {
1207 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
1209 Service service = new Service();
1211 if (serviceMetadata != null) {
1213 if (toscaResourceStructure.getServiceVersion() != null) {
1214 service.setModelVersion(toscaResourceStructure.getServiceVersion());
1217 service.setServiceType(serviceMetadata.getValue("serviceType"));
1218 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
1219 service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
1221 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1222 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1223 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1224 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
1226 if (resourceStructure != null)
1227 service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
1229 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1230 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
1234 toscaResourceStructure.setCatalogService(service);
1238 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
1239 ToscaResourceStructure toscaResourceStructure) {
1241 Metadata spMetadata = nodeTemplate.getMetaData();
1243 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
1245 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
1247 spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1248 spCustomizationResource
1249 .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1250 spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1251 spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1252 spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1254 spCustomizationResource
1255 .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1256 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
1257 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1259 String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
1261 Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
1263 spCustomizationResource.setSourceService(sourceService);
1264 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
1265 serviceProxyCustomizationSet.add(spCustomizationResource);
1268 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
1270 return spCustomizationResource;
1273 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
1274 ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
1275 Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
1277 ConfigurationResourceCustomization configCustomizationResource =
1278 getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure, spResourceCustomization);
1280 ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
1282 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
1284 StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
1285 String type = entityType.getType();
1287 if (NODES_VRF_ENTRY.equals(type)) {
1288 configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
1291 configCustomizationResource.setConfigurationResource(configResource);
1293 configResourceCustomizationSet.add(configCustomizationResource);
1295 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
1297 toscaResourceStructure.setCatalogConfigurationResource(configResource);
1299 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
1301 return configCustomizationResource;
1304 protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate,
1305 ToscaResourceStructure toscaResourceStructure) {
1307 Metadata fabricMetadata = nodeTemplate.getMetaData();
1309 ConfigurationResource configResource = new ConfigurationResource();
1311 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1312 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1313 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1314 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1315 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1316 configResource.setToscaNodeType(nodeTemplate.getType());
1318 return configResource;
1321 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
1322 ToscaCsar toscaCsar = new ToscaCsar();
1323 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
1324 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
1326 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
1328 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
1329 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
1330 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
1331 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
1332 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
1334 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
1337 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
1338 VnfcCustomization vnfcCustomization = null;
1339 for (VnfcCustomization vnfcCustom : vnfcCustomizations) {
1340 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
1341 vnfcCustomization = vnfcCustom;
1345 if (vnfcCustomization == null)
1346 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
1347 // vnfcCustomization = new VnfcCustomization();
1349 return vnfcCustomization;
1352 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations,
1353 String customizationUUID) {
1354 CvnfcCustomization cvnfcCustomization = null;
1355 for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) {
1356 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
1357 cvnfcCustomization = cvnfcCustom;
1361 if (cvnfcCustomization == null)
1362 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
1364 return cvnfcCustomization;
1367 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
1368 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
1371 NetworkResourceCustomization networkResourceCustomization =
1372 networkCustomizationRepo.findOneByModelCustomizationUUID(
1373 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1375 boolean networkUUIDsMatch = true;
1376 // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from
1377 // the distribution.
1378 // If not we'll update the Customization record with latest from the distribution
1379 if (networkResourceCustomization != null) {
1380 String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
1381 String latestNetworkModelUUID =
1382 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
1384 if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
1385 networkUUIDsMatch = false;
1390 if (networkResourceCustomization != null && !networkUUIDsMatch) {
1392 NetworkResource networkResource =
1393 createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, aicMax, aicMin);
1395 networkResourceCustomization.setNetworkResource(networkResource);
1397 networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
1399 } else if (networkResourceCustomization == null) {
1400 networkResourceCustomization =
1401 createNetworkResourceCustomization(networkNodeTemplate, toscaResourceStructure);
1403 NetworkResource networkResource = findExistingNetworkResource(service,
1404 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1405 if (networkResource == null)
1406 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
1409 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
1410 networkResourceCustomization.setNetworkResource(networkResource);
1413 return networkResourceCustomization;
1416 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
1417 NetworkResource networkResource = null;
1418 for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) {
1419 if (networkCustom.getNetworkResource() != null
1420 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
1421 networkResource = networkCustom.getNetworkResource();
1424 if (networkResource == null)
1425 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
1427 return networkResource;
1430 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
1431 ToscaResourceStructure toscaResourceStructure) {
1432 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
1433 networkResourceCustomization.setModelInstanceName(
1434 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1435 networkResourceCustomization.setModelCustomizationUUID(
1436 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1438 networkResourceCustomization.setNetworkTechnology(
1439 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1440 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
1441 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
1442 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
1443 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1444 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
1445 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
1446 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
1447 return networkResourceCustomization;
1450 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
1451 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
1452 NetworkResource networkResource = new NetworkResource();
1453 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1454 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1456 if ("true".equalsIgnoreCase(providerNetwork)) {
1457 networkResource.setNeutronNetworkType(PROVIDER);
1459 networkResource.setNeutronNetworkType(BASIC);
1462 networkResource.setModelName(
1463 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1465 networkResource.setModelInvariantUUID(
1466 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1467 networkResource.setModelUUID(
1468 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1469 networkResource.setModelVersion(
1470 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1472 networkResource.setAicVersionMax(aicMax);
1473 networkResource.setAicVersionMin(aicMin);
1474 networkResource.setToscaNodeType(networkNodeTemplate.getType());
1475 networkResource.setDescription(
1476 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1477 networkResource.setOrchestrationMode(HEAT);
1478 networkResource.setHeatTemplate(heatTemplate);
1479 return networkResource;
1482 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
1483 ToscaResourceStructure toscaResourceStructure, Service service) {
1485 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization =
1486 new CollectionNetworkResourceCustomization();
1488 // **** Build Object to populate Collection_Resource table
1489 CollectionResource collectionResource = new CollectionResource();
1492 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1493 collectionResource.setModelInvariantUUID(
1494 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1496 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1498 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1500 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1501 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
1503 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
1505 // **** Build object to populate Collection_Resource_Customization table
1506 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
1508 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1510 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1512 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1515 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1516 ncfc.setModelCustomizationUUID(
1517 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1519 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
1520 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
1522 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
1524 ncfc.setCollectionResource(collectionResource);
1525 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
1527 // *** Build object to populate the Instance_Group table
1528 List<Group> groupList =
1529 toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
1530 networkNodeTemplate, "org.openecomp.groups.NetworkCollection");
1532 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
1534 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList =
1535 new ArrayList<CollectionResourceInstanceGroupCustomization>();
1537 for (Group group : groupList) {
1539 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
1540 Metadata instanceMetadata = group.getMetadata();
1541 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1542 networkInstanceGroup
1543 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1544 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1545 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1546 networkInstanceGroup.setToscaNodeType(group.getType());
1547 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1549 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1551 networkInstanceGroup.setCollectionResource(collectionResource);
1553 // ****Build object to populate
1554 // Collection_Resource_Instance_Group_Customization table
1555 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization =
1556 new CollectionResourceInstanceGroupCustomization();
1557 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1558 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1559 crInstanceGroupCustomization.setModelCustomizationUUID(
1560 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1562 // Loop through the template policy to find the subinterface_network_quantity property name. Then extract
1563 // the value for it.
1564 List<Policy> policyList =
1565 toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(
1566 networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
1568 if (policyList != null) {
1569 for (Policy policy : policyList) {
1570 for (String policyNetworkCollection : policy.getTargets()) {
1572 if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
1574 Map<String, Object> propMap = policy.getPolicyProperties();
1576 if (propMap.get("quantity") != null) {
1578 String quantity = toscaResourceStructure.getSdcCsarHelper()
1579 .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1580 getPropertyInput(propMap.get("quantity").toString()));
1582 if (quantity != null) {
1583 crInstanceGroupCustomization
1584 .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
1594 crInstanceGroupCustomization.setDescription(
1595 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1596 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1597 + "_network_collection_description"));
1598 crInstanceGroupCustomization.setFunction(
1599 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1600 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1601 + "_network_collection_function"));
1602 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1603 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1605 networkInstanceGroup
1606 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1608 networkInstanceGroupList.add(networkInstanceGroup);
1611 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1613 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1614 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1616 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1618 // *****Build object to populate the NetworkResource table
1619 NetworkResource networkResource = new NetworkResource();
1621 for (NodeTemplate vlNodeTemplate : vlNodeList) {
1623 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1624 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1626 if ("true".equalsIgnoreCase(providerNetwork)) {
1627 networkResource.setNeutronNetworkType(PROVIDER);
1629 networkResource.setNeutronNetworkType(BASIC);
1633 .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1635 networkResource.setModelInvariantUUID(
1636 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1638 .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1640 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1642 networkResource.setAicVersionMax(
1643 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1645 TempNetworkHeatTemplateLookup tempNetworkLookUp =
1646 tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1647 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1649 if (tempNetworkLookUp != null) {
1651 HeatTemplate heatTemplate =
1652 heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1653 networkResource.setHeatTemplate(heatTemplate);
1655 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1659 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1660 networkResource.setDescription(
1661 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1662 networkResource.setOrchestrationMode(HEAT);
1664 // Build object to populate the
1665 // Collection_Network_Resource_Customization table
1666 for (NodeTemplate memberNode : group.getMemberNodes()) {
1667 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1670 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1671 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1673 collectionNetworkResourceCustomization.setNetworkTechnology(
1674 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1675 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1676 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1677 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1678 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1679 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1680 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1681 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1682 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1683 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1684 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1686 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1691 return collectionNetworkResourceCustomization;
1694 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1695 VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
1697 Metadata instanceMetadata = group.getMetadata();
1698 // Populate InstanceGroup
1699 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1701 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1702 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1703 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1704 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1705 vfcInstanceGroup.setToscaNodeType(group.getType());
1706 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1707 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1709 // Populate VNFCInstanceGroupCustomization
1710 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1712 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1713 vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1715 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1716 vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
1718 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1720 String getInputName = null;
1721 String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1722 "vfc_instance_group_function");
1723 if (groupProperty != null) {
1724 int getInputIndex = groupProperty.indexOf("{get_input=");
1725 if (getInputIndex > -1) {
1726 getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1);
1729 vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper()
1730 .getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
1731 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1734 return vfcInstanceGroupCustom;
1738 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
1739 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1740 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
1741 Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
1743 VfModuleCustomization vfModuleCustomization =
1744 findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
1745 if (vfModuleCustomization == null) {
1746 VfModule vfModule = findExistingVfModule(vnfResource,
1747 vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1748 Metadata vfMetadata = group.getMetadata();
1749 if (vfModule == null)
1750 vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1752 vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
1753 vfModuleCustomization.setVnfCustomization(vnfResource);
1754 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1756 vfModuleCustomization.setVfModule(vfModule);
1757 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1758 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1760 vfResourceStructure.setAlreadyDeployed(true);
1763 // ******************************************************************************************************************
1764 // * Extract VFC's and CVFC's then add them to VFModule
1765 // ******************************************************************************************************************
1767 Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations =
1768 new HashSet<CvnfcConfigurationCustomization>();
1769 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
1770 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
1772 // Only set the CVNFC if this vfModule group is a member of it.
1773 List<NodeTemplate> groupMembers =
1774 toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
1775 String vfModuleMemberName = null;
1777 for (NodeTemplate node : groupMembers) {
1778 vfModuleMemberName = node.getName();
1781 // Extract CVFC lists
1782 List<NodeTemplate> cvfcList =
1783 toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
1785 for (NodeTemplate cvfcTemplate : cvfcList) {
1786 boolean cvnfcVfModuleNameMatch = false;
1788 for (NodeTemplate node : groupMembers) {
1789 vfModuleMemberName = node.getName();
1791 if (vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) {
1792 cvnfcVfModuleNameMatch = true;
1797 if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
1799 // Extract associated VFC - Should always be just one
1800 List<NodeTemplate> vfcList =
1801 toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1803 for (NodeTemplate vfcTemplate : vfcList) {
1805 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1806 VnfcCustomization existingVnfcCustomization = null;
1808 existingVnfcCustomization = findExistingVfc(existingVnfcSet,
1809 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1811 if (existingVnfcCustomization == null) {
1812 vnfcCustomization = new VnfcCustomization();
1814 vnfcCustomization = existingVnfcCustomization;
1817 // Only Add Abstract VNFC's to our DB, ignore all others
1818 if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
1819 .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
1820 vnfcCustomization.setModelCustomizationUUID(
1821 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1822 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1823 vnfcCustomization.setModelInvariantUUID(
1824 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1826 .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1828 .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1830 vnfcCustomization.setModelVersion(
1831 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1832 vnfcCustomization.setDescription(testNull(
1833 vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1834 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1836 vnfcCustomizations.add(vnfcCustomization);
1837 existingVnfcSet.add(vnfcCustomization);
1840 // This check is needed incase the VFC subcategory is
1841 // something other than Abstract. In that case we want to
1842 // skip adding that record to our DB.
1843 if (vnfcCustomization.getModelCustomizationUUID() != null) {
1844 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1845 cvnfcCustomization.setModelCustomizationUUID(
1846 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1847 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1848 cvnfcCustomization.setModelInvariantUUID(
1849 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1851 .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1853 .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1855 cvnfcCustomization.setModelVersion(
1856 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1857 cvnfcCustomization.setDescription(testNull(
1858 cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1859 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1861 if (existingVnfcCustomization != null) {
1862 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1864 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1867 cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
1868 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
1869 cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
1870 .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
1871 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1873 cvnfcCustomizations.add(cvnfcCustomization);
1874 existingCvnfcSet.add(cvnfcCustomization);
1876 // *****************************************************************************************************************************************
1877 // * Extract Fabric Configuration
1878 // *****************************************************************************************************************************************
1880 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
1881 .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
1883 for (NodeTemplate fabricTemplate : fabricConfigList) {
1885 ConfigurationResource fabricConfig = null;
1887 ConfigurationResource existingConfig = findExistingConfiguration(service,
1888 fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1890 if (existingConfig == null) {
1892 fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1895 fabricConfig = existingConfig;
1898 CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
1899 createCvnfcConfigurationCustomization(fabricTemplate, toscaResourceStructure,
1900 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig,
1901 vfTemplate, vfModuleMemberName);
1902 cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
1904 fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1906 cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
1913 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1915 return vfModuleCustomization;
1918 protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate,
1919 ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource,
1920 VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1921 ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
1923 Metadata fabricMetadata = fabricTemplate.getMetaData();
1925 CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
1927 cvnfcConfigurationCustomization.setConfigurationResource(configResource);
1929 cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
1931 cvnfcConfigurationCustomization
1932 .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1933 cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
1935 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper()
1936 .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
1938 if (policyList != null) {
1939 for (Policy policy : policyList) {
1941 for (String policyCvfcTarget : policy.getTargets()) {
1943 if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) {
1945 Map<String, Object> propMap = policy.getPolicyProperties();
1947 if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) {
1948 cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
1955 cvnfcConfigurationCustomization.setConfigurationFunction(
1956 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
1957 cvnfcConfigurationCustomization.setConfigurationRole(
1958 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
1959 cvnfcConfigurationCustomization.setConfigurationType(
1960 toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
1962 return cvnfcConfigurationCustomization;
1965 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1966 ConfigurationResource configResource = null;
1967 for (ConfigurationResourceCustomization configurationResourceCustom : service
1968 .getConfigurationCustomizations()) {
1969 if (configurationResourceCustom.getConfigurationResource() != null
1970 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1971 configResource = configurationResourceCustom.getConfigurationResource();
1975 return configResource;
1978 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1979 String vfModuleModelCustomizationUUID) {
1980 VfModuleCustomization vfModuleCustomization = null;
1981 for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
1982 if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) {
1983 vfModuleCustomization = vfModuleCustom;
1986 return vfModuleCustomization;
1989 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1990 VfModule vfModule = null;
1991 for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
1992 if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) {
1993 vfModule = vfModuleCustom.getVfModule();
1996 if (vfModule == null)
1997 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
2002 protected VfModuleCustomization createVfModuleCustomization(Group group,
2003 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
2004 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
2006 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
2008 vfModuleCustomization.setVfModule(vfModule);
2010 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2011 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
2012 if (initialCount != null && initialCount.length() > 0) {
2013 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
2016 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
2017 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
2019 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2020 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
2021 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
2022 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
2025 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2026 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
2028 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2029 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
2030 if (maxInstances != null && maxInstances.length() > 0) {
2031 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
2034 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2035 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
2036 if (minInstances != null && minInstances.length() > 0) {
2037 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
2039 return vfModuleCustomization;
2042 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
2043 IVfModuleData vfModuleData, Metadata vfMetadata) {
2044 VfModule vfModule = new VfModule();
2045 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
2047 if (vfModuleModelUUID == null) {
2048 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2049 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
2050 } else if (vfModuleModelUUID.indexOf('.') > -1) {
2051 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
2054 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
2055 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
2056 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2057 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
2058 vfModule.setModelUUID(vfModuleModelUUID);
2059 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2060 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
2061 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2062 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
2064 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
2065 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
2066 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
2067 vfModule.setIsBase(true);
2069 vfModule.setIsBase(false);
2074 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
2075 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2076 Metadata vfMetadata) {
2078 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
2079 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
2080 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
2081 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
2084 if (matchingObject.isPresent()) {
2085 List<HeatFiles> heatFilesList = new ArrayList<>();
2086 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
2087 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
2088 HeatTemplate parentHeatTemplate = new HeatTemplate();
2089 String parentArtifactType = null;
2090 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
2091 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
2093 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
2095 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
2096 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
2097 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
2100 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
2101 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
2103 if (!childNestedHeatTemplates.isEmpty()) {
2105 if (parentArtifactType != null
2106 && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
2107 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
2109 heatChildTemplates.add(childNestedHeatTemplates.get(0));
2115 if (!heatFilesList.isEmpty()) {
2116 vfModule.setHeatFiles(heatFilesList);
2120 // Set all Child Templates related to HEAT_VOLUME
2121 if (!volumeHeatChildTemplates.isEmpty()) {
2122 if (vfModule.getVolumeHeatTemplate() != null) {
2123 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
2125 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
2129 // Set all Child Templates related to HEAT
2130 if (!heatChildTemplates.isEmpty()) {
2131 if (vfModule.getModuleHeatTemplate() != null) {
2132 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
2134 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
2140 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
2141 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
2142 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
2143 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
2144 vfModuleArtifact.incrementDeployedInDB();
2145 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
2146 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
2147 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
2148 VfModuleArtifact volVfModuleArtifact =
2149 this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
2150 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
2151 vfModuleArtifact.incrementDeployedInDB();
2152 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
2153 if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
2154 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
2156 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
2158 vfModuleArtifact.incrementDeployedInDB();
2159 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
2160 heatFilesList.add(vfModuleArtifact.getHeatFiles());
2161 vfModuleArtifact.incrementDeployedInDB();
2162 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
2163 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
2164 vfModuleArtifact.incrementDeployedInDB();
2168 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
2169 ToscaResourceStructure toscaResourceStructure, Service service) {
2170 VnfResourceCustomization vnfResourceCustomization = null;
2171 if (vnfResourceCustomization == null) {
2172 VnfResource vnfResource = findExistingVnfResource(service,
2173 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2175 if (vnfResource == null)
2176 vnfResource = createVnfResource(vfNodeTemplate);
2178 vnfResourceCustomization =
2179 createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource);
2180 vnfResourceCustomization.setVnfResources(vnfResource);
2181 vnfResourceCustomization.setService(service);
2182 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
2185 return vnfResourceCustomization;
2188 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
2189 VnfResource vnfResource = null;
2190 for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
2191 if (vnfResourceCustom.getVnfResources() != null
2192 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
2193 vnfResource = vnfResourceCustom.getVnfResources();
2196 if (vnfResource == null)
2197 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
2202 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
2203 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
2204 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
2205 vnfResourceCustomization.setModelCustomizationUUID(
2206 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2207 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
2209 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2210 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2211 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2212 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
2213 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2214 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2215 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2216 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2218 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
2219 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
2221 vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
2222 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
2224 vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
2225 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
2227 String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper()
2228 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
2229 if (skipPostInstConfText != null) {
2230 vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
2233 vnfResourceCustomization.setVnfResources(vnfResource);
2234 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
2235 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
2237 CapabilityAssignments vnfCustomizationCapability =
2238 toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(vfNodeTemplate);
2240 if (vnfCustomizationCapability != null) {
2241 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
2243 if (capAssign != null) {
2244 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2245 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2246 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
2247 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2252 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
2254 return vnfResourceCustomization;
2257 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
2258 VnfResource vnfResource = new VnfResource();
2259 vnfResource.setModelInvariantUUID(
2260 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2261 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2262 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2264 vnfResource.setModelVersion(
2265 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2266 vnfResource.setDescription(
2267 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
2268 vnfResource.setOrchestrationMode(HEAT);
2269 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
2270 vnfResource.setAicVersionMax(
2271 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2272 vnfResource.setAicVersionMin(
2273 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2274 vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
2275 vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
2280 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
2281 ToscaResourceStructure toscaResourceStructure, Service service) {
2282 AllottedResourceCustomization allottedResourceCustomization =
2283 allottedCustomizationRepo.findOneByModelCustomizationUUID(
2284 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
2286 if (allottedResourceCustomization == null) {
2287 AllottedResource allottedResource = findExistingAllottedResource(service,
2288 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
2290 if (allottedResource == null)
2291 allottedResource = createAR(nodeTemplate);
2293 toscaResourceStructure.setAllottedResource(allottedResource);
2294 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
2295 allottedResourceCustomization.setAllottedResource(allottedResource);
2296 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
2298 return allottedResourceCustomization;
2301 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
2302 AllottedResource allottedResource = null;
2303 for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) {
2304 if (allottedResourceCustom.getAllottedResource() != null
2305 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
2306 allottedResource = allottedResourceCustom.getAllottedResource();
2309 if (allottedResource == null)
2310 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
2312 return allottedResource;
2315 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
2316 ToscaResourceStructure toscaResourceStructure) {
2317 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
2318 allottedResourceCustomization.setModelCustomizationUUID(
2319 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
2320 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
2323 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
2324 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
2325 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
2326 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
2327 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
2328 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
2329 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
2330 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
2332 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
2333 .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
2335 if (vfcNodes != null) {
2336 for (NodeTemplate vfcNode : vfcNodes) {
2338 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
2339 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
2340 allottedResourceCustomization
2341 .setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper()
2342 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
2343 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
2344 .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
2349 CapabilityAssignments arCustomizationCapability =
2350 toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(nodeTemplate);
2352 if (arCustomizationCapability != null) {
2353 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
2355 if (capAssign != null) {
2356 allottedResourceCustomization.setMinInstances(
2357 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2358 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
2359 allottedResourceCustomization.setMaxInstances(
2360 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
2361 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
2364 return allottedResourceCustomization;
2367 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
2368 AllottedResource allottedResource = new AllottedResource();
2370 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
2371 allottedResource.setModelInvariantUUID(
2372 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
2374 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
2376 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
2377 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
2378 allottedResource.setSubcategory(
2379 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
2381 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
2382 return allottedResource;
2385 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
2386 // Scan the payload downloadResult and extract the HeatTemplate
2388 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
2389 return yamlEditor.getParameterList(artifactUUID);
2392 protected String testNull(Object object) {
2394 if (object == null) {
2396 } else if (object.equals("NULL")) {
2398 } else if (object instanceof Integer) {
2399 return object.toString();
2400 } else if (object instanceof String) {
2401 return (String) object;
2403 return "Type not recognized";
2407 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
2408 VfModuleArtifact heatNestedArtifact) {
2410 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
2411 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
2412 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
2413 .getArtifactInfo().getRelatedArtifacts()) {
2414 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2415 return ASDCConfiguration.HEAT;
2421 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
2422 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
2423 .getRelatedArtifacts() != null) {
2424 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
2425 .get(0).getArtifactInfo().getRelatedArtifacts()) {
2426 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
2427 return ASDCConfiguration.HEAT_VOL;
2433 // Does not belong to anything
2438 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
2440 return vfResourceStructure.getNotification().getServiceName() + "/"
2441 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
2444 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
2446 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
2447 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
2450 protected String getPropertyInput(String propertyName) {
2452 String inputName = new String();
2454 if (propertyName != null) {
2455 int getInputIndex = propertyName.indexOf("{get_input=");
2456 if (getInputIndex > -1) {
2457 inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
2465 protected static Timestamp getCurrentTimeStamp() {
2467 return new Timestamp(new Date().getTime());