2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.asdc.installer.heat;
24 import java.util.ArrayList;
25 import java.util.List;
28 import org.hibernate.exception.ConstraintViolationException;
29 import org.hibernate.exception.LockAcquisitionException;
31 import org.openecomp.sdc.api.notification.IArtifactInfo;
32 import org.openecomp.mso.asdc.client.ASDCConfiguration;
33 import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
34 import org.openecomp.mso.asdc.installer.ASDCElementInfo;
35 import org.openecomp.mso.asdc.installer.BigDecimalVersion;
36 import org.openecomp.mso.asdc.installer.IVfResourceInstaller;
37 import org.openecomp.mso.asdc.installer.VfModuleArtifact;
38 import org.openecomp.mso.asdc.installer.VfModuleStructure;
39 import org.openecomp.mso.asdc.installer.VfResourceStructure;
40 import org.openecomp.mso.asdc.util.YamlEditor;
41 import org.openecomp.mso.db.catalog.CatalogDatabase;
42 import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
43 import org.openecomp.mso.db.catalog.beans.HeatFiles;
44 import org.openecomp.mso.db.catalog.beans.HeatTemplate;
45 import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
46 import org.openecomp.mso.db.catalog.beans.Service;
47 import org.openecomp.mso.db.catalog.beans.VfModule;
48 import org.openecomp.mso.db.catalog.beans.VnfResource;
49 import org.openecomp.mso.logger.MessageEnum;
50 import org.openecomp.mso.logger.MsoLogger;
52 public class VfResourceInstaller implements IVfResourceInstaller {
54 private MsoLogger logger;
56 public VfResourceInstaller() {
57 logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC);
61 public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStructure)
62 throws ArtifactInstallerException {
63 boolean status = false;
65 try (CatalogDatabase db = new CatalogDatabase()) {
67 logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "VNFResource",
68 VfResourceInstaller.createVNFName(vfResourceStructure),
69 BigDecimalVersion.castAndCheckNotificationVersionToString(
70 vfResourceStructure.getNotification().getServiceVersion()), "", "");
72 VnfResource vnfResource = db.getVnfResource(
73 VfResourceInstaller.createVNFName(vfResourceStructure),
74 BigDecimalVersion.castAndCheckNotificationVersionToString(
75 vfResourceStructure.getNotification().getServiceVersion()));
77 if (vnfResource != null) {
83 logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL,
84 vfResourceStructure.getResourceInstance().getResourceInstanceName(),
85 vfResourceStructure.getResourceInstance().getResourceUUID(),
86 vfResourceStructure.getNotification().getServiceName(),
87 BigDecimalVersion.castAndCheckNotificationVersionToString(
88 vfResourceStructure.getNotification().getServiceVersion()),
89 vfResourceStructure.getNotification().getServiceUUID(),
90 vfResourceStructure.getResourceInstance().getResourceName(), "", "");
92 logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL,
93 vfResourceStructure.getResourceInstance().getResourceInstanceName(),
94 vfResourceStructure.getResourceInstance().getResourceUUID(),
95 vfResourceStructure.getNotification().getServiceName(),
96 BigDecimalVersion.castAndCheckNotificationVersionToString(
97 vfResourceStructure.getNotification().getServiceVersion()),
98 vfResourceStructure.getNotification().getServiceUUID(),
99 vfResourceStructure.getResourceInstance().getResourceName(),"", "");
104 } catch (Exception e) {
105 logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed");
106 throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
111 public void installTheResource(VfResourceStructure vfResourceStructure) throws ArtifactInstallerException {
113 // 1. Add the DB object list (Hashed) to be created from the HashMap
115 // The DB objects will be stored in each VfModuleArtifact objects
116 // Those objects could be reused by different VfModule
118 for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
120 switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
121 case ASDCConfiguration.HEAT:
122 case ASDCConfiguration.HEAT_VOL:
123 case ASDCConfiguration.HEAT_NESTED:
124 VfResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, vfModuleArtifact);
126 case ASDCConfiguration.HEAT_ENV:
127 VfResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
129 case ASDCConfiguration.HEAT_ARTIFACT:
130 VfResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact);
132 case ASDCConfiguration.HEAT_NET:
133 case ASDCConfiguration.OTHER:
134 logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
142 // in case of deployment failure, use a string that will represent the type of artifact that failed...
143 List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
145 CatalogDatabase catalogDB = new CatalogDatabase();
146 // 2. Create the VFModules/VNFResource objects by linking them to the
147 // objects created before and store them in Resource/module structure
148 // Opening a DB transaction, starting from here
151 VfResourceInstaller.createService(vfResourceStructure);
153 VfResourceInstaller.createVnfResource(vfResourceStructure);
155 // Add this one for logging
156 artifactListForLogging.add(ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure));
158 catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource());
159 catalogDB.saveService(vfResourceStructure.getCatalogService());
161 for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
163 // Here we set the right db structure according to the Catalog
166 // We expect only one MAIN HEAT per VFMODULE
167 // we can also obtain from it the Env ArtifactInfo, that's why
169 // get the Main IArtifactInfo
171 HeatTemplate heatMainTemplate = null;
172 HeatEnvironment heatEnv = null;
174 HeatTemplate heatVolumeTemplate = null;
175 HeatEnvironment heatVolumeEnv = null;
177 if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) {
178 IArtifactInfo mainEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT)
179 .get(0).getArtifactInfo().getGeneratedArtifact();
182 heatMainTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
183 .get(ASDCConfiguration.HEAT).get(0).getCatalogObject();
185 // Add this one for logging
186 artifactListForLogging.add(ASDCElementInfo
187 .createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo()));
189 catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters());
190 // Indicate we have deployed it in the DB
191 vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).incrementDeployedInDB();
195 // We expect only one VOL HEAT per VFMODULE
196 // we can also obtain from it the Env ArtifactInfo, that's why
197 // we get the Volume IArtifactInfo
199 if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) {
200 IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0)
201 .getArtifactInfo().getGeneratedArtifact();
203 heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
204 .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject();
206 // Add this one for logging
207 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()));
209 catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters());
210 // Indicate we have deployed it in the DB
211 vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB();
213 if (volEnvArtifactInfo != null) {
214 heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
215 .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
217 // Add this one for logging
218 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo));
220 catalogDB.saveHeatEnvironment(heatVolumeEnv);
221 // Indicate we have deployed it in the DB
222 vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
228 // Here we expect many HEAT_NESTED template to be there
229 // check first if we really have nested heat templates
230 if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) {
231 for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap()
232 .get(ASDCConfiguration.HEAT_NESTED)) {
234 // Check if this nested is well referenced by the MAIN HEAT
235 String parentArtifactType = VfResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact);
236 HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject();
238 if (parentArtifactType != null) {
240 switch (parentArtifactType) {
241 case ASDCConfiguration.HEAT:
243 // Add this one for logging
244 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
246 catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
247 // Indicate we have deployed it in the DB
248 heatNestedArtifact.incrementDeployedInDB();
250 case ASDCConfiguration.HEAT_VOL:
252 // Add this one for logging
253 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
254 catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
255 // Indicate we have deployed it in the DB
256 heatNestedArtifact.incrementDeployedInDB();
263 } else { // Assume it belongs to HEAT MAIN
264 // Add this one for logging
265 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
267 catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
268 // Indicate we have deployed it in the DB
269 heatNestedArtifact.incrementDeployedInDB();
274 if (mainEnvArtifactInfo != null) {
275 heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
276 .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
278 // Add this one for logging
279 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo));
281 catalogDB.saveHeatEnvironment(heatEnv);
282 // Indicate we have deployed it in the DB
283 vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
289 // here we expect one VFModule to be there
290 VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
291 VfModule vfModule = vfModuleStructure.getCatalogVfModule();
293 // Add this one for logging
294 artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure));
296 catalogDB.saveOrUpdateVfModule(vfModule);
298 // Here we expect many HEAT_TEMPLATE files to be there
299 if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) {
300 for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap()
301 .get(ASDCConfiguration.HEAT_ARTIFACT)) {
303 HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject();
305 // Add this one for logging
306 artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo()));
309 catalogDB.saveVfModuleToHeatFiles (vfModule.getId(), heatFile);
310 // Indicate we will deploy it in the DB
311 heatArtifact.incrementDeployedInDB();
318 vfResourceStructure.setSuccessfulDeployment();
320 } catch (Exception e) {
322 Throwable dbExceptionToCapture = e;
323 while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException)
324 && (dbExceptionToCapture.getCause() != null)) {
325 dbExceptionToCapture = dbExceptionToCapture.getCause();
328 if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) {
329 logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(),
330 vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
332 String endEvent = "Exception caught during installation of the VFResource. Transaction rollback.";
333 String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
334 logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of the VFResource. Transaction rollback", e);
335 catalogDB.rollback();
336 throw new ArtifactInstallerException(
337 "Exception caught during installation of the VFResource. Transaction rollback.", e);
342 // Debug log the whole collection...
343 logger.debug(artifactListForLogging.toString());
348 private static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,VfModuleArtifact heatNestedArtifact) {
350 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null
351 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
352 for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
353 .getArtifactInfo().getRelatedArtifacts()) {
354 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
355 return ASDCConfiguration.HEAT;
361 if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
362 && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
363 for (IArtifactInfo unknownArtifact:vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts()) {
364 if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
365 return ASDCConfiguration.HEAT_VOL;
371 // Does not belong to anything
376 private static void createVnfResource(VfResourceStructure vfResourceStructure) {
377 VnfResource vnfResource = new VnfResource();
379 vnfResource.setAsdcUuid(vfResourceStructure.getResourceInstance().getResourceUUID());
380 vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription());
382 vnfResource.setOrchestrationMode("HEAT");
383 // Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION
384 vnfResource.setVersion(BigDecimalVersion
385 .castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion()));
386 vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure));
387 vnfResource.setModelVersion(BigDecimalVersion
388 .castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion()));
390 vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID());
391 vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName());
392 vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName());
393 vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
395 vfResourceStructure.setCatalogVnfResource(vnfResource);
398 private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
399 VfModule vfModule = new VfModule();
400 vfModule.setType(createVfModuleName(vfModuleStructure));
401 vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID());
402 vfModule.setDescription(vfModuleStructure.getVfModuleMetadata().getVfModuleModelDescription());
404 if (vfModuleStructure.getVfModuleMetadata().isBase()) {
405 vfModule.setIsBase(1);
407 vfModule.setIsBase(0);
410 vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID());
411 vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName());
413 vfModule.setVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(vfModuleStructure.getParentVfResource().getNotification().getServiceVersion()));
414 vfModule.setModelVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(
415 vfModuleStructure.getVfModuleMetadata().getVfModuleModelVersion()));
417 vfModuleStructure.setCatalogVfModule(vfModule);
419 VfResourceInstaller.createVfModuleLinks(vfModule, vfModuleStructure.getParentVfResource().getCatalogVnfResource(), heatMain,heatVolume, heatEnv,heatVolumeEnv);
422 private static void createVfModuleLinks(VfModule vfModule, VnfResource vnfResource, HeatTemplate heatMain,
423 HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) {
425 if (heatMain !=null) {
426 vfModule.setTemplateId(heatMain.getId());
428 if (heatEnv != null) {
429 vfModule.setEnvironmentId(heatEnv.getId());
431 if (heatVolume != null) {
432 vfModule.setVolTemplateId(heatVolume.getId());
434 if (heatVolumeEnv != null) {
435 vfModule.setVolEnvironmentId(heatVolumeEnv.getId());
438 vfModule.setVnfResourceId(vnfResource.getId());
442 private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile) {
444 // Scan the payload downloadResult and extract the HeatTemplate
446 YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
447 return yamlEditor.getParameterList();
452 public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List<String> listTypes) {
453 String newFileBody = filebody;
454 for (VfModuleArtifact moduleArtifact:vfResourceStructure.getArtifactsMapByUUID().values()) {
456 if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
458 newFileBody = verifyTheFilePrefixInString(newFileBody,moduleArtifact.getArtifactInfo().getArtifactName());
464 public static String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
466 String needlePrefix = "file:///";
467 String prefixedFilenameToVerify = needlePrefix+filenameToVerify;
469 if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
473 StringBuffer sb = new StringBuffer(body.length());
475 int currentIndex = 0;
478 while (currentIndex != -1) {
479 startIndex = currentIndex;
480 currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
482 if (currentIndex == -1) {
486 // We append from the startIndex up to currentIndex (start of File Name)
487 sb.append(body.substring(startIndex, currentIndex));
488 sb.append(filenameToVerify);
490 currentIndex += prefixedFilenameToVerify.length();
493 sb.append(body.substring(startIndex));
495 return sb.toString();
498 private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
499 VfModuleArtifact vfModuleArtifact) {
500 HeatTemplate heatTemplate = new HeatTemplate();
502 // TODO Set the label
503 heatTemplate.setAsdcLabel("label");
504 // Use the ResourceName of the ASDC template because the HEAT could be
506 heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
507 heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
509 List<String> typeList = new ArrayList<String>();
510 typeList.add(ASDCConfiguration.HEAT_NESTED);
511 typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
513 heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
514 heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
516 if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
517 heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
519 heatTemplate.setTimeoutMinutes(240);
522 heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
523 heatTemplate.setVersion(BigDecimalVersion
524 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
525 Set<HeatTemplateParam> heatParam = VfResourceInstaller
526 .extractHeatTemplateParameters(vfModuleArtifact.getResult());
527 heatTemplate.setParameters(heatParam);
529 vfModuleArtifact.setCatalogObject(heatTemplate);
532 private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
533 VfModuleArtifact vfModuleArtifact) {
534 HeatEnvironment heatEnvironment = new HeatEnvironment();
536 heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
537 // TODO Set the label
538 heatEnvironment.setAsdcLabel("Label");
540 List<String> typeList = new ArrayList<String>();
541 typeList.add(ASDCConfiguration.HEAT);
542 typeList.add(ASDCConfiguration.HEAT_VOL);
544 heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
545 heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
546 heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
547 heatEnvironment.setVersion(BigDecimalVersion
548 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
549 heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
551 vfModuleArtifact.setCatalogObject(heatEnvironment);
555 private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
556 VfModuleArtifact vfModuleArtifact) {
558 HeatFiles heatFile = new HeatFiles();
559 // TODO Set the label
560 heatFile.setAsdcLabel("Label");
561 heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
562 heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
563 heatFile.setFileBody(vfModuleArtifact.getResult());
564 heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
565 heatFile.setVersion(BigDecimalVersion
566 .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
568 heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
569 vfModuleArtifact.setCatalogObject(heatFile);
573 private static void createService(VfResourceStructure vfResourceStructure) {
575 Service service = new Service();
576 service.setDescription(vfResourceStructure.getNotification().getServiceDescription());
577 service.setServiceName(vfResourceStructure.getNotification().getServiceName());
578 service.setServiceNameVersionId(vfResourceStructure.getNotification().getServiceUUID());
579 service.setVersion(vfResourceStructure.getNotification().getServiceVersion());
580 service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID());
582 vfResourceStructure.setCatalogService(service);
586 private static String createVNFName(VfResourceStructure vfResourceStructure) {
588 return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName();
591 private static String createVfModuleName(VfModuleStructure vfModuleStructure) {
593 return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();