2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.asdc.installer.heat;
25 import java.sql.Timestamp;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Optional;
33 import org.hibernate.exception.ConstraintViolationException;
34 import org.hibernate.exception.LockAcquisitionException;
35 import org.onap.sdc.api.notification.IArtifactInfo;
36 import org.onap.sdc.api.notification.IResourceInstance;
37 import org.onap.sdc.api.notification.IStatusData;
38 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
39 import org.onap.sdc.tosca.parser.impl.SdcTypes;
40 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
41 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
42 import org.onap.sdc.toscaparser.api.Group;
43 import org.onap.sdc.toscaparser.api.NodeTemplate;
44 import org.onap.sdc.toscaparser.api.Policy;
45 import org.onap.sdc.toscaparser.api.RequirementAssignment;
46 import org.onap.sdc.toscaparser.api.elements.Metadata;
47 import org.onap.sdc.utils.DistributionStatusEnum;
48 import org.onap.so.asdc.client.ASDCConfiguration;
49 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
50 import org.onap.so.asdc.installer.ASDCElementInfo;
51 import org.onap.so.asdc.installer.BigDecimalVersion;
52 import org.onap.so.asdc.installer.IVfModuleData;
53 import org.onap.so.asdc.installer.ToscaResourceStructure;
54 import org.onap.so.asdc.installer.VfModuleArtifact;
55 import org.onap.so.asdc.installer.VfModuleStructure;
56 import org.onap.so.asdc.installer.VfResourceStructure;
57 import org.onap.so.asdc.util.YamlEditor;
58 import org.onap.so.db.catalog.beans.AllottedResource;
59 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
60 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
61 import org.onap.so.db.catalog.beans.CollectionResource;
62 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
63 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
64 import org.onap.so.db.catalog.beans.ConfigurationResource;
65 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
66 import org.onap.so.db.catalog.beans.CvnfcCustomization;
67 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
68 import org.onap.so.db.catalog.beans.HeatEnvironment;
69 import org.onap.so.db.catalog.beans.HeatFiles;
70 import org.onap.so.db.catalog.beans.HeatTemplate;
71 import org.onap.so.db.catalog.beans.HeatTemplateParam;
72 import org.onap.so.db.catalog.beans.InstanceGroupType;
73 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
74 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
75 import org.onap.so.db.catalog.beans.NetworkResource;
76 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
77 import org.onap.so.db.catalog.beans.Service;
78 import org.onap.so.db.catalog.beans.ServiceProxyResource;
79 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
80 import org.onap.so.db.catalog.beans.SubType;
81 import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
82 import org.onap.so.db.catalog.beans.ToscaCsar;
83 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
84 import org.onap.so.db.catalog.beans.VfModule;
85 import org.onap.so.db.catalog.beans.VfModuleCustomization;
86 import org.onap.so.db.catalog.beans.VnfResource;
87 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
88 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
89 import org.onap.so.db.catalog.beans.VnfcCustomization;
90 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
91 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
92 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
93 import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
94 import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
95 import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
96 import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
97 import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
98 import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
99 import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
100 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
101 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
102 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
103 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
104 import org.onap.so.db.catalog.data.repository.ServiceRepository;
105 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
106 import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
107 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
108 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
109 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
110 import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
111 import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
112 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
113 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
114 import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
115 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
116 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
117 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
118 import org.onap.so.logger.MessageEnum;
119 import org.onap.so.logger.MsoLogger;
120 import org.springframework.beans.factory.annotation.Autowired;
121 import org.springframework.stereotype.Component;
122 import org.springframework.transaction.annotation.Transactional;
125 public class ToscaResourceInstaller {
127 protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
129 protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
131 protected static final String SCALABLE = "scalable";
133 protected static final String BASIC = "BASIC";
135 protected static final String PROVIDER = "PROVIDER";
137 protected static final String HEAT = "HEAT";
139 protected static final String MANUAL_RECORD = "MANUAL_RECORD";
141 protected static final String MSO = "SO";
145 protected ServiceRepository serviceRepo;
148 protected InstanceGroupRepository instanceGroupRepo;
151 protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
154 protected CollectionResourceRepository collectionRepo;
157 protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
160 protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
163 protected ConfigurationResourceRepository configRepo;
166 protected VnfResourceRepository vnfRepo;
169 protected VnfCustomizationRepository vnfCustomizationRepo;
172 protected VFModuleRepository vfModuleRepo;
175 protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
178 protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
181 protected VnfcCustomizationRepository vnfcCustomizationRepo;
184 protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
187 protected AllottedResourceRepository allottedRepo;
190 protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
193 protected NetworkResourceRepository networkRepo;
196 protected HeatTemplateRepository heatRepo;
199 protected NetworkResourceCustomizationRepository networkCustomizationRepo;
202 protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
204 protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
206 protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
209 protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
212 protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
214 protected static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ToscaResourceInstaller.class);
216 public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
217 boolean status = false;
218 VfResourceStructure vfResourceStructure = vfResourceStruct;
220 status = vfResourceStructure.isDeployedSuccessfully();
221 } catch (RuntimeException e) {
225 Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
226 if(existingService != null)
229 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
230 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
231 vfResourceStructure.getNotification().getServiceName(),
232 BigDecimalVersion.castAndCheckNotificationVersionToString(
233 vfResourceStructure.getNotification().getServiceVersion()),
234 vfResourceStructure.getNotification().getServiceUUID(),
235 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
236 WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
237 wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
238 watchdogCDStatusRepository.saveAndFlush(wdStatus);
240 logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
241 vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
242 vfResourceStructure.getNotification().getServiceName(),
243 BigDecimalVersion.castAndCheckNotificationVersionToString(
244 vfResourceStructure.getNotification().getServiceVersion()),
245 vfResourceStructure.getNotification().getServiceUUID(),
246 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
249 } catch (Exception e) {
250 logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError,
251 "Exception - isResourceAlreadyDeployed");
252 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
256 public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
257 logger.debug("Entering installTheComponentStatus for distributionId " + iStatus.getDistributionID()
258 + " and ComponentName " + iStatus.getComponentName());
261 WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
262 iStatus.getComponentName());
263 cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
264 watchdogCDStatusRepository.save(cdStatus);
266 } catch (Exception e) {
267 logger.debug("Exception caught in installTheComponentStatus " + e.getMessage());
268 throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
272 @Transactional(rollbackFor = { ArtifactInstallerException.class })
273 public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
274 throws ArtifactInstallerException {
275 VfResourceStructure vfResourceStructure = vfResourceStruct;
276 extractHeatInformation(toscaResourceStruct, vfResourceStructure);
278 // PCLO: in case of deployment failure, use a string that will represent
279 // the type of artifact that failed...
280 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
282 createToscaCsar(toscaResourceStruct);
283 createService(toscaResourceStruct, vfResourceStruct);
284 Service service = toscaResourceStruct.getCatalogService();
285 List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
288 for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
290 Metadata metadata = nodeTemplate.getMetaData();
291 String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
292 String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
293 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
294 processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
295 vfCustomizationCategory);
298 List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
299 processAllottedResources(toscaResourceStruct, service, allottedResourceList);
300 processNetworks(toscaResourceStruct, service);
301 // process Network Collections
302 processNetworkCollections(toscaResourceStruct, service);
303 // Process Service Proxy & Configuration
304 processServiceProxyAndConfiguration(toscaResourceStruct, service);
306 serviceRepo.save(service);
308 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
309 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
310 watchdogCDStatusRepository.save(status);
312 toscaResourceStruct.setSuccessfulDeployment();
314 } catch (Exception e) {
315 logger.debug("Exception :", e);
316 WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
317 status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
318 watchdogCDStatusRepository.save(status);
319 Throwable dbExceptionToCapture = e;
320 while (!(dbExceptionToCapture instanceof ConstraintViolationException
321 || dbExceptionToCapture instanceof LockAcquisitionException)
322 && (dbExceptionToCapture.getCause() != null)) {
323 dbExceptionToCapture = dbExceptionToCapture.getCause();
326 if (dbExceptionToCapture instanceof ConstraintViolationException
327 || dbExceptionToCapture instanceof LockAcquisitionException) {
328 logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED,
329 vfResourceStructure.getResourceInstance().getResourceName(),
330 vfResourceStructure.getNotification().getServiceVersion(), "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
332 String elementToLog = (!artifactListForLogging.isEmpty()
333 ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
334 : "No element listed");
335 logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError,
336 "Exception caught during installation of "
337 + vfResourceStructure.getResourceInstance().getResourceName()
338 + ". Transaction rollback",
340 throw new ArtifactInstallerException("Exception caught during installation of "
341 + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
346 protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
347 throws ArtifactInstallerException {
348 List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
350 if (nodeTemplatesVLList != null) {
351 for (NodeTemplate vlNode : nodeTemplatesVLList) {
352 String networkResourceModelName = vlNode.getMetaData()
353 .getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
355 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
357 if (tempNetworkLookUp != null ) {
358 HeatTemplate heatTemplate = heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
359 if (heatTemplate != null ) {
360 NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct, heatTemplate,tempNetworkLookUp.getAicVersionMax(),
361 tempNetworkLookUp.getAicVersionMin(),service);
362 service.getNetworkCustomizations()
363 .add(networkCustomization);
366 throw new ArtifactInstallerException(
367 "No HeatTemplate found for artifactUUID: "
368 + tempNetworkLookUp.getHeatTemplateArtifactUuid());
371 throw new ArtifactInstallerException(
372 "No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
373 + networkResourceModelName);
380 protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
381 List<NodeTemplate> allottedResourceList) {
382 if (allottedResourceList != null) {
383 for (NodeTemplate allottedNode : allottedResourceList) {
384 service.getAllottedCustomizations()
385 .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
390 protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
392 List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
394 List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
396 if (serviceProxyResourceList != null) {
397 for (NodeTemplate spNode : serviceProxyResourceList) {
398 createServiceProxy(spNode, service, toscaResourceStruct);
399 serviceProxyCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogServiceProxyResourceCustomization());
401 for (NodeTemplate configNode : configurationNodeTemplatesList) {
403 List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
404 for (RequirementAssignment requirement : requirementsList) {
405 if (requirement.getNodeTemplateName().equals(spNode.getName())) {
406 createConfiguration(configNode, toscaResourceStruct, toscaResourceStruct.getCatalogServiceProxyResourceCustomization());
407 configCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogConfigurationResourceCustomization());
417 protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
419 List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
421 if (networkCollectionList != null) {
422 for (NodeTemplate crNode : networkCollectionList) {
424 createNetworkCollection(crNode, toscaResourceStruct, service);
425 collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
427 List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
428 for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
429 instanceGroupRepo.saveAndFlush(networkInstanceGroup);
434 service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
437 protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
438 Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
440 logger.debug("VF Category is : " + vfCustomizationCategory);
442 //if (!vfCustomizationCategory.equalsIgnoreCase(ALLOTTED_RESOURCE))
443 if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
446 String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
447 .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
448 logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
450 IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
452 // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
453 logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
454 " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
456 if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
458 logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
460 VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
462 Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
463 Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
465 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
467 logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
468 List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
469 .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
470 IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
472 logger.debug("Comparing VFModule Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
473 for(Group group : vfGroups){
474 logger.debug("To Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
477 Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream().
478 filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).
480 if(matchingObject.isPresent()){
481 VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
482 vfResourceStructure,vfMetadata, vnfResource, service, cvnfcCustomizations, vnfcCustomizations);
483 vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
485 throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
488 service.getVnfCustomizations().add(vnfResource);
493 public void processWatchdog(String distributionId, String servideUUID) {
494 WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
495 watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
497 WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
498 watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
501 protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
502 VfResourceStructure vfResourceStructure) {
503 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
505 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
506 case ASDCConfiguration.HEAT:
507 case ASDCConfiguration.HEAT_NESTED:
508 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
511 case ASDCConfiguration.HEAT_VOL:
512 createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
514 VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
515 createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
517 case ASDCConfiguration.HEAT_ENV:
518 createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
520 case ASDCConfiguration.HEAT_ARTIFACT:
521 createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
522 toscaResourceStruct);
524 case ASDCConfiguration.HEAT_NET:
525 case ASDCConfiguration.OTHER:
526 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
527 vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
528 + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
529 "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
538 protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
539 VfModuleArtifact vfModuleArtifact) {
540 String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
541 artifactName = artifactName.substring(0, artifactName.indexOf('.'));
542 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
543 if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
544 && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
545 return moduleArtifact;
551 public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
552 List<String> listTypes) {
553 String newFileBody = filebody;
554 for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
556 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
558 newFileBody = verifyTheFilePrefixInString(newFileBody,
559 moduleArtifact.getArtifactInfo().getArtifactName());
565 public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
567 String needlePrefix = "file:///";
568 String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
570 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
574 StringBuilder sb = new StringBuilder(body.length());
576 int currentIndex = 0;
579 while (currentIndex != -1) {
580 startIndex = currentIndex;
581 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
583 if (currentIndex == -1) {
586 // We append from the startIndex up to currentIndex (start of File
588 sb.append(body.substring(startIndex, currentIndex));
589 sb.append(filenameToVerify);
591 currentIndex += prefixedFilenameToVerify.length();
594 sb.append(body.substring(startIndex));
596 return sb.toString();
599 protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
600 ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
601 HeatTemplate heatTemplate = new HeatTemplate();
602 List<String> typeList = new ArrayList<>();
603 typeList.add(ASDCConfiguration.HEAT_NESTED);
604 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
606 heatTemplate.setTemplateBody(
607 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
608 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
610 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
611 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
613 heatTemplate.setTimeoutMinutes(240);
616 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
617 heatTemplate.setVersion(BigDecimalVersion
618 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
619 heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
621 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
622 heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
624 heatTemplate.setArtifactChecksum(MANUAL_RECORD);
627 Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
628 vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
629 heatTemplate.setParameters(heatParam);
630 vfModuleArtifact.setHeatTemplate(heatTemplate);
633 protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
634 VfModuleArtifact vfModuleArtifact) {
635 HeatEnvironment heatEnvironment = new HeatEnvironment();
636 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
637 List<String> typeList = new ArrayList<>();
638 typeList.add(ASDCConfiguration.HEAT);
639 typeList.add(ASDCConfiguration.HEAT_VOL);
640 heatEnvironment.setEnvironment(
641 verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
642 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
643 heatEnvironment.setVersion(BigDecimalVersion
644 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
645 heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
647 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
648 heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
650 heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
652 vfModuleArtifact.setHeatEnvironment(heatEnvironment);
655 protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
656 VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
658 HeatFiles heatFile = new HeatFiles();
659 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
660 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
661 heatFile.setFileBody(vfModuleArtifact.getResult());
662 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
663 heatFile.setVersion(BigDecimalVersion
664 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
665 toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
666 if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
667 heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
669 heatFile.setArtifactChecksum(MANUAL_RECORD);
671 vfModuleArtifact.setHeatFiles(heatFile);
674 protected Service createService(ToscaResourceStructure toscaResourceStructure,
675 VfResourceStructure vfResourceStructure) {
677 toscaResourceStructure.getServiceMetadata();
679 Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
681 Service service = new Service();
683 if (serviceMetadata != null) {
685 if (toscaResourceStructure.getServiceVersion() != null) {
686 service.setModelVersion(toscaResourceStructure.getServiceVersion());
689 service.setServiceType(serviceMetadata.getValue("serviceType"));
690 service.setServiceRole(serviceMetadata.getValue("serviceRole"));
692 service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
693 service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
694 service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
695 service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
697 if (vfResourceStructure != null)
698 service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
700 service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
701 service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
705 toscaResourceStructure.setCatalogService(service);
709 protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
711 Metadata spMetadata = nodeTemplate.getMetaData();
713 ServiceProxyResource spResource = new ServiceProxyResource();
715 spResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
716 spResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
717 spResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
718 spResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
719 spResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
721 ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
723 Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
725 spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
726 spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
727 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
728 spCustomizationResource.setSourceService(service);
729 spCustomizationResource.setServiceProxyResource(spResource);
730 spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
731 spCustomizationResource.setServiceProxyResource(spResource);
732 serviceProxyCustomizationSet.add(spCustomizationResource);
735 spResource.setServiceProxyCustomization(serviceProxyCustomizationSet);
737 toscaResourceStructure.setCatalogServiceProxyResource(spResource);
739 toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
741 return spCustomizationResource;
744 protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
746 Metadata metadata = nodeTemplate.getMetaData();
748 ConfigurationResource configResource = new ConfigurationResource();
750 configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
751 configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
752 configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
753 configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
754 configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
755 configResource.setToscaNodeType(nodeTemplate.getType());
757 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
759 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
761 configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
762 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
764 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
765 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
766 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
767 configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
768 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
769 configCustomizationResource.setConfigurationResource(configResource);
770 configResourceCustomizationSet.add(configCustomizationResource);
772 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
774 toscaResourceStructure.setCatalogConfigurationResource(configResource);
776 toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
778 return configCustomizationResource;
781 protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
783 Metadata fabricMetadata = nodeTemplate.getMetaData();
785 ConfigurationResource configResource = new ConfigurationResource();
787 configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
788 configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
789 configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
790 configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
791 configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
792 configResource.setToscaNodeType(nodeTemplate.getType());
794 ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
796 Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
798 configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
799 configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
801 configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
802 configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
803 configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
804 configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
805 configCustomizationResource.setConfigurationResource(configResource);
806 configResourceCustomizationSet.add(configCustomizationResource);
808 configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
810 return configCustomizationResource;
813 protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
814 ToscaCsar toscaCsar = new ToscaCsar();
815 if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
816 toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
818 toscaCsar.setArtifactChecksum(MANUAL_RECORD);
820 toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
821 toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
822 toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
823 toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
824 toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
826 toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
829 protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
830 VnfcCustomization vnfcCustomization = null;
831 for(VnfcCustomization vnfcCustom : vnfcCustomizations){
832 if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
833 vnfcCustomization = vnfcCustom;
837 if(vnfcCustomization==null)
838 vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
840 return vnfcCustomization;
843 protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
844 CvnfcCustomization cvnfcCustomization = null;
845 for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
846 if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
847 cvnfcCustomization = cvnfcCustom;
851 if(cvnfcCustomization==null)
852 cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
854 return cvnfcCustomization;
857 protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
858 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
860 NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
861 if(networkResourceCustomization==null){
862 networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
863 toscaResourceStructure);
865 NetworkResource networkResource = findExistingNetworkResource(service,
866 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
867 if(networkResource == null)
868 networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
871 networkResource.addNetworkResourceCustomization(networkResourceCustomization);
872 networkResourceCustomization.setNetworkResource(networkResource);
874 return networkResourceCustomization;
877 protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
878 NetworkResource networkResource = null;
879 for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
880 if (networkCustom.getNetworkResource() != null
881 && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
882 networkResource = networkCustom.getNetworkResource();
885 if(networkResource==null)
886 networkResource = networkRepo.findResourceByModelUUID(modelUUID);
888 return networkResource;
891 protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
892 ToscaResourceStructure toscaResourceStructure) {
893 NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
894 networkResourceCustomization.setModelInstanceName(
895 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
896 networkResourceCustomization.setModelCustomizationUUID(
897 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
899 networkResourceCustomization.setNetworkTechnology(
900 testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
901 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
902 networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
903 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
904 networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
905 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
906 networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
907 .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
908 return networkResourceCustomization;
911 protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
912 ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
913 NetworkResource networkResource = new NetworkResource();
914 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
915 networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
917 if ("true".equalsIgnoreCase(providerNetwork)) {
918 networkResource.setNeutronNetworkType(PROVIDER);
920 networkResource.setNeutronNetworkType(BASIC);
923 networkResource.setModelName(
924 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
926 networkResource.setModelInvariantUUID(
927 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
928 networkResource.setModelUUID(
929 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
930 networkResource.setModelVersion(
931 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
933 networkResource.setAicVersionMax(aicMax);
934 networkResource.setAicVersionMin(aicMin);
935 networkResource.setToscaNodeType(networkNodeTemplate.getType());
936 networkResource.setDescription(
937 testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
938 networkResource.setOrchestrationMode(HEAT);
939 networkResource.setHeatTemplate(heatTemplate);
940 return networkResource;
943 protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
944 ToscaResourceStructure toscaResourceStructure, Service service) {
946 CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
948 // **** Build Object to populate Collection_Resource table
949 CollectionResource collectionResource = new CollectionResource();
952 .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
953 collectionResource.setModelInvariantUUID(
954 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
956 .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
958 .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
960 .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
961 collectionResource.setToscaNodeType(networkNodeTemplate.getType());
963 toscaResourceStructure.setCatalogCollectionResource(collectionResource);
965 // **** Build object to populate Collection_Resource_Customization table
966 NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
968 ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
970 ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
972 ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
975 ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
976 ncfc.setModelCustomizationUUID(
977 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
979 Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
980 networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
982 ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
984 ncfc.setCollectionResource(collectionResource);
985 toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
987 //*** Build object to populate the Instance_Group table
988 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
989 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
990 "org.openecomp.groups.NetworkCollection");
992 List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
994 List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
996 for (Group group : groupList) {
998 NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
999 Metadata instanceMetadata = group.getMetadata();
1000 networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1001 networkInstanceGroup
1002 .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1003 networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1004 networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1005 networkInstanceGroup.setToscaNodeType(group.getType());
1006 networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
1008 networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
1010 networkInstanceGroup.setCollectionResource(collectionResource);
1012 // ****Build object to populate
1013 // Collection_Resource_Instance_Group_Customization table
1014 CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
1015 crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
1016 crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1017 crInstanceGroupCustomization.setModelCustomizationUUID(
1018 networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1020 String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
1021 String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
1022 if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1023 fixedQuantity + "_quantity") != null) {
1025 crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
1026 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1027 fixedQuantity + "_quantity")));
1030 crInstanceGroupCustomization.setDescription(
1031 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1032 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1033 + "_network_collection_description"));
1034 crInstanceGroupCustomization.setFunction(
1035 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
1036 instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
1037 + "_network_collection_function"));
1038 crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
1039 collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
1041 networkInstanceGroup
1042 .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
1044 networkInstanceGroupList.add(networkInstanceGroup);
1048 toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
1050 List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
1051 .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
1053 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
1055 //*****Build object to populate the NetworkResource table
1056 NetworkResource networkResource = new NetworkResource();
1058 for(NodeTemplate vlNodeTemplate : vlNodeList){
1060 String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
1061 vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
1063 if ("true".equalsIgnoreCase(providerNetwork)) {
1064 networkResource.setNeutronNetworkType(PROVIDER);
1066 networkResource.setNeutronNetworkType(BASIC);
1069 networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1071 networkResource.setModelInvariantUUID(
1072 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1073 networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1075 .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1077 networkResource.setAicVersionMax(
1078 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
1080 TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
1081 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1083 if (tempNetworkLookUp != null ) {
1085 HeatTemplate heatTemplate = heatRepo
1086 .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
1087 networkResource.setHeatTemplate(heatTemplate);
1089 networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
1093 networkResource.setToscaNodeType(vlNodeTemplate.getType());
1095 .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1096 networkResource.setOrchestrationMode(HEAT);
1098 // Build object to populate the
1099 // Collection_Network_Resource_Customization table
1100 for (NodeTemplate memberNode : group.getMemberNodes()) {
1101 collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
1104 collectionNetworkResourceCustomization.setModelCustomizationUUID(
1105 vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1107 collectionNetworkResourceCustomization.setNetworkTechnology(
1108 toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
1109 SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
1110 collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
1111 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
1112 collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
1113 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
1114 collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
1115 .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
1116 collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
1117 collectionNetworkResourceCustomization.setNetworkResource(networkResource);
1118 collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
1120 collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
1125 return collectionNetworkResourceCustomization;
1128 protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
1129 VnfResourceCustomization vnfResourceCustomization) {
1131 Metadata instanceMetadata = group.getMetadata();
1132 // Populate InstanceGroup
1133 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
1135 vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1136 vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1137 vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1138 vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
1139 vfcInstanceGroup.setToscaNodeType(group.getType());
1140 vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
1141 vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
1143 //Populate VNFCInstanceGroupCustomization
1144 VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
1146 vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
1147 vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1148 vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1149 vfcInstanceGroupCustom.setFunction("FUNCTION");
1150 vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
1151 vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
1153 return vfcInstanceGroupCustom;
1157 protected VFCInstanceGroup findExistingVnfcInstanceGroup(VnfResourceCustomization vnfResourceCustomization,
1159 VFCInstanceGroup vfcInstanceGroup = null;
1160 List<VnfcInstanceGroupCustomization> vnfInstanceGroupCustomizations = vnfResourceCustomization
1161 .getVnfcInstanceGroupCustomizations();
1162 if(vnfInstanceGroupCustomizations != null){
1163 for (VnfcInstanceGroupCustomization vnfcInstanceGroupCustom : vnfResourceCustomization
1164 .getVnfcInstanceGroupCustomizations()) {
1165 if (vnfcInstanceGroupCustom.getInstanceGroup() != null
1166 && vnfcInstanceGroupCustom.getInstanceGroup().getModelUUID().equals(modelUUID)) {
1167 vfcInstanceGroup = (VFCInstanceGroup)vnfcInstanceGroupCustom.getInstanceGroup();
1171 if (vfcInstanceGroup == null)
1172 vfcInstanceGroup = (VFCInstanceGroup) instanceGroupRepo.findByModelUUID(modelUUID);
1174 return vfcInstanceGroup;
1177 protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
1178 ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
1179 IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> cvnfcCustomizations, Set<VnfcCustomization> vnfcCustomizations) {
1180 VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
1181 vfModuleData.getVfModuleModelCustomizationUUID());
1182 if(vfModuleCustomization == null){
1183 VfModule vfModule = findExistingVfModule(vnfResource,
1184 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1185 Metadata vfMetadata = group.getMetadata();
1187 vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
1189 vfModuleCustomization = createVfModuleCustomzation(group, toscaResourceStructure, vfModule, vfModuleData);
1190 setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
1192 vfModuleCustomization.setVfModule(vfModule);
1193 vfModule.getVfModuleCustomization().add(vfModuleCustomization);
1194 vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
1196 vfResourceStructure.setAlreadyDeployed(true);
1199 //******************************************************************************************************************
1200 //* Extract VFC's and CVFC's then add them to VFModule
1201 //******************************************************************************************************************
1203 Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
1205 // Extract CVFC lists
1206 List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
1208 for(NodeTemplate cvfcTemplate : cvfcList) {
1210 CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(cvnfcCustomizations, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1212 if(existingCvnfcCustomization == null){
1214 //Extract associated VFC - Should always be just one
1215 List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
1217 VnfcCustomization vnfcCustomization = new VnfcCustomization();
1218 VnfcCustomization existingVnfcCustomization = null;
1220 for(NodeTemplate vfcTemplate : vfcList) {
1222 existingVnfcCustomization = findExistingVfc(vnfcCustomizations, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1224 if(existingVnfcCustomization == null){
1225 vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1226 vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
1227 vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1228 vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1229 vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1231 vnfcCustomization.setModelVersion(
1232 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1233 vnfcCustomization.setDescription(
1234 testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1235 vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
1237 vnfcCustomizations.add(vnfcCustomization);
1242 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
1243 cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1244 cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
1245 cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
1246 cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
1247 cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1249 cvnfcCustomization.setModelVersion(
1250 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1251 cvnfcCustomization.setDescription(
1252 testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1253 cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
1255 if(existingVnfcCustomization != null){
1256 cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
1258 cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
1261 cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
1262 cvnfcCustomization.setVnfResourceCustomization(vnfResource);
1264 cvnfcCustomizations.add(cvnfcCustomization);
1266 //*****************************************************************************************************************************************
1267 //* Extract Fabric Configuration
1268 //*****************************************************************************************************************************************
1270 List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
1272 for(NodeTemplate fabricTemplate : fabricConfigList) {
1274 ConfigurationResource fabricConfig = null;
1276 ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1278 if(existingConfig == null){
1280 ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
1282 fabricConfig = fabricConfigCustomization.getConfigurationResource();
1284 service.getConfigurationCustomizations().add(fabricConfigCustomization);
1286 fabricConfig = existingConfig;
1290 VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
1291 vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
1293 vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
1300 vfModuleCustomization.setVnfcCustomization(vnfcCustomizations);
1301 vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
1302 vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
1304 return vfModuleCustomization;
1307 protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
1308 VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
1309 ConfigurationResource configResource) {
1311 Metadata fabricMetadata = fabricTemplate.getMetaData();
1314 VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
1316 vfModuleToCvnfc.setConfigurationResource(configResource);
1317 vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
1318 vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1319 vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
1320 vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
1321 vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
1322 vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
1324 List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
1326 if(policyList != null){
1327 for(Policy policy : policyList){
1328 vfModuleToCvnfc.setPolicyName(policy.getName());
1332 vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
1333 vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
1334 vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
1336 return vfModuleToCvnfc;
1339 protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
1340 ConfigurationResource configResource = null;
1341 for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
1342 if (configurationResourceCustom.getConfigurationResource() != null
1343 && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
1344 configResource = configurationResourceCustom.getConfigurationResource();
1347 if(configResource==null)
1348 configResource = configRepo.findResourceByModelUUID(modelUUID);
1350 return configResource;
1353 protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
1354 String vfModuleModelCustomizationUUID) {
1355 VfModuleCustomization vfModuleCustomization = null;
1356 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1357 if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
1358 vfModuleCustomization = vfModuleCustom;
1361 if(vfModuleCustomization==null)
1362 vfModuleCustomization = vfModuleCustomizationRepo
1363 .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
1365 return vfModuleCustomization;
1368 protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
1369 VfModule vfModule = null;
1370 for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
1371 if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
1372 vfModule = vfModuleCustom.getVfModule();
1376 vfModule = vfModuleRepo.findByModelUUID(modelUUID);
1381 protected VfModuleCustomization createVfModuleCustomzation(Group group,
1382 ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
1383 VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
1385 vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
1387 vfModuleCustomization.setVfModule(vfModule);
1389 String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1390 SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
1391 if (initialCount != null && initialCount.length() > 0) {
1392 vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
1395 vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
1396 .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
1398 String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1399 SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
1400 if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
1401 vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
1404 vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1405 SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
1407 String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1408 SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
1409 if (maxInstances != null && maxInstances.length() > 0) {
1410 vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
1413 String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1414 SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
1415 if (minInstances != null && minInstances.length() > 0) {
1416 vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
1418 return vfModuleCustomization;
1421 protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
1422 IVfModuleData vfModuleData, Metadata vfMetadata) {
1423 VfModule vfModule = new VfModule();
1424 String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
1426 if(vfModuleModelUUID == null) {
1427 vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1428 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
1429 } else if (vfModuleModelUUID.indexOf('.') > -1) {
1430 vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
1433 vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
1434 .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
1435 vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1436 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
1437 vfModule.setModelUUID(vfModuleModelUUID);
1438 vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1439 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
1440 vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1441 SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1443 String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
1444 SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
1445 if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
1446 vfModule.setIsBase(true);
1448 vfModule.setIsBase(false);
1453 protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
1454 VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1455 Metadata vfMetadata) {
1457 Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
1458 .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
1459 .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
1460 SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
1463 if (matchingObject.isPresent()) {
1464 List<HeatFiles> heatFilesList = new ArrayList<>();
1465 List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
1466 List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
1467 HeatTemplate parentHeatTemplate = new HeatTemplate();
1468 String parentArtifactType = null;
1469 Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
1470 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
1472 List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
1474 if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
1475 checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
1476 childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
1479 if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
1480 parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
1482 if(!childNestedHeatTemplates.isEmpty()){
1484 if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
1485 volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
1487 heatChildTemplates.add(childNestedHeatTemplates.get(0));
1493 if(!heatFilesList.isEmpty()){
1494 vfModule.setHeatFiles(heatFilesList);
1498 // Set all Child Templates related to HEAT_VOLUME
1499 if(!volumeHeatChildTemplates.isEmpty()){
1500 if(vfModule.getVolumeHeatTemplate() != null){
1501 vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
1503 logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
1507 // Set all Child Templates related to HEAT
1508 if(!heatChildTemplates.isEmpty()){
1509 if(vfModule.getModuleHeatTemplate() != null){
1510 vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
1512 logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
1518 protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
1519 List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
1520 HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
1521 if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
1522 vfModuleArtifact.incrementDeployedInDB();
1523 vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
1524 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
1525 vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
1526 VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
1527 vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
1528 vfModuleArtifact.incrementDeployedInDB();
1529 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
1530 if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
1531 vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
1533 vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
1535 vfModuleArtifact.incrementDeployedInDB();
1536 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
1537 heatFilesList.add(vfModuleArtifact.getHeatFiles());
1538 vfModuleArtifact.incrementDeployedInDB();
1539 } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
1540 nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
1541 vfModuleArtifact.incrementDeployedInDB();
1545 protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
1546 ToscaResourceStructure toscaResourceStructure, Service service) {
1547 VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
1548 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1549 if(vnfResourceCustomization == null){
1550 VnfResource vnfResource = findExistingVnfResource(service,
1551 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1553 if(vnfResource==null)
1554 vnfResource=createVnfResource(vfNodeTemplate);
1556 vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
1558 vnfResourceCustomization.setVnfResources(vnfResource);
1559 vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
1561 // Fetch VNFC Instance Group Info
1562 List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
1563 .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
1564 "org.openecomp.groups.VfcInstanceGroup");
1566 for (Group group : groupList) {
1568 VFCInstanceGroup vfcInstanceGroup = findExistingVnfcInstanceGroup(vnfResourceCustomization,
1569 group.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1570 if(vfcInstanceGroup == null){
1571 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(
1572 vfNodeTemplate, group, vnfResourceCustomization);
1574 vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
1579 return vnfResourceCustomization;
1582 protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
1583 VnfResource vnfResource = null;
1584 for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
1585 if (vnfResourceCustom.getVnfResources() != null
1586 && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
1587 vnfResource = vnfResourceCustom.getVnfResources();
1590 if(vnfResource==null)
1591 vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
1596 protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
1597 ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
1598 VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
1599 vnfResourceCustomization.setModelCustomizationUUID(
1600 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1601 vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
1603 vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1604 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1605 vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1606 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
1607 vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1608 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1609 vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1610 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1612 vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
1613 .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
1615 vnfResourceCustomization.setVnfResources(vnfResource);
1616 vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
1617 vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
1619 CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1620 .getCapabilitiesOf(vfNodeTemplate);
1622 if (vnfCustomizationCapability != null) {
1623 CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
1625 if (capAssign != null) {
1626 vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1627 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1628 vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
1629 .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1634 toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
1636 return vnfResourceCustomization;
1639 protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
1640 VnfResource vnfResource = new VnfResource();
1641 vnfResource.setModelInvariantUUID(
1642 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1643 vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1644 vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1646 vnfResource.setModelVersion(
1647 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1648 vnfResource.setDescription(
1649 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
1650 vnfResource.setOrchestrationMode(HEAT);
1651 vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
1652 vnfResource.setAicVersionMax(
1653 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1654 vnfResource.setAicVersionMin(
1655 testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1660 protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
1661 ToscaResourceStructure toscaResourceStructure, Service service) {
1662 AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
1663 .findOneByModelCustomizationUUID(
1664 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
1666 if(allottedResourceCustomization == null){
1667 AllottedResource allottedResource = findExistingAllottedResource(service,
1668 nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
1670 if(allottedResource==null)
1671 allottedResource=createAR(nodeTemplate);
1673 toscaResourceStructure.setAllottedResource(allottedResource);
1674 allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
1675 allottedResourceCustomization.setAllottedResource(allottedResource);
1676 allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
1678 return allottedResourceCustomization;
1681 protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
1682 AllottedResource allottedResource = null;
1683 for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
1684 if (allottedResourceCustom.getAllottedResource() != null
1685 && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
1686 allottedResource = allottedResourceCustom.getAllottedResource();
1689 if(allottedResource==null)
1690 allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
1692 return allottedResource;
1695 protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
1696 ToscaResourceStructure toscaResourceStructure) {
1697 AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
1698 allottedResourceCustomization.setModelCustomizationUUID(
1699 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
1700 allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
1703 allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
1704 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
1705 allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
1706 .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
1707 allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
1708 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
1709 allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
1710 .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
1712 List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
1714 if(vfcNodes != null){
1715 for(NodeTemplate vfcNode : vfcNodes){
1717 allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
1718 allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
1719 allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
1724 CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
1725 .getCapabilitiesOf(nodeTemplate);
1727 if (arCustomizationCapability != null) {
1728 CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
1730 if (capAssign != null) {
1731 allottedResourceCustomization.setMinInstances(
1732 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1733 capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
1734 allottedResourceCustomization.setMaxInstances(
1735 Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
1736 capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
1739 return allottedResourceCustomization;
1742 protected AllottedResource createAR(NodeTemplate nodeTemplate) {
1743 AllottedResource allottedResource = new AllottedResource();
1745 .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
1746 allottedResource.setModelInvariantUUID(
1747 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
1749 .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
1751 .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
1752 allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
1753 allottedResource.setSubcategory(
1754 testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
1756 .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
1757 return allottedResource;
1760 protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
1761 // Scan the payload downloadResult and extract the HeatTemplate
1763 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
1764 return yamlEditor.getParameterList(artifactUUID);
1767 protected String testNull(Object object) {
1769 if (object == null) {
1771 } else if (object.equals("NULL")) {
1773 } else if (object instanceof Integer) {
1774 return object.toString();
1775 } else if (object instanceof String) {
1776 return (String) object;
1778 return "Type not recognized";
1782 protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
1783 VfModuleArtifact heatNestedArtifact) {
1785 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
1786 .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
1787 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
1788 .getArtifactInfo().getRelatedArtifacts()) {
1789 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1790 return ASDCConfiguration.HEAT;
1796 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
1797 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
1798 .getRelatedArtifacts() != null) {
1799 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
1800 .get(0).getArtifactInfo().getRelatedArtifacts()) {
1801 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
1802 return ASDCConfiguration.HEAT_VOL;
1808 // Does not belong to anything
1813 protected static String createVNFName(VfResourceStructure vfResourceStructure) {
1815 return vfResourceStructure.getNotification().getServiceName() + "/"
1816 + vfResourceStructure.getResourceInstance().getResourceInstanceName();
1819 protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
1821 return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
1822 + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
1826 protected static Timestamp getCurrentTimeStamp() {
1828 return new Timestamp(new Date().getTime());