diff options
Diffstat (limited to 'asdc-controller/src/main/java/org/openecomp/mso/asdc/installer')
12 files changed, 0 insertions, 3520 deletions
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java deleted file mode 100644 index b6e130820a..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.IResourceInstance; -import org.openecomp.mso.asdc.client.ASDCConfiguration; - -/** - * A class representing a generic element whose information can be used for example to log artifacts, resource... data. - */ -public class ASDCElementInfo { - - /** - * A default, empty instance used in case a source element was not correctly provided. - */ - public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo(); - - /** - * Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/> - * <br/> - * Possible types allowed:<br/> - * <ul> - * <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li> - * <ul> - */ - public static enum ASDCElementTypeEnum { - /** - * The type VNF_RESOURCE. Represents a VNF_RESOURCE element. - */ - VNF_RESOURCE - }; - - /** - * The map of element information fields useful for logging. The complete contents of this list will be concatenated. - */ - private final Map<String, String> elementInfoMap = new HashMap<>(); - - /** - * The type of this element. - */ - private final String type; - - private ASDCElementInfo () { - // Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE. - this.type = ""; - } - - /** - * Artifact-type based constructor. Requires a valid artifact type. - * @param artifactType The artifact type - */ - private ASDCElementInfo (String artifactType) { - // We need the exact type name here... - this.type = artifactType; - } - - /** - * 'Other element type'-based constructor. Requires a valid element type. - * @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing - */ - private ASDCElementInfo (ASDCElementTypeEnum elementType) { - // We need the exact type name here... - this.type = elementType.name(); - } - - /** - * Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time. - * - * @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.) - * @param value The value bound to the information entry. - */ - public final void addElementInfo(String key, String value) { - if ((key != null) && (value != null)) { - this.getElementInfoMap().put(key, value); - } - } - - /** - * Returns an aggregated, formatted list of the expected details about an ASDC element. - * (non-Javadoc) - * @return An aggregated list of element information entries, comma-separated. - * @see java.lang.Object#toString() - */ - @Override - public final String toString() { - StringBuilder sb = new StringBuilder(); - List<String> aggregatedElements = new ArrayList<>(); - for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) { - aggregatedElements.add(entry.getKey() + ": " + entry.getValue()); - } - sb.append(aggregatedElements.size() > 0 ? aggregatedElements.get(0) : ""); - if (aggregatedElements.size() > 1) { - for (int i = 1; i < aggregatedElements.size(); ++i) { - sb.append (", "); - sb.append(aggregatedElements.get(i)); - } - } - return sb.toString(); - } - - /** - * The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc. - * @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or an ASDCElementTypeEnum entry name. - * @see ASDCElementInfo.ASDCElementTypeEnum - */ - public String getType() { - return type; - } - - /** - * Provides the map of all element information entries for this type. - * @return A map of all element information entries which will be used by the toString() method. - * @see ASDCElementInfo#toString() - */ - protected Map<String, String> getElementInfoMap() { - return elementInfoMap; - } - - /** - * Create an ASDCElementInfo object from a VNF Resource.<br/> - * <br/> - * <b>Used information:</b><br/> - * <ul> - * <li>Resource Instance Name</li> - * <li>Resource Instance UUID</li> - * </ul> - * - * @param vfResourceStructure The VfResourceStructure to use as source of information (see {@link VfResourceStructure}). - * @return an ASDCElementInfo using the information held in the VNF Resource. - */ - public static final ASDCElementInfo createElementFromVfResourceStructure (VfResourceStructure vfResourceStructure) { - if (vfResourceStructure == null) { - return EMPTY_INSTANCE; - } - ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCElementTypeEnum.VNF_RESOURCE); - IResourceInstance resourceInstance = vfResourceStructure.getResourceInstance(); - elementInfo.addElementInfo("Resource Instance Name", resourceInstance.getResourceInstanceName()); - elementInfo.addElementInfo("Resource Instance Invariant UUID", resourceInstance.getResourceInvariantUUID()); - return elementInfo; - } - - /** - * Create an ASDCElementInfo object from a VF Module.<br/> - * <br/> - * <b>Used information:</b><br/> - * <ul> - * <li>Module Model Name</li> - * <li>Module Model UUID</li> - * </ul> - * - * @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}). - * @return an ASDCElementInfo using the information held in the VF Module. - */ - public static final ASDCElementInfo createElementFromVfModuleStructure (VfModuleStructure vfModuleStructure) { - if (vfModuleStructure == null) { - return EMPTY_INSTANCE; - } - ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA); - IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata(); - elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName()); - elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID()); - return elementInfo; - } - - /** - * Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/> - * <br/> - * <b>Used information:</b><br/> - * <ul> - * <li>IArtifactInfo Name</li> - * <li>IArtifactInfo UUID</li> - * </ul> - * - * @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}). - * @return an ASDCElementInfo using the information held in the IArtifactInfo instance. - */ - public static final ASDCElementInfo createElementFromVfArtifactInfo (IArtifactInfo artifactInfo) { - if (artifactInfo == null) { - return EMPTY_INSTANCE; - } - ASDCElementInfo elementInfo = new ASDCElementInfo(artifactInfo.getArtifactType()); - elementInfo.addElementInfo(elementInfo.getType() + " Name", artifactInfo.getArtifactName()); - elementInfo.addElementInfo(elementInfo.getType() + " UUID", artifactInfo.getArtifactUUID()); - return elementInfo; - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java deleted file mode 100644 index c2faf1c0e8..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - - -import java.math.BigDecimal; - -public class BigDecimalVersion { - - /** - * This method truncates and convert the version String provided in the notification. - * - * @param version The version to check - * @return A BigDecimal value checked and truncated - */ - public static BigDecimal castAndCheckNotificationVersion(String version) { - // Truncate the version if bad type - String[] splitVersion = version.split("\\."); - StringBuilder newVersion = new StringBuilder(); - if (splitVersion.length > 1) { - newVersion.append(splitVersion[0]); - newVersion.append("."); - newVersion.append(splitVersion[1]); - } else { - return new BigDecimal(splitVersion[0]); - } - - for (int i=2;i<splitVersion.length;i++) { - newVersion.append(splitVersion[i]); - } - - return new BigDecimal(newVersion.toString()); - } - - /** - * This method truncates and convert the version String provided in the notification. - * - * @param version The version to check - * @return A String value checked and truncated to Decimal format - */ - public static String castAndCheckNotificationVersionToString (String version) { - return castAndCheckNotificationVersion(version).toString(); - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java deleted file mode 100644 index 60519f226d..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - - - -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IResourceInstance; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; - -public interface IArtifactOrchestrator { - - void installTheArtifact (INotificationData iNotif, IResourceInstance resource, IArtifactInfo artifact, IDistributionClientDownloadResult downloadResult) throws ArtifactInstallerException; - - boolean isArtifactAlreadyDeployed (INotificationData iNotif,IResourceInstance resource,IArtifactInfo artifact) throws ArtifactInstallerException; - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java deleted file mode 100644 index 1e24b59035..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfModuleData.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - -import java.util.Map; - - -public interface IVfModuleData { - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelName(); - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelInvariantUUID(); - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelCustomizationUUID(); - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelVersion(); - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelUUID(); - - // Method descriptor #4 ()Ljava/lang/String; - public abstract java.lang.String getVfModuleModelDescription(); - - // Method descriptor #10 ()Z - public abstract boolean isBase(); - - // Method descriptor #12 ()Ljava/util/List; - // Signature: ()Ljava/util/List<Ljava/lang/String;>; - public abstract java.util.List<String> getArtifacts(); - - public abstract java.util.Map<String,String> getProperties(); -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java deleted file mode 100644 index 128239cf75..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - - - -import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; - -public interface IVfResourceInstaller { - - boolean isResourceAlreadyDeployed (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException; - - public void installTheResource (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException; -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java deleted file mode 100644 index 941787efe4..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java +++ /dev/null @@ -1,537 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.asdc.installer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-
-import java.util.List;
-
-import org.onap.sdc.api.notification.IArtifactInfo;
-import org.onap.sdc.api.notification.INotificationData;
-//import org.openecomp.generic.tosca.parser.model.Metadata;
-//import org.onap.sdc.tosca.parser.factory.SdcCsarHelperFactory;
-//import org.onap.sdc.tosca.parser.factory.SdcCsarHelperFactory;
-///import org.openecomp.generic.tosca.parser.model.Metadata;
-import org.onap.sdc.api.results.IDistributionClientDownloadResult;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-
-
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-
-
-
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException;
-import org.openecomp.mso.db.catalog.beans.AllottedResource;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
-import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class ToscaResourceStructure {
-
- Metadata serviceMetadata;
- private Service catalogService;
- ISdcCsarHelper sdcCsarHelper;
- List<NodeTemplate> allottedList;
- List<NodeTemplate> networkTypes;
- List<NodeTemplate> vfTypes;
- String heatTemplateUUID;
- String volHeatTemplateUUID;
- String volHeatEnvTemplateUUID;
- String envHeatTemplateUUID;
- String heatFilesUUID;
- String workloadPerformance;
- boolean isVnfAlreadyInstalled = false;
- String serviceVersion;
- private boolean isDeployedSuccessfully=false;
-
-
- private NetworkResourceCustomization catalogNetworkResourceCustomization;
-
- private NetworkResource catalogNetworkResource;
-
- private AllottedResourceCustomization catalogResourceCustomization;
-
- private VfModule vfModule;
-
- private VfModuleCustomization vfModuleCustomization;
-
- private VnfResource vnfResource;
-
- private VnfResourceCustomization vnfResourceCustomization;
-
- private ServiceToResourceCustomization serviceToResourceCustomization;
-
- private AllottedResource allottedResource;
-
- private AllottedResourceCustomization allottedResourceCustomization;
-
- private VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom;
-
- private TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup;
-
- private VfModuleToHeatFiles vfModuleToHeatFiles;
-
- private IArtifactInfo toscaArtifact;
-
- private ToscaCsar toscaCsar;
-
- private ServiceToResourceCustomization vfServiceToResourceCustomization;
-
- private ServiceToResourceCustomization allottedServiceToResourceCustomization;
-
- private ServiceToResourceCustomization vlServiceToResourceCustomization;
-
- protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
-
-
- public ToscaResourceStructure(){
- }
-
- public void updateResourceStructure(IArtifactInfo artifact) throws ASDCDownloadException {
-
-
- try {
-
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable
-
- LOGGER.debug("MSO config path is: " + System.getProperty("mso.config.path"));
-
- File spoolFile = new File(System.getProperty("mso.config.path") + "ASDC/" + artifact.getArtifactName());
-
- LOGGER.debug("ASDC File path is: " + spoolFile.getAbsolutePath());
- LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath());
-
-
- sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
-
- }catch(Exception e){
- System.out.println("System out " + e.getMessage());
- LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG,
- "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e);
-
- throw new ASDCDownloadException ("Exception caught when passing the csar file to the parser ", e);
- }
-
- serviceMetadata = sdcCsarHelper.getServiceMetadata();
-
- }
-
- public String getHeatTemplateUUID() {
- return heatTemplateUUID;
- }
-
- public void setHeatTemplateUUID(String heatTemplateUUID) {
- this.heatTemplateUUID = heatTemplateUUID;
- }
-
- public List<NodeTemplate> getAllottedList() {
- return allottedList;
- }
-
- public void setAllottedList(List<NodeTemplate> allottedList) {
- this.allottedList = allottedList;
- }
-
- public ISdcCsarHelper getSdcCsarHelper() {
- return sdcCsarHelper;
- }
-
- public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) {
- this.sdcCsarHelper = sdcCsarHelper;
- }
-
- public Metadata getServiceMetadata() {
- return serviceMetadata;
- }
-
- public Service getCatalogService() {
- return catalogService;
- }
-
- public void setServiceMetadata(Metadata serviceMetadata) {
- this.serviceMetadata = serviceMetadata;
- }
-
- public void setCatalogService(Service catalogService) {
- this.catalogService = catalogService;
- }
-
- public List<NodeTemplate> getNetworkTypes() {
- return networkTypes;
- }
-
- public void setNetworkTypes(List<NodeTemplate> networkTypes) {
- this.networkTypes = networkTypes;
- }
-
- public List<NodeTemplate> getVfTypes() {
- return vfTypes;
- }
-
- public void setVfTypes(List<NodeTemplate> vfTypes) {
- this.vfTypes = vfTypes;
- }
-
- public AllottedResourceCustomization getCatalogResourceCustomization() {
- return catalogResourceCustomization;
- }
-
- public void setCatalogResourceCustomization(
- AllottedResourceCustomization catalogResourceCustomization) {
- this.catalogResourceCustomization = catalogResourceCustomization;
- }
-
- // Network Only
- public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
- return catalogNetworkResourceCustomization;
- }
- // Network Only
- public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) {
- this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
- }
-
- public NetworkResource getCatalogNetworkResource() {
- return catalogNetworkResource;
- }
-
- public void setCatalogNetworkResource(NetworkResource catalogNetworkResource) {
- this.catalogNetworkResource = catalogNetworkResource;
- }
-
- public VfModule getCatalogVfModule() {
- return vfModule;
- }
-
- public void setCatalogVfModule(VfModule vfModule) {
- this.vfModule = vfModule;
- }
-
- public VnfResource getCatalogVnfResource() {
- return vnfResource;
- }
-
- public void setCatalogVnfResource(VnfResource vnfResource) {
- this.vnfResource = vnfResource;
- }
-
- public VnfResourceCustomization getCatalogVnfResourceCustomization() {
- return vnfResourceCustomization;
- }
-
- public void setCatalogVnfResourceCustomization(
- VnfResourceCustomization vnfResourceCustomization) {
- this.vnfResourceCustomization = vnfResourceCustomization;
- }
-
- public VfModuleCustomization getCatalogVfModuleCustomization() {
- return vfModuleCustomization;
- }
-
- public void setCatalogVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
- this.vfModuleCustomization = vfModuleCustomization;
- }
-
- public ServiceToResourceCustomization getServiceToResourceCustomization() {
- return serviceToResourceCustomization;
- }
-
- public void setServiceToResourceCustomization(
- ServiceToResourceCustomization serviceToResourceCustomization) {
- this.serviceToResourceCustomization = serviceToResourceCustomization;
- }
-
- public AllottedResource getAllottedResource() {
- return allottedResource;
- }
-
- public void setAllottedResource(AllottedResource allottedResource) {
- this.allottedResource = allottedResource;
- }
-
- public AllottedResourceCustomization getCatalogAllottedResourceCustomization() {
- return allottedResourceCustomization;
- }
-
- public void setCatalogAllottedResourceCustomization(
- AllottedResourceCustomization allottedResourceCustomization) {
- this.allottedResourceCustomization = allottedResourceCustomization;
- }
-
- public VnfResCustomToVfModuleCustom getCatalogVnfResCustomToVfModuleCustom() {
- return vnfResCustomToVfModuleCustom;
- }
-
- public void setCatalogVnfResCustomToVfModuleCustom(
- VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom) {
- this.vnfResCustomToVfModuleCustom = vnfResCustomToVfModuleCustom;
- }
-
- public TempNetworkHeatTemplateLookup getCatalogTempNetworkHeatTemplateLookup() {
- return tempNetworkHeatTemplateLookup;
- }
-
- public void setCatalogTempNetworkHeatTemplateLookup(
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
- this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
- }
-
- public String getHeatFilesUUID() {
- return heatFilesUUID;
- }
-
- public void setHeatFilesUUID(String heatFilesUUID) {
- this.heatFilesUUID = heatFilesUUID;
- }
-
- public VfModuleToHeatFiles getCatalogVfModuleToHeatFiles() {
- return vfModuleToHeatFiles;
- }
-
- public void setCatalogVfModuleToHeatFiles(VfModuleToHeatFiles vfModuleToHeatFiles) {
- this.vfModuleToHeatFiles = vfModuleToHeatFiles;
- }
-
- public IArtifactInfo getToscaArtifact() {
- return toscaArtifact;
- }
-
- public void setToscaArtifact(IArtifactInfo toscaArtifact) {
- this.toscaArtifact = toscaArtifact;
- }
-
- public ToscaCsar getCatalogToscaCsar() {
- return toscaCsar;
- }
-
- public void setCatalogToscaCsar(ToscaCsar toscaCsar) {
- this.toscaCsar = toscaCsar;
- }
-
- public boolean isVnfAlreadyInstalled() {
- return isVnfAlreadyInstalled;
- }
-
- public void setVnfAlreadyInstalled(boolean isVnfAlreadyInstalled) {
- this.isVnfAlreadyInstalled = isVnfAlreadyInstalled;
- }
-
- public ServiceToResourceCustomization getCatalogVfServiceToResourceCustomization() {
- return vfServiceToResourceCustomization;
- }
-
- public void setCatalogVfServiceToResourceCustomization(
- ServiceToResourceCustomization vfServiceToResourceCustomization) {
- this.vfServiceToResourceCustomization = vfServiceToResourceCustomization;
- }
-
- public ServiceToResourceCustomization getCatalogAllottedServiceToResourceCustomization() {
- return allottedServiceToResourceCustomization;
- }
-
- public void setCatalogAllottedServiceToResourceCustomization(
- ServiceToResourceCustomization allottedServiceToResourceCustomization) {
- this.allottedServiceToResourceCustomization = allottedServiceToResourceCustomization;
- }
-
- public ServiceToResourceCustomization getCatalogVlServiceToResourceCustomization() {
- return vlServiceToResourceCustomization;
- }
-
- public void setCatalogVlServiceToResourceCustomization(
- ServiceToResourceCustomization vlServiceToResourceCustomization) {
- this.vlServiceToResourceCustomization = vlServiceToResourceCustomization;
- }
-
- public String getVolHeatTemplateUUID() {
- return volHeatTemplateUUID;
- }
-
- public void setVolHeatTemplateUUID(String volHeatTemplateUUID) {
- this.volHeatTemplateUUID = volHeatTemplateUUID;
- }
-
- public String getEnvHeatTemplateUUID() {
- return envHeatTemplateUUID;
- }
-
- public void setEnvHeatTemplateUUID(String envHeatTemplateUUID) {
- this.envHeatTemplateUUID = envHeatTemplateUUID;
- }
-
- public String getVolHeatEnvTemplateUUID() {
- return volHeatEnvTemplateUUID;
- }
-
- public void setVolHeatEnvTemplateUUID(String volHeatEnvTemplateUUID) {
- this.volHeatEnvTemplateUUID = volHeatEnvTemplateUUID;
- }
-
- public String getServiceVersion() {
- return serviceVersion;
- }
-
- public void setServiceVersion(String serviceVersion) {
- this.serviceVersion = serviceVersion;
- }
-
- public String getWorkloadPerformance() {
- return workloadPerformance;
- }
-
- public void setWorkloadPerformance(String workloadPerformance) {
- this.workloadPerformance = workloadPerformance;
- }
-
- public VfModule getVfModule() {
- return vfModule;
- }
-
- public void setVfModule(VfModule vfModule) {
- this.vfModule = vfModule;
- }
-
- public VfModuleCustomization getVfModuleCustomization() {
- return vfModuleCustomization;
- }
-
- public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
- this.vfModuleCustomization = vfModuleCustomization;
- }
-
- public VnfResource getVnfResource() {
- return vnfResource;
- }
-
- public void setVnfResource(VnfResource vnfResource) {
- this.vnfResource = vnfResource;
- }
-
- public VnfResourceCustomization getVnfResourceCustomization() {
- return vnfResourceCustomization;
- }
-
- public void setVnfResourceCustomization(
- VnfResourceCustomization vnfResourceCustomization) {
- this.vnfResourceCustomization = vnfResourceCustomization;
- }
-
- public AllottedResourceCustomization getAllottedResourceCustomization() {
- return allottedResourceCustomization;
- }
-
- public void setAllottedResourceCustomization(
- AllottedResourceCustomization allottedResourceCustomization) {
- this.allottedResourceCustomization = allottedResourceCustomization;
- }
-
- public VnfResCustomToVfModuleCustom getVnfResCustomToVfModuleCustom() {
- return vnfResCustomToVfModuleCustom;
- }
-
- public void setVnfResCustomToVfModuleCustom(
- VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom) {
- this.vnfResCustomToVfModuleCustom = vnfResCustomToVfModuleCustom;
- }
-
- public TempNetworkHeatTemplateLookup getTempNetworkHeatTemplateLookup() {
- return tempNetworkHeatTemplateLookup;
- }
-
- public void setTempNetworkHeatTemplateLookup(
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
- this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
- }
-
- public VfModuleToHeatFiles getVfModuleToHeatFiles() {
- return vfModuleToHeatFiles;
- }
-
- public void setVfModuleToHeatFiles(VfModuleToHeatFiles vfModuleToHeatFiles) {
- this.vfModuleToHeatFiles = vfModuleToHeatFiles;
- }
-
- public ToscaCsar getToscaCsar() {
- return toscaCsar;
- }
-
- public void setToscaCsar(ToscaCsar toscaCsar) {
- this.toscaCsar = toscaCsar;
- }
-
- public ServiceToResourceCustomization getVfServiceToResourceCustomization() {
- return vfServiceToResourceCustomization;
- }
-
- public void setVfServiceToResourceCustomization(
- ServiceToResourceCustomization vfServiceToResourceCustomization) {
- this.vfServiceToResourceCustomization = vfServiceToResourceCustomization;
- }
-
- public ServiceToResourceCustomization getAllottedServiceToResourceCustomization() {
- return allottedServiceToResourceCustomization;
- }
-
- public void setAllottedServiceToResourceCustomization(
- ServiceToResourceCustomization allottedServiceToResourceCustomization) {
- this.allottedServiceToResourceCustomization = allottedServiceToResourceCustomization;
- }
-
- public ServiceToResourceCustomization getVlServiceToResourceCustomization() {
- return vlServiceToResourceCustomization;
- }
-
- public void setVlServiceToResourceCustomization(
- ServiceToResourceCustomization vlServiceToResourceCustomization) {
- this.vlServiceToResourceCustomization = vlServiceToResourceCustomization;
- }
-
- public static MsoLogger getLogger() {
- return LOGGER;
- }
-
- public boolean isDeployedSuccessfully() {
- return isDeployedSuccessfully;
- }
-
- public void setSuccessfulDeployment() {
- isDeployedSuccessfully = true;
- }
-
-}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java deleted file mode 100644 index c1f836904d..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - - -import java.io.UnsupportedEncodingException; - -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; - -/** - * The structure that contains the artifactInfo and its associated DownloadedResult. - * - */ -public final class VfModuleArtifact { - private final IArtifactInfo artifactInfo; - private int deployedInDb=0; - private final String result; - - private Object catalogObject; - - public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - artifactInfo=artifactinfo; - result = new String(clientResult.getArtifactPayload(), "UTF-8"); - - } - - public Object getCatalogObject() { - return catalogObject; - } - - public void setCatalogObject(Object catalogObject) { - this.catalogObject = catalogObject; - } - - public IArtifactInfo getArtifactInfo() { - return artifactInfo; - } - - public String getResult() { - return result; - } - - public int getDeployedInDb() { - return deployedInDb; - } - - public void incrementDeployedInDB() { - ++deployedInDb; - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java deleted file mode 100644 index 8ee5302003..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleMetaData.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class VfModuleMetaData implements IVfModuleData { - - @JsonProperty("artifacts") - private List<String> artifacts; - - @JsonProperty("properties") - //private List<Map<String, Object>> properties = new ArrayList<>(); - private Map<String,String> properties = new HashMap<>(); - - @JsonIgnore - private Map<String,Object> attributesMap = new HashMap<>(); - - @Override - public List<String> getArtifacts() { - return artifacts; - } - - public Map<String, String> getProperties() { - return properties; - } - - @Override - public String getVfModuleModelDescription() { - return (String)attributesMap.get("vfModuleModelDescription"); - } - - @Override - public String getVfModuleModelInvariantUUID() { - return (String)attributesMap.get("vfModuleModelInvariantUUID"); - } - - public String getVfModuleModelCustomizationUUID() { - return (String)attributesMap.get("vfModuleModelCustomizationUUID"); - } - - @Override - public String getVfModuleModelName() { - return (String)attributesMap.get("vfModuleModelName"); - } - - @Override - public String getVfModuleModelUUID() { - return (String)attributesMap.get("vfModuleModelUUID"); - } - - @Override - public String getVfModuleModelVersion() { - return (String)attributesMap.get("vfModuleModelVersion"); - } - - @Override - public boolean isBase() { - return (boolean)attributesMap.get("isBase"); - } - - - - @SuppressWarnings("unused") - @JsonAnySetter - public final void setAttribute(String attrName, Object attrValue) { - if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) { - this.attributesMap.put(attrName,attrValue); - } - } - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java deleted file mode 100644 index 2986a80b1f..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import org.onap.sdc.api.notification.IVfModuleMetadata; -import org.openecomp.mso.asdc.client.ASDCConfiguration; -import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; -import org.openecomp.mso.db.catalog.beans.VfModule; - -public final class VfModuleStructure { - - private final IVfModuleData vfModuleMetadata; - - private final VfResourceStructure parentVfResource; - - private VfModule catalogVfModule; - /** - * The list of artifact existing in this resource hashed by artifactType. - */ - private final Map<String, List<VfModuleArtifact>> artifactsMap; - - public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleData vfmoduleMetadata) throws ArtifactInstallerException { - - vfModuleMetadata = vfmoduleMetadata; - parentVfResource = vfParentResource; - - artifactsMap = new HashMap<>(); - - for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) { - if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) { - this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID)); - } else { - throw new ArtifactInstallerException("Artifact (UUID:"+artifactUUID+ ") referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment"); - } - } - } - - private void addToStructure(VfModuleArtifact vfModuleArtifact) { - - if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) { - artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact); - - } else { - List<VfModuleArtifact> nestedList = new LinkedList<>(); - nestedList.add(vfModuleArtifact); - - artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList); - } - } - - public List<VfModuleArtifact> getOrderedArtifactList() { - - List <VfModuleArtifact> artifactsList = new LinkedList<>(); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED))); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - return null; - } - - public IVfModuleData getVfModuleMetadata() { - return vfModuleMetadata; - } - - public VfResourceStructure getParentVfResource() { - return parentVfResource; - } - - public Map<String, List<VfModuleArtifact>> getArtifactsMap() { - return artifactsMap; - } - - - public VfModule getCatalogVfModule() { - return catalogVfModule; - } - - public void setCatalogVfModule(VfModule catalogVfModule) { - this.catalogVfModule = catalogVfModule; - } - - -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java deleted file mode 100644 index 10e936060d..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.openecomp.mso.asdc.client.ASDCConfiguration; -import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; -import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.logger.MsoLogger; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.notification.IResourceInstance; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.mso.logger.MessageEnum; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -/** - * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure). - * - */ -public final class VfResourceStructure { - - protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); - - private boolean isDeployedSuccessfully=false; - /** - * The Raw notification data. - */ - private final INotificationData notification; - - /** - * The resource we will try to deploy. - */ - private final IResourceInstance resourceInstance; - - /** - * The list of VfModules defined for this resource. - */ - private final List<VfModuleStructure> vfModulesStructureList; - - /** - * The list of VfModulesMetadata defined for this resource. - */ - private List<IVfModuleData> vfModulesMetadataList; - - private VnfResource catalogVnfResource; - - private NetworkResourceCustomization catalogNetworkResourceCustomization; - - private ServiceToNetworks catalogServiceToNetworks; - - private ServiceToAllottedResources catalogServiceToAllottedResources; - - private AllottedResourceCustomization catalogResourceCustomization; - - private Service catalogService; - - private List<String> vfArtifactUUIDList; - - /** - * The list of artifacts existing in this resource hashed by UUID. - */ - private final Map<String, VfModuleArtifact> artifactsMapByUUID; - - - public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { - notification=notificationdata; - resourceInstance=resourceinstance; - - - vfModulesStructureList = new LinkedList<>(); - artifactsMapByUUID = new HashMap<>(); - } - - //@Override - public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult); - - switch(artifactinfo.getArtifactType()) { - case ASDCConfiguration.HEAT: - case ASDCConfiguration.HEAT_ENV: - case ASDCConfiguration.HEAT_VOL: - case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported - case ASDCConfiguration.HEAT_ARTIFACT: - case ASDCConfiguration.HEAT_NET: - case ASDCConfiguration.OTHER: - artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); - break; - - case ASDCConfiguration.VF_MODULES_METADATA: - vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); - - for(IVfModuleData moduleData : vfModulesMetadataList){ - - } - - //vfArtifactUUIDList.add(artifactinfo.getArtifactUUID()); - //vfModulesMetadataList = distributionClient.decodeVfModuleArtifact(clientResult.getArtifactPayload()); - break; - - default: - break; - - } - } - - public void createVfModuleStructures() throws ArtifactInstallerException { - - //for vender tosca VNF there is no VFModule in VF - if (vfModulesMetadataList == null) { - LOGGER.info(MessageEnum.ASDC_GENERAL_INFO,"There is no VF mudules in the VF.", "ASDC", "createVfModuleStructures"); - return; - } - for (IVfModuleData vfModuleMeta:vfModulesMetadataList) { - vfModulesStructureList.add(new VfModuleStructure(this,vfModuleMeta)); - } - } - - public INotificationData getNotification() { - return notification; - } - - public IResourceInstance getResourceInstance() { - return resourceInstance; - } - - public List<VfModuleStructure> getVfModuleStructure() { - return vfModulesStructureList; - } - - public boolean isDeployedSuccessfully() { - return isDeployedSuccessfully; - } - - public void setSuccessfulDeployment() { - isDeployedSuccessfully = true; - } - - public Map<String, VfModuleArtifact> getArtifactsMapByUUID() { - return artifactsMapByUUID; - } - - public List<VfModuleStructure> getVfModulesStructureList() { - return vfModulesStructureList; - } - - public VnfResource getCatalogVnfResource() { - return catalogVnfResource; - } - - public void setCatalogVnfResource(VnfResource catalogVnfResource) { - this.catalogVnfResource = catalogVnfResource; - } - - // Network Only - public NetworkResourceCustomization getCatalogNetworkResourceCustomization() { - return catalogNetworkResourceCustomization; - } - // Network Only - public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) { - this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization; - } - // Network Only - public ServiceToNetworks getCatalogServiceToNetworks() { - return catalogServiceToNetworks; - } - // Network Only - public void setCatalogServiceToNetworks( - ServiceToNetworks catalogServiceToNetworks) { - this.catalogServiceToNetworks = catalogServiceToNetworks; - } - - public ServiceToAllottedResources getCatalogServiceToAllottedResources() { - return catalogServiceToAllottedResources; - } - - public void setCatalogServiceToAllottedResources( - ServiceToAllottedResources catalogServiceToAllottedResources) { - this.catalogServiceToAllottedResources = catalogServiceToAllottedResources; - } - - public AllottedResourceCustomization getCatalogResourceCustomization() { - return catalogResourceCustomization; - } - - public void setCatalogResourceCustomization( - AllottedResourceCustomization catalogResourceCustomization) { - this.catalogResourceCustomization = catalogResourceCustomization; - } - - public Service getCatalogService() { - return catalogService; - } - - public void setCatalogService(Service catalogService) { - this.catalogService = catalogService; - } - - public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) { - try { - List<IVfModuleData> listVFModuleMetaData = new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>(){}); - return listVFModuleMetaData; - - } catch (JsonParseException e) { - LOGGER.debug("JsonParseException : ",e); - } catch (JsonMappingException e) { - LOGGER.debug("JsonMappingException : ",e); - } catch (IOException e) { - LOGGER.debug("IOException : ",e); - } - return null; - } -} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java deleted file mode 100644 index 9d986d9df7..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java +++ /dev/null @@ -1,1272 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.asdc.installer.heat;
-
-import java.sql.SQLIntegrityConstraintViolationException;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.Comparator;
-
-import org.hibernate.exception.ConstraintViolationException;
-import org.hibernate.exception.LockAcquisitionException;
-import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
-//import org.openecomp.generic.tosca.parser.model.Metadata;
-//import org.openecomp.generic.tosca.parser.model.NodeTemplate;
-import org.onap.sdc.api.notification.IArtifactInfo;
-import org.onap.sdc.api.notification.IStatusData;
-import org.onap.sdc.api.notification.IVfModuleMetadata;
-import org.onap.sdc.api.results.IDistributionClientResult;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.Group;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.sdc.toscaparser.api.parameters.Input;
-import org.onap.sdc.utils.DistributionStatusEnum;
-import org.openecomp.mso.asdc.client.ASDCConfiguration;
-import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
-import org.openecomp.mso.asdc.installer.ASDCElementInfo;
-import org.openecomp.mso.asdc.installer.BigDecimalVersion;
-import org.openecomp.mso.asdc.installer.IVfModuleData;
-import org.openecomp.mso.asdc.installer.IVfResourceInstaller;
-import org.openecomp.mso.asdc.installer.ToscaResourceStructure;
-import org.openecomp.mso.asdc.installer.VfModuleArtifact;
-import org.openecomp.mso.asdc.installer.VfModuleStructure;
-import org.openecomp.mso.asdc.installer.VfResourceStructure;
-import org.openecomp.mso.asdc.tenantIsolation.DistributionStatus;
-import org.openecomp.mso.asdc.tenantIsolation.WatchdogDistribution;
-import org.openecomp.mso.asdc.util.ASDCNotificationLogging;
-import org.openecomp.mso.asdc.util.YamlEditor;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.AllottedResource;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
-import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;
-import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;
-import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.WatchdogComponentDistributionStatusDb;
-import org.openecomp.mso.requestsdb.WatchdogDistributionStatusDb;
-import org.openecomp.mso.requestsdb.WatchdogServiceModVerIdLookupDb;
-
-public class ToscaResourceInstaller {// implements IVfResourceInstaller {
-
- private MsoLogger logger;
-
- private static final Pattern lastDigit = Pattern.compile("(\\d+)$");
-
- public ToscaResourceInstaller() {
- logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC);
- }
-
- //@Override
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct)
- throws ArtifactInstallerException {
- boolean status = false;
- VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
- try {
- status = vfResourceStructure.isDeployedSuccessfully();
- } catch (RuntimeException e) {
- status = false;
- }
-
- try {
-
- String serviceUUID = vfResourceStruct.getNotification().getServiceUUID();
-
- if (status) {
- logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL,
- vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(),"", "");
- } else {
- logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL,
- vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(),"", "");
- }
-
- return status;
-
- } catch (Exception e) {
- logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed");
- throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
- }
- }
-
- public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
-
- logger.debug("Entering installTheComponentStatus for distributionId " + iStatus.getDistributionID() + " and ComponentName " + iStatus.getComponentName());
-
- WatchdogComponentDistributionStatusDb wdComponentDistributionStatus = WatchdogComponentDistributionStatusDb.getInstance();
-
- WatchdogDistributionStatusDb wdDistributionStatus = WatchdogDistributionStatusDb.getInstance();
-
-
- try{
- //Check to make sure the distributionId exists in the Distribution Status table first. If not then we'll need to add it
- String distributionId = wdDistributionStatus.getWatchdogDistributionId(iStatus.getDistributionID());
-
- if(distributionId == null){
- // Insert the record into the parent table first - WatchDogDistributionStatus
- wdDistributionStatus.insertWatchdogDistributionId(iStatus.getDistributionID());
- }
-
- wdComponentDistributionStatus.insertWatchdogComponentDistributionStatus(iStatus.getDistributionID(), iStatus.getComponentName(), iStatus.getStatus().toString());
-
-
- WatchdogDistribution wd = new WatchdogDistribution();
-
- String distributionStatus = wd.getOverallDistributionStatus(iStatus.getDistributionID());
-
- logger.debug("Distribution status in installTheComponentStatus is : " + distributionStatus);
-
- }catch (Exception e){
- logger.debug("Exception caught in installTheComponentStatus " + e.getMessage());
- throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
- }
-
- }
-
-
- public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
-
- logger.debug("installTheResource is called");
-
- VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct;
-
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
- case ASDCConfiguration.HEAT:
- case ASDCConfiguration.HEAT_VOL:
- case ASDCConfiguration.HEAT_NESTED:
- ToscaResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ENV:
- ToscaResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ARTIFACT:
- ToscaResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct);
- break;
- case ASDCConfiguration.HEAT_NET:
- case ASDCConfiguration.OTHER:
- logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
- break;
- default:
- break;
-
- }
- }
- // Those objects could be reused by different VfModule
-
-
-
- // PCLO: in case of deployment failure, use a string that will represent the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
-
- CatalogDatabase catalogDB = CatalogDatabase.getInstance();
-
- WatchdogServiceModVerIdLookupDb wdLookupDB = WatchdogServiceModVerIdLookupDb.getInstance();
-
- WatchdogDistributionStatusDb wdDistributionStatus = WatchdogDistributionStatusDb.getInstance();
-
- WatchdogComponentDistributionStatusDb wdComponentDistributionStatus = WatchdogComponentDistributionStatusDb.getInstance();
- // 2. Create the VFModules/VNFResource objects by linking them to the
- // objects created before and store them in Resource/module structure
- // Opening a DB transaction, starting from here
- try {
-
-
- createToscaCsar(toscaResourceStruct);
-
- catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());
-
- ToscaResourceInstaller.createService(toscaResourceStruct, vfResourceStruct);
-
- catalogDB.saveService(toscaResourceStruct.getCatalogService());
-
- wdLookupDB.insertWatchdogServiceModVerIdLookup(vfResourceStructure.getNotification().getDistributionID(), vfResourceStructure.getNotification().getServiceUUID());
-
- wdDistributionStatus.insertWatchdogDistributionId(vfResourceStructure.getNotification().getDistributionID());
-
-
- /* VNF POPULATION
- * ************************************************************************************************************
- */
-
- // Ingest (VNF) Data - 1707
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
- int outerLoop = 0;
- logger.debug("**vfMondeTEmplatesList.size()=" + vfNodeTemplatesList.size());
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
- logger.debug("nodeTemplate outerLoop=" + outerLoop++);
- // extract VF metadata
-
- Metadata metadata = nodeTemplate.getMetaData();
-
-
-
- //************************Flexware code*******************************************
-
- String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
-
-
- if(serviceType != null && serviceType.equalsIgnoreCase("Flexware")){
-
- createVnfResource(nodeTemplate, toscaResourceStruct);
-
- // check for duplicate record already in the database
- VnfResource vnfResource = catalogDB.getVnfResource(toscaResourceStruct.getCatalogVnfResource().getModelName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- toscaResourceStruct.getCatalogVnfResource().getVersion()));
-
- if (vnfResource != null) {
- toscaResourceStruct.setVnfAlreadyInstalled(true);
- }
-
-
- if(!toscaResourceStruct.isVnfAlreadyInstalled()) {
-
- catalogDB.saveOrUpdateVnfResource(toscaResourceStruct.getCatalogVnfResource());
-
- }
-
-
- boolean saveVnfCustomization = catalogDB.saveVnfResourceCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization());
-
- if(saveVnfCustomization){
- catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVfServiceToResourceCustomization());
- }
-
-
- }
-
-
- // *************************** END of FLEXWARE CODE ****************************************************
-
- String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
-
- if(!vfCustomizationCategory.equalsIgnoreCase("Allotted Resource")) // Do not treat Allotted Resources as VNF resources
- {
-
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("vfCustomizationUUID=" + vfCustomizationUUID);
-
-
- /* HEAT TABLE POPULATION
- * *******************************************************************************************************
- */
-
- int nextLoop = 0;
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
- logger.debug("vfResourceStructure.getVfModuleStructure() loop, nextLoop = " + nextLoop++);
- logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
-
- // Here we set the right db structure according to the Catalog
- // DB
-
- // We expect only one MAIN HEAT per VFMODULE
- // we can also obtain from it the Env ArtifactInfo, that's why
- // we
- // get the Main IArtifactInfo
-
- HeatTemplate heatMainTemplate = null;
- HeatEnvironment heatEnv;
-
- HeatTemplate heatVolumeTemplate = null;
- HeatEnvironment heatVolumeEnv;
-
-
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
-
-
- if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) {
-
- List<VfModuleArtifact> artifacts = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT);
- logger.debug("there are " + artifacts.size() + " artifacts");
- IArtifactInfo mainEnvArtifactInfo = null;
- for (VfModuleArtifact vfma : artifacts) {
- logger.debug("vmfa=" + vfma.toString());
- mainEnvArtifactInfo =
- vfma.getArtifactInfo().getGeneratedArtifact();
-
- // MAIN HEAT
- heatMainTemplate = (HeatTemplate) vfma.getCatalogObject();
-
- // Set HeatTemplateArtifactUUID to use later when setting the VfModule and NetworkResource
- toscaResourceStruct.setHeatTemplateUUID(heatMainTemplate.getArtifactUuid());
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo
- .createElementFromVfArtifactInfo(vfma.getArtifactInfo()));
-
- catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters());
- // Indicate we have deployed it in the DB
- vfma.incrementDeployedInDB();
- }
-
-
- // VOLUME HEAT
- // We expect only one VOL HEAT per VFMODULE
- // we can also obtain from it the Env ArtifactInfo, that's why
- // we get the Volume IArtifactInfo
-
- if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) {
- IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0)
- .getArtifactInfo().getGeneratedArtifact();
-
- heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap()
- .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject();
-
- // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule
- toscaResourceStruct.setVolHeatTemplateUUID(heatVolumeTemplate.getArtifactUuid());
-
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()));
-
- catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters());
- // Indicate we have deployed it in the DB
- vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB();
-
- if (volEnvArtifactInfo != null) {
- heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
- .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
-
- // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule
- toscaResourceStruct.setVolHeatEnvTemplateUUID(heatVolumeEnv.getArtifactUuid());
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo));
-
- catalogDB.saveHeatEnvironment(heatVolumeEnv);
- // Indicate we have deployed it in the DB
- vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
- }
-
- }
-
- // NESTED HEAT
- // Here we expect many HEAT_NESTED template to be there
- // XXX FIX BY PCLO: Defect# -36643 -US666034 - check first if we really have nested heat templates
- if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) {
- for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap()
- .get(ASDCConfiguration.HEAT_NESTED)) {
-
- // Check if this nested is well referenced by the MAIN HEAT
- String parentArtifactType = ToscaResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact);
- HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject();
-
- if (parentArtifactType != null) {
-
- switch (parentArtifactType) {
- case ASDCConfiguration.HEAT:
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
-
- catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
- // Indicate we have deployed it in the DB
- heatNestedArtifact.incrementDeployedInDB();
- break;
- case ASDCConfiguration.HEAT_VOL:
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
- catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
- // Indicate we have deployed it in the DB
- heatNestedArtifact.incrementDeployedInDB();
- break;
-
- default:
- break;
-
- }
- } else { // Assume it belongs to HEAT MAIN
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo()));
-
- catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName());
- // Indicate we have deployed it in the DB
- heatNestedArtifact.incrementDeployedInDB();
- }
- }
- }
-
- if (mainEnvArtifactInfo != null) {
- heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID()
- .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject();
-
- // Set HeatEnvironmentArtifactUUID to use later when setting the VfModule
- toscaResourceStruct.setEnvHeatTemplateUUID(heatEnv.getArtifactUuid());
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo));
-
- catalogDB.saveHeatEnvironment(heatEnv);
- // Indicate we have deployed it in the DB
- vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB();
- }
-
- // here we expect one VFModule to be there
- //VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv);
- //VfModule vfModule = vfModuleStructure.getCatalogVfModule();
-
- // Add this one for logging
- //artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure));
-
- //catalogDB.saveOrUpdateVfModule(vfModule);
-
-
- // extract VF metadata
- createVnfResource(nodeTemplate, toscaResourceStruct);
-
- // check for duplicate record already in the database
- VnfResource vnfResource = catalogDB.getVnfResource(toscaResourceStruct.getCatalogVnfResource().getModelName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- toscaResourceStruct.getCatalogVnfResource().getVersion()));
-
- if (vnfResource != null) {
- toscaResourceStruct.setVnfAlreadyInstalled(true);
- }
-
-
- if(!toscaResourceStruct.isVnfAlreadyInstalled()) {
-
- catalogDB.saveOrUpdateVnfResource(toscaResourceStruct.getCatalogVnfResource());
-
- }
-
-
- catalogDB.saveVnfResourceCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization());
-
- catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVfServiceToResourceCustomization());
-
-
- List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
- logger.debug("vfGroups:" + vfGroups.toString());
-
- vfGroups.sort((group1, group2) -> {
- //Field name1Field = group1.class.getDeclaredField("name");
- //name1Field.setAccessible(true);
- String thisName = group1.getName(); //(String) name1Field.get(group1);
- String thatName = group2.getName(); // (String) name1Field.get(group2);
-
- Matcher m = lastDigit.matcher(thisName);
- Matcher m2 = lastDigit.matcher(thatName);
-
- String thisDigit = "0";
- String thatDigit = "0";
- if (m.find()) {
- thisDigit = m.group();
- } else {
- return -1;
- }
- if (m2.find()) {
- thatDigit = m2.group();
- } else {
- return 1;
- }
-
- return new Integer(thisDigit).compareTo(new Integer(thatDigit));
- });
-
- logger.debug("vfGroupsAfter:" + vfGroups.toString());
-
-
- for(Group group : vfGroups){
-
-
- //boolean saveVFModule = createVFModule(group, nodeTemplate, toscaResourceStruct, vfMetadata);
- if (vfMetadata.getVfModuleModelCustomizationUUID() == null) {
- logger.debug("NULL 1");
- } else {
- logger.debug("vfMetadata.getMCU=" + vfMetadata.getVfModuleModelCustomizationUUID());
- }
- if (group.getMetadata() == null) {
- logger.debug("NULL 3");
- } else {
- logger.debug("group.getMetadata().getValue() = " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
- }
- if (vfMetadata.getVfModuleModelCustomizationUUID().equals(group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) {
- logger.debug("Found a match at " + vfMetadata.getVfModuleModelCustomizationUUID());
- createVFModule(group, nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata);
-
- catalogDB.saveOrUpdateVfModule(toscaResourceStruct.getCatalogVfModule());
-
- catalogDB.saveOrUpdateVfModuleCustomization(toscaResourceStruct.getCatalogVfModuleCustomization());
-
- catalogDB.saveVnfResourceToVfModuleCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct.getCatalogVfModuleCustomization());
-
-
- } else {
- if(toscaResourceStruct.getCatalogVfModuleCustomization() != null){
- logger.debug("No match for " + toscaResourceStruct.getCatalogVfModuleCustomization().getModelCustomizationUuid());
- } else {
- logger.debug("No match for vfModuleModelCustomizationUUID");
- }
- }
-
- }
-
- } //Commented out to process VFModules each time
-
- // Here we expect many HEAT_TEMPLATE files to be there
- if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) {
- for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap()
- .get(ASDCConfiguration.HEAT_ARTIFACT)) {
-
- HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject();
-
- // Add this one for logging
- artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo()));
-
- if(toscaResourceStruct.getCatalogVfModule() != null && heatFile != null){
- catalogDB.saveVfModuleToHeatFiles (toscaResourceStruct.getCatalogVfModule().getModelUUID(), heatFile);
- }
- // Indicate we will deploy it in the DB
- heatArtifact.incrementDeployedInDB();
- }
- }
-
- }
- }
- }
-
- /* END OF HEAT TABLE POPULATION
- * ***************************************************************************************************
- */
-
-
- // throw new ArtifactInstallerException("TESTING");
-
-
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
-
- if(allottedResourceList != null){
-
- for(NodeTemplate allottedNode : allottedResourceList){
-
- createAllottedResource(allottedNode, toscaResourceStruct);
-
- catalogDB.saveAllottedResource(toscaResourceStruct.getAllottedResource());
-
- catalogDB.saveAllottedResourceCustomization(toscaResourceStruct.getCatalogAllottedResourceCustomization());
-
- catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogAllottedServiceToResourceCustomization());
-
- }
- }
-
- // handle VF resource
- List<NodeTemplate> serviceVfList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
- if (serviceVfList != null) {
- for (NodeTemplate vfNode : serviceVfList) {
- createVnfResource(vfNode, toscaResourceStruct);
- catalogDB.saveVnfResource(toscaResourceStruct.getCatalogVnfResource());
- catalogDB.saveVnfResourceCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization());
- catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVfServiceToResourceCustomization());
- }
- }
-
-
- List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
-
- if(nodeTemplatesVLList != null){
-
- for(NodeTemplate vlNode : nodeTemplatesVLList){
-
- String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
-
- List<TempNetworkHeatTemplateLookup> networkHeatTemplateLookup = catalogDB.getTempNetworkHeatTemplateLookup(networkResourceModelName);
-
- if(networkHeatTemplateLookup != null && networkHeatTemplateLookup.size() > 0 ){
-
- createNetworkResource(vlNode, toscaResourceStruct, networkHeatTemplateLookup.get(0));
-
- } else {
- logger.info(MessageEnum.ASDC_GENERAL_INFO,
- "No NetworkResourceName found in TempNetworkHeatTemplateLookup for" + networkResourceModelName, "ASDC",
- "createVfModuleStructures");
- createNetworkResource(vlNode, toscaResourceStruct, null);
- }
-
-
- catalogDB.saveNetworkResource(toscaResourceStruct.getCatalogNetworkResource());
-
- catalogDB.saveNetworkResourceCustomization(toscaResourceStruct.getCatalogNetworkResourceCustomization());
-
- catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVlServiceToResourceCustomization());
-
- }
- }
-
-
- //createServiceToResourceCustomization(toscaResourceStruct.getCatalogService(), toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct);
-
- // catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar());
- wdComponentDistributionStatus.insertWatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), "SO", DistributionStatusEnum.COMPONENT_DONE_OK.name());
-
- catalogDB.commit();
- toscaResourceStruct.setSuccessfulDeployment();
-
- }catch(Exception e){
- logger.debug("Exception :",e);
-
- wdDistributionStatus.insertWatchdogDistributionId(vfResourceStructure.getNotification().getDistributionID());
-
- wdComponentDistributionStatus.insertWatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), "SO", DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
-
- wdDistributionStatus.updateWatchdogDistributionIdStatus(vfResourceStruct.getNotification().getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
-
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(),
- vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed");
- logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e);
- catalogDB.rollback();
- throw new ArtifactInstallerException(
- "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
-
- } finally {
- catalogDB.close();
- }
-
- }
-
-
- public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List<String> listTypes) {
- String newFileBody = filebody;
- for (VfModuleArtifact moduleArtifact:vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
-
- newFileBody = verifyTheFilePrefixInString(newFileBody,moduleArtifact.getArtifactInfo().getArtifactName());
- }
- }
- return newFileBody;
- }
-
- public static String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
-
- String needlePrefix = "file:///";
- String prefixedFilenameToVerify = needlePrefix+filenameToVerify;
-
- if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
- return body;
- }
-
- StringBuilder sb = new StringBuilder(body.length());
-
- int currentIndex = 0;
- int startIndex = 0;
-
- while (currentIndex != -1) {
- startIndex = currentIndex;
- currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
-
- if (currentIndex == -1) {
- break;
- }
-
- // We append from the startIndex up to currentIndex (start of File Name)
- sb.append(body.substring(startIndex, currentIndex));
- sb.append(filenameToVerify);
-
- currentIndex += prefixedFilenameToVerify.length();
- }
-
- sb.append(body.substring(startIndex));
-
- return sb.toString();
- }
-
-
- private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,ToscaResourceStructure toscaResourceStruct,
- VfModuleArtifact vfModuleArtifact) {
- HeatTemplate heatTemplate = new HeatTemplate();
-
- // TODO Set the label
-// heatTemplate.setAsdcLabel("label");
- // Use the ResourceName of the ASDC template because the HEAT could be
- // reused
-// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
- heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT_NESTED);
- typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
-
- heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
- heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
- heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
- } else {
- heatTemplate.setTimeoutMinutes(240);
- }
-
- //toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatTemplate.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
- heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatTemplate.setArtifactChecksum("MANUAL_RECORD");
- }
-
- Set<HeatTemplateParam> heatParam = ToscaResourceInstaller
- .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatTemplate.setParameters(heatParam);
- //heatTemplate.setCreated(getCurrentTimeStamp());
-
- vfModuleArtifact.setCatalogObject(heatTemplate);
- }
-
- private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- HeatEnvironment heatEnvironment = new HeatEnvironment();
-
- heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- // TODO Set the label
-// heatEnvironment.setAsdcLabel("Label");
-
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT);
- typeList.add(ASDCConfiguration.HEAT_VOL);
-
- heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList));
-// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatEnvironment.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
-// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure));
- heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
- heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else{
- heatEnvironment.setArtifactChecksum("MANUAL_RECORD");
- }
- //heatEnvironment.setCreated(getCurrentTimeStamp());
-
- vfModuleArtifact.setCatalogObject(heatEnvironment);
-
- }
-
- private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
-
- HeatFiles heatFile = new HeatFiles();
- // TODO Set the label
-// heatFile.setAsdcLabel("Label");
- heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatFile.setFileBody(vfModuleArtifact.getResult());
- heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- heatFile.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
-
- toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- //heatFile.setCreated(getCurrentTimeStamp());
-
-// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName());
-
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){
- heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatFile.setArtifactChecksum("MANUAL_RECORD");
- }
-
- vfModuleArtifact.setCatalogObject(heatFile);
-
- }
-
- private static void createService(ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure) {
-
- toscaResourceStructure.getServiceMetadata();
-
- Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
-
- Service service = new Service();
-
- // Service
- if(serviceMetadata != null) {
-
- if(toscaResourceStructure.getServiceVersion() != null){
- service.setVersion(toscaResourceStructure.getServiceVersion());
- }
-
- service.setServiceType(serviceMetadata.getValue("serviceType"));
- service.setServiceRole(serviceMetadata.getValue("serviceRole"));
-
- service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
-
-
- if(vfResourceStructure != null){
- service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
- }
- //service.setVersion(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- service.setToscaCsarArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
- //service.setCreated(getCurrentTimeStamp());
- }
-
- toscaResourceStructure.setCatalogService(service);
- }
-
- private static void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
-
- ToscaCsar toscaCsar = new ToscaCsar();
- if(toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null){
- toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
- } else {
- toscaCsar.setArtifactChecksum("MANUAL_RECORD");
- }
- toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
- toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
- toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
- toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
- toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
-
- toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
- }
-
- private static void createNetworkResource(NodeTemplate networkNodeTemplate, ToscaResourceStructure toscaResourceStructure, TempNetworkHeatTemplateLookup networkHeatTemplateLookup) {
- NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
-
- NetworkResource networkResource = new NetworkResource();
-
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if("true".equalsIgnoreCase(providerNetwork)){
- networkResource.setNeutronNetworkType("PROVIDER");
- } else {
- networkResource.setNeutronNetworkType("BASIC");
- }
-
- networkResource.setModelName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
-
- networkResource.setModelInvariantUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- networkResource.setModelUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- networkResource.setModelVersion(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-
- networkResource.setAicVersionMax(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- String aicVersionMin = networkHeatTemplateLookup != null ? networkHeatTemplateLookup.getAicVersionMin() : "2.5";
- networkResource.setAicVersionMin(aicVersionMin);
- networkResource.setToscaNodeType(networkNodeTemplate.getType());
- networkResource.setDescription(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- networkResource.setOrchestrationMode("HEAT");
- networkResource.setCategory(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- networkResource.setSubCategory(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
- //for tosca NS ,there is no heat for network VL
- String heatTemplateArtifactUUID = networkHeatTemplateLookup != null ? networkHeatTemplateLookup.getHeatTemplateArtifactUuid() : "null";
- networkResource.setHeatTemplateArtifactUUID(heatTemplateArtifactUUID);
-
- toscaResourceStructure.setCatalogNetworkResource(networkResource);
-
- networkResourceCustomization.setModelInstanceName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- networkResourceCustomization.setModelCustomizationUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- networkResourceCustomization.setNetworkResourceModelUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
-
- networkResourceCustomization.setNetworkTechnology(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
- networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
- networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
- networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
-
- toscaResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization);
-
- ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
- serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
- serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- serviceToResourceCustomization.setModelType("network");
-
- toscaResourceStructure.setCatalogVlServiceToResourceCustomization(serviceToResourceCustomization);
-
-
- }
-
- private static void createVFModule(Group group, NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData) {
- VfModule vfModule = new VfModule();
-
- Metadata vfMetadata = group.getMetadata();
-
- String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
-
-
- if(vfModuleModelUUID != null && vfModuleModelUUID.contains(".")){
- vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf("."));
- }
-
-
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()){
-
- String vfModelUUID = vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID();
-
- if(vfModelUUID != null && vfModelUUID.equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))){
-
- List<String> artifacts = vfModuleStructure.getVfModuleMetadata().getArtifacts();
-
- for(String artifact: artifacts){
-
-
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
-
- if(artifact.equals(vfModuleArtifact.getArtifactInfo().getArtifactUUID())){
- //if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)){
- if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)){
- vfModule.setHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- }
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)){
- vfModule.setVolHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- }
- }
-
- }
-
-
- }
-
-
- }
-
-
- }
-
- vfModule.setModelInvariantUuid(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
- vfModule.setModelUUID(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)));
- vfModule.setVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- //vfModule.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID());
- //vfModule.setVolHeatTemplateArtifactUUId(toscaResourceStructure.getVolHeatTemplateUUID());
-
- vfModule.setVnfResourceModelUUId(toscaResourceStructure.getCatalogVnfResource().getModelUuid());
-
- String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- if(vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)){
- vfModule.setIsBase(1);
- }else {
- vfModule.setIsBase(0);
- }
-
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUuid(vfModuleData.getVfModuleModelCustomizationUUID());
-
-
- vfModuleCustomization.setVfModuleModelUuid(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
-
- vfModuleCustomization.setHeatEnvironmentArtifactUuid(toscaResourceStructure.getEnvHeatTemplateUUID());
-
-
- vfModuleCustomization.setVolEnvironmentArtifactUuid(toscaResourceStructure.getVolHeatEnvTemplateUUID());
-
- String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
- if(initialCount != null && initialCount.length() > 0){
- vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
- }
-
- vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
-
- String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
- if(availabilityZoneCount != null && availabilityZoneCount.length() > 0){
- vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
- }
-
-
- vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
-
- String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
- if(maxInstances != null && maxInstances.length() > 0){
- vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
- }
-
- String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
- if(minInstances != null && minInstances.length() > 0){
- vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
- }
-
- toscaResourceStructure.setCatalogVfModule(vfModule);
-
- toscaResourceStructure.setCatalogVfModuleCustomization(vfModuleCustomization);
-
- }
-
- private static void createVnfResourceToVfModuleCustomization(VnfResourceCustomization vnfResourceCustomization,
- VfModuleCustomization vfModuleCustomization,
- ToscaResourceStructure toscaResourceStructure) {
-
- VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom();
-
- vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vfModuleCustomization.getModelCustomizationUuid());
- vnfResCustomToVfModuleCustom.setVnfResourceCustModelCustomizationUuid(vnfResourceCustomization.getModelCustomizationUuid());
-
- toscaResourceStructure.setCatalogVnfResCustomToVfModuleCustom(vnfResCustomToVfModuleCustom);
-
-
-
- }
-
-
- private static void createTempNetworkHeatTemplateLookup(NetworkResource networkResource,
- VfModule vfModule,
- ToscaResourceStructure toscaResourceStructure) {
-
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup();
-
- tempNetworkHeatTemplateLookup.setNetworkResourceModelName(networkResource.getModelName());
- tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid(vfModule.getHeatTemplateArtifactUUId());
- tempNetworkHeatTemplateLookup.setAicVersionMin("1");
-
- toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(tempNetworkHeatTemplateLookup);
-
-
-
- }
-
- private static void createVnfResource(NodeTemplate vfNodeTemplate, ToscaResourceStructure toscaResourceStructure) {
- VnfResource vnfResource = new VnfResource();
-
-
- //toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)
-
- vnfResource.setModelInvariantUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- vnfResource.setModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
- vnfResource.setVersion(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfResource.setDescription(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfResource.setOrchestrationMode("HEAT");
- vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
- vnfResource.setAicVersionMax(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- vnfResource.setAicVersionMin(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
- //vnfResource.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID());
-
- // vfNodeTemplate.getProperties()
- toscaResourceStructure.setCatalogVnfResource(vnfResource);
-
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setModelCustomizationUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
-
- vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)));
- vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
-
- vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, "multi_stage_design"));
-
-
- vnfResourceCustomization.setVnfResourceModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
-
- //vnfResourceCustomization.setMultiStageDesign(vfNodeTemplate.getMetaData().getValue("multi_stage_design"));
- //vnfResourceCustomization.setMultiStageDesign(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT).trim());
-
-
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- vnfResourceCustomization.setMinInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
-
-
-
- toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
-
-
- ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
- serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
- serviceToResourceCustomization.setResourceModelCustomizationUUID(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- serviceToResourceCustomization.setModelType("vnf");
-
- toscaResourceStructure.setCatalogVfServiceToResourceCustomization(serviceToResourceCustomization);
-
-
- }
-
- private static void createAllottedResource(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
- AllottedResource allottedResource = new AllottedResource();
-
- allottedResource.setModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- allottedResource.setModelInvariantUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- allottedResource.setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- allottedResource.setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
- allottedResource.setSubcategory(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- allottedResource.setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- toscaResourceStructure.setAllottedResource(allottedResource);
-
- AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
- allottedResourceCustomization.setModelCustomizationUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
- allottedResourceCustomization.setArModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
-
- allottedResourceCustomization.setProvidingServiceModelInvariantUuid(toscaResourceStructure.getCatalogService().getModelInvariantUUID());
- allottedResourceCustomization.setProvidingServiceModelUuid(toscaResourceStructure.getCatalogService().getModelUUID());
- allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getCatalogService().getModelName());
- allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)));
- allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
- allottedResourceCustomization.setMinInstances(Integer.getInteger(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- allottedResourceCustomization.setMaxInstances(Integer.getInteger(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- allottedResourceCustomization.setTargetNetworkRole(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
-
- toscaResourceStructure.setCatalogAllottedResourceCustomization(allottedResourceCustomization);
-
- ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization();
- serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID());
- serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- serviceToResourceCustomization.setModelType("allottedResource");
-
- toscaResourceStructure.setCatalogAllottedServiceToResourceCustomization(serviceToResourceCustomization);
-
- }
-
- private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
-
- // Scan the payload downloadResult and extract the HeatTemplate
- // parameters
- YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
- return yamlEditor.getParameterList(artifactUUID);
-
- }
-
- private static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,VfModuleArtifact heatNestedArtifact) {
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null
- && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
- .getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT;
- }
-
- }
- }
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
- && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact:vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT_VOL;
- }
-
- }
- }
-
- // Does not belong to anything
- return null;
-
- }
-
- private static String testNull(Object object) {
-
-
- if(object == null){
- return null;
- }else if (object != null && object.equals("NULL")) {
- return null;
- }else if (object != null && object instanceof Integer) {
- return object.toString();
- } else if (object != null && object instanceof String) {
- return (String)object;
- } else {
- return "Type not recognized";
- }
- }
-
- private static String createVNFName(VfResourceStructure vfResourceStructure) {
-
- return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName();
- }
-
- private static String createVfModuleName(VfModuleStructure vfModuleStructure) {
-
- return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
- }
-
-
- private static Timestamp getCurrentTimeStamp() {
-
- return new Timestamp(new Date().getTime());
- }
-}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java deleted file mode 100644 index d227961664..0000000000 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java +++ /dev/null @@ -1,790 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.asdc.installer.heat; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hibernate.exception.ConstraintViolationException; -import org.hibernate.exception.LockAcquisitionException; -import org.onap.sdc.api.notification.IArtifactInfo; - -import org.openecomp.mso.asdc.client.ASDCConfiguration; -import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; -import org.openecomp.mso.asdc.installer.ASDCElementInfo; -import org.openecomp.mso.asdc.installer.BigDecimalVersion; -import org.openecomp.mso.asdc.installer.IVfResourceInstaller; -import org.openecomp.mso.asdc.installer.VfModuleArtifact; -import org.openecomp.mso.asdc.installer.VfModuleStructure; -import org.openecomp.mso.asdc.installer.VfResourceStructure; -import org.openecomp.mso.asdc.util.YamlEditor; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.HeatEnvironment; -import org.openecomp.mso.db.catalog.beans.HeatFiles; -import org.openecomp.mso.db.catalog.beans.HeatTemplate; -import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; -import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -public class VfResourceInstaller implements IVfResourceInstaller { - - private MsoLogger logger; - - public VfResourceInstaller() { - logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC); - } - - @Override - public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) - throws ArtifactInstallerException { - - boolean status = false; - VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct; - - try(CatalogDatabase db = CatalogDatabase.getInstance()) { - - String resourceType = vfResourceStruct.getResourceInstance().getResourceType(); - String category = vfResourceStruct.getResourceInstance().getCategory(); - - // Check for duplicate VF Module that is not an Allotted Resource - if(resourceType.equals("VF") && !category.equalsIgnoreCase("Allotted Resource")){ - logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "VNFResource", - VfResourceInstaller.createVNFName(vfResourceStructure), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), "", ""); - - VnfResource vnfResource = db.getVnfResource( - VfResourceInstaller.createVNFName(vfResourceStructure), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion())); - - if (vnfResource != null) { - status = true; - - } - - } - - // Check dup for VF Allotted Resource - if(resourceType.equals("VF") && category.equalsIgnoreCase("Allotted Resource")){ - logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "AllottedResource", - vfResourceStruct.getResourceInstance().getResourceInstanceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), "", ""); - - List<AllottedResourceCustomization> allottedResources = db.getAllAllottedResourcesByServiceModelUuid(vfResourceStruct.getNotification().getServiceUUID()); - - if(allottedResources != null && allottedResources.size() > 0){ - for(AllottedResourceCustomization allottedResource : allottedResources){ - - String existingAllottedResource = allottedResource.getModelCustomizationUuid(); - String notificationAllottedResource = vfResourceStruct.getResourceInstance().getResourceCustomizationUUID(); - - if(existingAllottedResource.equals(notificationAllottedResource)){ - status=true; - break; - } - } - - } - } - - // Check Network for duplicates - if(resourceType.equals("VL")){ - logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "NetworkResource", - vfResourceStruct.getResourceInstance().getResourceInstanceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), "", ""); - - List<NetworkResourceCustomization> networkResources = db.getAllNetworksByServiceModelUuid(vfResourceStruct.getNotification().getServiceUUID()); - - if(networkResources != null && networkResources.size() > 0){ - for(NetworkResourceCustomization networkResource : networkResources){ - - String existingNetworkResource = networkResource.getModelCustomizationUuid(); - String notificationNetworkResource = vfResourceStruct.getResourceInstance().getResourceCustomizationUUID(); - - if(existingNetworkResource.equals(notificationNetworkResource)){ - status=true; - break; - } - } - - } - } - - if (status) { - logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, - vfResourceStructure.getResourceInstance().getResourceInstanceName(), - vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), - vfResourceStructure.getNotification().getServiceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), - vfResourceStructure.getNotification().getServiceUUID(), - vfResourceStructure.getResourceInstance().getResourceName(),"", ""); - } else { - logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, - vfResourceStructure.getResourceInstance().getResourceInstanceName(), - vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), - vfResourceStructure.getNotification().getServiceName(), - BigDecimalVersion.castAndCheckNotificationVersionToString( - vfResourceStructure.getNotification().getServiceVersion()), - vfResourceStructure.getNotification().getServiceUUID(), - vfResourceStructure.getResourceInstance().getResourceName(),"", ""); - } - - return status; - - } catch (Exception e) { - logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed"); - throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); - } - } - - @Override - public void installTheResource(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException { - - // 1. Add the DB object list (Hashed) to be created from the HashMap - // UUID - // The DB objects will be stored in each VfModuleArtifact objects - // Those objects could be reused by different VfModule - - VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct; - - for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { - - switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) { - case ASDCConfiguration.HEAT: - case ASDCConfiguration.HEAT_VOL: - case ASDCConfiguration.HEAT_NESTED: - VfResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, vfModuleArtifact); - break; - case ASDCConfiguration.HEAT_ENV: - VfResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact); - break; - case ASDCConfiguration.HEAT_ARTIFACT: - VfResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact); - break; - case ASDCConfiguration.HEAT_NET: - case ASDCConfiguration.OTHER: - logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported"); - break; - default: - break; - - } - } - - // in case of deployment failure, use a string that will represent the type of artifact that failed... - List<ASDCElementInfo> artifactListForLogging = new ArrayList<>(); - - CatalogDatabase catalogDB = CatalogDatabase.getInstance(); - // 2. Create the VFModules/VNFResource objects by linking them to the - // objects created before and store them in Resource/module structure - // Opening a DB transaction, starting from here - try { - - VfResourceInstaller.createService(vfResourceStructure); - - String resourceType = vfResourceStructure.getResourceInstance().getResourceType(); - String resourceCategory = vfResourceStructure.getResourceInstance().getCategory(); - - if("VF".equals(resourceType)){ - - if(resourceCategory.equalsIgnoreCase("Allotted Resource")){ - VfResourceInstaller.createAllottedResourceCustomization(vfResourceStructure); - catalogDB.saveAllottedResourceCustomization(vfResourceStructure.getCatalogResourceCustomization()); - } else { - VfResourceInstaller.createVnfResource(vfResourceStructure); - catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource()); - } - } - - if("VL".equals(resourceType)){ - VfResourceInstaller.createNetworkResourceCustomization(vfResourceStructure); - catalogDB.saveNetworkResourceCustomization(vfResourceStructure.getCatalogNetworkResourceCustomization()); - } - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure)); - - //catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource()); - catalogDB.saveService(vfResourceStructure.getCatalogService()); - - // Now that the service has been added we can populate the Service_to_AllottedResources table - if("VF".equals(resourceType) && "Allotted Resource".equalsIgnoreCase(resourceCategory)){ - catalogDB.saveServiceToAllottedResources(vfResourceStructure.getCatalogServiceToAllottedResources()); - } - - // Now that the service has been added we can populate the Service_to_Network table - if("VL".equals(resourceType)){ - catalogDB.saveServiceToNetworks(vfResourceStructure.getCatalogServiceToNetworks()); - } - - for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - - // Here we set the right db structure according to the Catalog - // DB - - // We expect only one MAIN HEAT per VFMODULE - // we can also obtain from it the Env ArtifactInfo, that's why - // we - // get the Main IArtifactInfo - - HeatTemplate heatMainTemplate = null; - HeatEnvironment heatEnv = null; - - HeatTemplate heatVolumeTemplate = null; - HeatEnvironment heatVolumeEnv = null; - - if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) { - IArtifactInfo mainEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) - .get(0).getArtifactInfo().getGeneratedArtifact(); - - // MAIN HEAT - heatMainTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap() - .get(ASDCConfiguration.HEAT).get(0).getCatalogObject(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo - .createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo())); - - catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters()); - // Indicate we have deployed it in the DB - vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).incrementDeployedInDB(); - - - // VOLUME HEAT - // We expect only one VOL HEAT per VFMODULE - // we can also obtain from it the Env ArtifactInfo, that's why - // we get the Volume IArtifactInfo - - if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) { - IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0) - .getArtifactInfo().getGeneratedArtifact(); - - heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap() - .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo())); - - catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters()); - // Indicate we have deployed it in the DB - vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB(); - - if (volEnvArtifactInfo != null) { - heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() - .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo)); - - catalogDB.saveHeatEnvironment(heatVolumeEnv); - // Indicate we have deployed it in the DB - vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); - } - - } - - // NESTED HEAT - // Here we expect many HEAT_NESTED template to be there - // check first if we really have nested heat templates - if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) { - for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap() - .get(ASDCConfiguration.HEAT_NESTED)) { - - // Check if this nested is well referenced by the MAIN HEAT - String parentArtifactType = VfResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact); - HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject(); - - if (parentArtifactType != null) { - - switch (parentArtifactType) { - case ASDCConfiguration.HEAT: - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - - catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); - // Indicate we have deployed it in the DB - heatNestedArtifact.incrementDeployedInDB(); - break; - case ASDCConfiguration.HEAT_VOL: - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); - // Indicate we have deployed it in the DB - heatNestedArtifact.incrementDeployedInDB(); - break; - - default: - break; - - } - } else { // Assume it belongs to HEAT MAIN - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - - catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); - // Indicate we have deployed it in the DB - heatNestedArtifact.incrementDeployedInDB(); - } - } - } - - if (mainEnvArtifactInfo != null) { - heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() - .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo)); - - catalogDB.saveHeatEnvironment(heatEnv); - // Indicate we have deployed it in the DB - vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); - } - - } - - - // here we expect one VFModule to be there -/* VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv); - VfModule vfModule = vfModuleStructure.getCatalogVfModule(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure)); - - catalogDB.saveOrUpdateVfModule(vfModule); - - // Here we expect many HEAT_TEMPLATE files to be there - if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) { - for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap() - .get(ASDCConfiguration.HEAT_ARTIFACT)) { - - HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject(); - - // Add this one for logging - artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo())); - - - catalogDB.saveVfModuleToHeatFiles (vfModule.getArtifactUuid(), heatFile); - // Indicate we will deploy it in the DB - heatArtifact.incrementDeployedInDB(); - } - } */ - - } - - catalogDB.commit(); - vfResourceStructure.setSuccessfulDeployment(); - - } catch (Exception e) { - - Throwable dbExceptionToCapture = e; - while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) - && (dbExceptionToCapture.getCause() != null)) { - dbExceptionToCapture = dbExceptionToCapture.getCause(); - } - - if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) { - logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(), - vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e); - } else { - String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback."; - String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed"); - logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e); - catalogDB.rollback(); - throw new ArtifactInstallerException( - "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e); - } - - } finally { - catalogDB.close(); - // Debug log the whole collection... - logger.debug(artifactListForLogging.toString()); - } - - } - - private static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,VfModuleArtifact heatNestedArtifact) { - - if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null - && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) { - for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0) - .getArtifactInfo().getRelatedArtifacts()) { - if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { - return ASDCConfiguration.HEAT; - } - - } - } - - if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null - && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts() != null) { - for (IArtifactInfo unknownArtifact:vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts()) { - if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { - return ASDCConfiguration.HEAT_VOL; - } - - } - } - - // Does not belong to anything - return null; - - } - - private static void createVnfResource(VfResourceStructure vfResourceStructure) { - VnfResource vnfResource = new VnfResource(); - - vnfResource.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID()); - vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription()); - - vnfResource.setOrchestrationMode("HEAT"); - // Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION - vnfResource.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion())); -// vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure)); - vnfResource.setModelVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion())); - - vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID()); - vnfResource.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion()); -// vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName()); -// vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID()); - vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName()); -// vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); - - //vnfResource.setCreated(getCurrentTimeStamp()); - - vfResourceStructure.setCatalogVnfResource(vnfResource); - } - - private static void createNetworkResourceCustomization(VfResourceStructure vfResourceStructure) { - NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); - - networkResourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim()); -// networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); - networkResourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim()); -// networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); -// networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); -// networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim()); - //networkResourceCustomization.setCreated(getCurrentTimeStamp()); - - vfResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization); - - ServiceToNetworks serviceNetworks = new ServiceToNetworks(); - serviceNetworks.setNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - serviceNetworks.setServiceModelUuid(vfResourceStructure.getNotification().getServiceUUID()); - - vfResourceStructure.setCatalogServiceToNetworks(serviceNetworks); - - } - - private static void createAllottedResourceCustomization(VfResourceStructure vfResourceStructure) { - AllottedResourceCustomization resourceCustomization = new AllottedResourceCustomization(); - - resourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim()); -// resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); - resourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim()); -// resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); -// resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); - resourceCustomization.setVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim()); - //resourceCustomization.setCreated(getCurrentTimeStamp()); - - vfResourceStructure.setCatalogResourceCustomization(resourceCustomization); - - ServiceToAllottedResources serviceAllottedResources = new ServiceToAllottedResources(); - serviceAllottedResources.setArModelCustomizationUuid(resourceCustomization.getModelCustomizationUuid()); - serviceAllottedResources.setServiceModelUuid(vfResourceStructure.getNotification().getServiceUUID()); - - vfResourceStructure.setCatalogServiceToAllottedResources(serviceAllottedResources); - - } - - private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { - VfModule vfModule = new VfModule(); -// vfModule.setType(createVfModuleName(vfModuleStructure)); -// vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID()); - vfModule.setDescription(vfModuleStructure.getVfModuleMetadata().getVfModuleModelDescription()); - - if (vfModuleStructure.getVfModuleMetadata().isBase()) { - vfModule.setIsBase(1); - } else { - vfModule.setIsBase(0); - } - -// vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID()); - vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID()); - vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName()); - - vfModule.setVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(vfModuleStructure.getParentVfResource().getNotification().getServiceVersion())); - vfModule.setModelVersion(BigDecimalVersion.castAndCheckNotificationVersionToString( - vfModuleStructure.getVfModuleMetadata().getVfModuleModelVersion())); - - Map<String,String> map = vfModuleStructure.getVfModuleMetadata().getProperties(); - - if(map != null){ - - if(map.get("vf_module_label") != null){ -// vfModule.setLabel(map.get("vf_module_label")); - } - if(map.get("initial_count") != null && map.get("initial_count").length() > 0){ -// vfModule.setInitialCount(Integer.parseInt(map.get("initial_count"))); - } - if(map.get("min_vf_module_instances") != null && map.get("min_vf_module_instances").length() > 0){ -// vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances"))); - } - if(map.get("max_vf_module_instances") != null && map.get("max_vf_module_instances").length() > 0){ -// vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances"))); - } - - } - - vfModuleStructure.setCatalogVfModule(vfModule); - - VfResourceInstaller.createVfModuleLinks(vfModule, vfModuleStructure.getParentVfResource().getCatalogVnfResource(), heatMain,heatVolume, heatEnv,heatVolumeEnv); - } - - private static void createVfModuleLinks(VfModule vfModule, VnfResource vnfResource, HeatTemplate heatMain, - HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { - - if (heatMain !=null) { -// vfModule.setTemplateId(heatMain.getId()); - } - if (heatEnv != null) { -// vfModule.setEnvironmentId(heatEnv.getId()); - } - if (heatVolume != null) { -// vfModule.setVolTemplateId(heatVolume.getId()); - } - if (heatVolumeEnv != null) { -// vfModule.setVolEnvironmentId(heatVolumeEnv.getId()); - } - -// vfModule.setVnfResourceId(vnfResource.getId()); - - } - - - private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) { - - // Scan the payload downloadResult and extract the HeatTemplate - // parameters - YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); - return yamlEditor.getParameterList(artifactUUID); - - } - - - public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List<String> listTypes) { - String newFileBody = filebody; - for (VfModuleArtifact moduleArtifact:vfResourceStructure.getArtifactsMapByUUID().values()) { - - if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) { - - newFileBody = verifyTheFilePrefixInString(newFileBody,moduleArtifact.getArtifactInfo().getArtifactName()); - } - } - return newFileBody; - } - - public static String verifyTheFilePrefixInString(final String body, final String filenameToVerify) { - - String needlePrefix = "file:///"; - String prefixedFilenameToVerify = needlePrefix+filenameToVerify; - - if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) { - return body; - } - - StringBuilder sb = new StringBuilder(body.length()); - - int currentIndex = 0; - int startIndex = 0; - - while (currentIndex != -1) { - startIndex = currentIndex; - currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex); - - if (currentIndex == -1) { - break; - } - - // We append from the startIndex up to currentIndex (start of File Name) - sb.append(body.substring(startIndex, currentIndex)); - sb.append(filenameToVerify); - - currentIndex += prefixedFilenameToVerify.length(); - } - - sb.append(body.substring(startIndex)); - - return sb.toString(); - } - - private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact) { - HeatTemplate heatTemplate = new HeatTemplate(); - - // TODO Set the label -// heatTemplate.setAsdcLabel("label"); - // Use the ResourceName of the ASDC template because the HEAT could be - // reused -// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); - heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - - List<String> typeList = new ArrayList<>(); - typeList.add(ASDCConfiguration.HEAT_NESTED); - typeList.add(ASDCConfiguration.HEAT_ARTIFACT); - - heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); - heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - - if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) { - heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout()); - } else { - heatTemplate.setTimeoutMinutes(240); - } - - heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatTemplate.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - - if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ - heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else { - heatTemplate.setArtifactChecksum("MANUAL_RECORD"); - } - - Set<HeatTemplateParam> heatParam = VfResourceInstaller - .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - heatTemplate.setParameters(heatParam); - //heatTemplate.setCreated(getCurrentTimeStamp()); - - vfModuleArtifact.setCatalogObject(heatTemplate); - } - - private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact) { - HeatEnvironment heatEnvironment = new HeatEnvironment(); - - heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - // TODO Set the label -// heatEnvironment.setAsdcLabel("Label"); - - List<String> typeList = new ArrayList<>(); - typeList.add(ASDCConfiguration.HEAT); - typeList.add(ASDCConfiguration.HEAT_VOL); - - heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); -// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatEnvironment.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); -// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure)); - heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - - if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ - heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else{ - heatEnvironment.setArtifactChecksum("MANUAL_RECORD"); - } - //heatEnvironment.setCreated(getCurrentTimeStamp()); - - vfModuleArtifact.setCatalogObject(heatEnvironment); - - } - - private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure, - VfModuleArtifact vfModuleArtifact) { - - HeatFiles heatFile = new HeatFiles(); - // TODO Set the label -// heatFile.setAsdcLabel("Label"); - heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); - heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); - heatFile.setFileBody(vfModuleArtifact.getResult()); - heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName()); - heatFile.setVersion(BigDecimalVersion - .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - //heatFile.setCreated(getCurrentTimeStamp()); - -// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); - - if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ - heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); - } else { - heatFile.setArtifactChecksum("MANUAL_RECORD"); - } - - vfModuleArtifact.setCatalogObject(heatFile); - - } - - private static void createService(VfResourceStructure vfResourceStructure) { - - Service service = new Service(); - service.setDescription(vfResourceStructure.getNotification().getServiceDescription()); - service.setModelName(vfResourceStructure.getNotification().getServiceName()); - service.setModelUUID(vfResourceStructure.getNotification().getServiceUUID()); - service.setVersion(vfResourceStructure.getNotification().getServiceVersion()); - service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); - //service.setCreated(getCurrentTimeStamp()); - - vfResourceStructure.setCatalogService(service); - } - - - private static String createVNFName(VfResourceStructure vfResourceStructure) { - - return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName(); - } - - private static String createVfModuleName(VfModuleStructure vfModuleStructure) { - - return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); - } - - - private static Timestamp getCurrentTimeStamp() { - - return new Timestamp(new Date().getTime()); - } - - -} |