aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-heat-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-heat-lib')
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/pom.xml4
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java168
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java125
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java115
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestContent.java47
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestFile.java27
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Constraint.java75
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailResourceTypes.java66
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailV2ResourceTypes.java50
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Environment.java16
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplate.java76
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatPseudoParameters.java58
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypes.java158
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Output.java26
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Parameter.java76
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterGroup.java36
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterType.java31
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PolicyTypes.java51
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PropertiesMapKeyTypes.java31
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Resource.java90
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceReferenceFunctions.java34
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceTypeToMessageString.java45
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/Artifact.java103
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java518
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/ValidationStructureList.java27
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatResourceUtil.java32
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatStructureUtil.java148
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/manifest/ManifestUtil.java245
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java456
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java339
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java127
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatResourceUtilTest.java89
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatStructureUtilTest.java146
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/manifest/ManifestUtilTest.java109
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java65
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtilTest.java230
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManagerTest.java163
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/MANIFEST.json48
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.env9
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.yaml103
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.env2
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.yaml71
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/nested.yml76
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/network.yml733
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/second.yaml14
45 files changed, 3287 insertions, 1971 deletions
diff --git a/openecomp-be/lib/openecomp-heat-lib/pom.xml b/openecomp-be/lib/openecomp-heat-lib/pom.xml
index 0d407e2ef6..9c2d5395b9 100644
--- a/openecomp-be/lib/openecomp-heat-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-heat-lib/pom.xml
@@ -14,6 +14,10 @@
<dependencies>
<dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.sdc.common</groupId>
<artifactId>onap-configuration-management-core</artifactId>
<version>${project.version}</version>
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java
index 0367d0969e..600917201b 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,102 +20,102 @@
package org.openecomp.sdc.heat.datatypes;
-import org.apache.commons.lang.math.NumberUtils;
-import org.apache.commons.lang3.ClassUtils;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.lang3.ClassUtils;
+
public enum DefinedHeatParameterTypes {
- NUMBER("number"),
- STRING("string"),
- COMMA_DELIMITED_LIST("comma_delimited_list"),
- JSON("json"),
- BOOLEAN("boolean");
-
- private static Map<String, DefinedHeatParameterTypes> stringToDefinedType = new HashMap<>();
-
- static {
- stringToDefinedType = new HashMap<>();
- for (DefinedHeatParameterTypes definedHeatParameterType : DefinedHeatParameterTypes.values()) {
- stringToDefinedType.put(definedHeatParameterType.type, definedHeatParameterType);
+ NUMBER("number"),
+ STRING("string"),
+ COMMA_DELIMITED_LIST("comma_delimited_list"),
+ JSON("json"),
+ BOOLEAN("boolean");
+
+ private static Map<String, DefinedHeatParameterTypes> stringToDefinedType;
+
+ static {
+ stringToDefinedType = new HashMap<>();
+ for (DefinedHeatParameterTypes definedHeatParameterType : DefinedHeatParameterTypes.values()) {
+ stringToDefinedType.put(definedHeatParameterType.type, definedHeatParameterType);
+ }
+ }
+
+ private String type;
+
+ DefinedHeatParameterTypes(String type) {
+ this.type = type;
}
- }
-
- private String type;
-
- DefinedHeatParameterTypes(String type) {
- this.type = type;
- }
-
- public static DefinedHeatParameterTypes findByHeatResource(String type) {
- return stringToDefinedType.get(type);
- }
-
- /**
- * Is value is from given type boolean.
- *
- * @param value the value
- * @param parameterType the parameter type
- * @return the boolean
- */
- public static boolean isValueIsFromGivenType(Object value, String parameterType) {
- DefinedHeatParameterTypes definedType = findByHeatResource(parameterType);
-
- if (Objects.nonNull(definedType)) {
- switch (definedType) {
- case NUMBER:
- return NumberUtils.isNumber(String.valueOf(value));
-
- case BOOLEAN:
- return HeatBoolean.isValueBoolean(value);
-
- case COMMA_DELIMITED_LIST:
- return isValueCommaDelimitedList(value);
-
- case JSON:
- return isValueJson(value);
-
- case STRING:
- return isValueString(value);
- default:
- }
+
+ public static DefinedHeatParameterTypes findByHeatResource(String type) {
+ return stringToDefinedType.get(type);
}
- return false;
- }
+ /**
+ * Is value is from given type boolean.
+ *
+ * @param value the value
+ * @param parameterType the parameter type
+ * @return the boolean
+ */
+ public static boolean isValueIsFromGivenType(Object value, String parameterType) {
+ DefinedHeatParameterTypes definedType = findByHeatResource(parameterType);
+
+ if (Objects.nonNull(definedType)) {
+ switch (definedType) {
+ case NUMBER:
+ return NumberUtils.isNumber(String.valueOf(value));
+
+ case BOOLEAN:
+ return HeatBoolean.isValueBoolean(value);
+
+ case COMMA_DELIMITED_LIST:
+ return isValueCommaDelimitedList(value);
+
+ case JSON:
+ return isValueJson(value);
+
+ case STRING:
+ return isValueString(value);
+ default:
+ }
+ }
+
+ return false;
+ }
- public static boolean isNovaServerEnvValueIsFromRightType(Object value) {
- return isValueIsFromGivenType(value, COMMA_DELIMITED_LIST.getType())
- || isValueIsFromGivenType(value, STRING.getType());
- }
+ public static boolean isNovaServerEnvValueIsFromRightType(Object value) {
+ return isValueIsFromGivenType(value, COMMA_DELIMITED_LIST.getType())
+ || isValueIsFromGivenType(value, STRING.getType());
+ }
- private static boolean isValueCommaDelimitedList(Object value) {
- return value instanceof List
- || String.valueOf(value).contains(",")
- || isValueIsFromGivenType(value, DefinedHeatParameterTypes.STRING.type);
- }
+ private static boolean isValueCommaDelimitedList(Object value) {
+ return value instanceof List
+ || String.valueOf(value).contains(",")
+ || isValueIsFromGivenType(value, DefinedHeatParameterTypes.STRING.type);
+ }
- private static boolean isValueString(Object value) {
- return value instanceof String
- || ClassUtils.isPrimitiveOrWrapper(value.getClass());
- }
+ private static boolean isValueString(Object value) {
+ return value instanceof String
+ || ClassUtils.isPrimitiveOrWrapper(value.getClass());
+ }
- private static boolean isValueJson(Object value) {
- return (value instanceof Map) || (value instanceof List);
- }
+ private static boolean isValueJson(Object value) {
+ return (value instanceof Map) || (value instanceof List);
+ }
- public static boolean isEmptyValueInEnv(Object value) {
- return Objects.isNull(value);
- }
+ public static boolean isEmptyValueInEnv(Object value) {
+ return Objects.isNull(value);
+ }
- public String getType() {
- return type;
- }
+ public String getType() {
+ return type;
+ }
- public void setType(String type) {
- this.type = type;
- }
+ public void setType(String type) {
+ this.type = type;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java
index 5753fa2a27..19fa2d5964 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java
@@ -12,10 +12,13 @@
* 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.
-*/
+ */
package org.openecomp.sdc.heat.datatypes;
+import java.util.HashSet;
+import java.util.Set;
+
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -23,77 +26,75 @@ import org.openecomp.sdc.heat.services.ErrorCodes;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.util.HashSet;
-import java.util.Set;
-
public class HeatBoolean {
- private static Set<Object> heatFalse;
- private static Set<Object> heatTrue;
- private static final Logger LOG = LoggerFactory.getLogger(HeatBoolean.class.getName());
-
- private HeatBoolean() {
- //Utility classes, which are a collection of static members, are not meant to be instantiated
- }
- static {
+ private static Set<Object> heatFalse;
+ private static Set<Object> heatTrue;
+ private static final Logger LOG = LoggerFactory.getLogger(HeatBoolean.class.getName());
+ private HeatBoolean() {
+ //Utility classes, which are a collection of static members, are not meant to be instantiated
+ }
- heatFalse = new HashSet<>();
- heatFalse.add("f");
- heatFalse.add(false);
- heatFalse.add("false");
- heatFalse.add("off");
- heatFalse.add("n");
- heatFalse.add("no");
- heatFalse.add(0);
+ static {
- heatTrue = new HashSet<>();
- heatTrue.add("t");
- heatTrue.add(true);
- heatTrue.add("true");
- heatTrue.add("on");
- heatTrue.add("y");
- heatTrue.add("yes");
- heatTrue.add(1);
- }
+ heatFalse = new HashSet<>();
+ heatFalse.add("f");
+ heatFalse.add(false);
+ heatFalse.add("false");
+ heatFalse.add("off");
+ heatFalse.add("n");
+ heatFalse.add("no");
+ heatFalse.add(0);
- /**
- * Eval boolean.
- *
- * @param value the value
- * @return the boolean
- */
- public static Boolean eval(Object value) {
+ heatTrue = new HashSet<>();
+ heatTrue.add("t");
+ heatTrue.add(true);
+ heatTrue.add("true");
+ heatTrue.add("on");
+ heatTrue.add("y");
+ heatTrue.add("yes");
+ heatTrue.add(1);
- if (value instanceof String) {
- value = ((String) value).toLowerCase();
- }
- if (heatFalse.contains(value)) {
- return false;
- } else if (heatTrue.contains(value)) {
- return true;
- } else {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withId(ErrorCodes.INVALID_BOOLEAN)
- .withCategory(ErrorCategory.APPLICATION)
- .withMessage("Invalid boolean value [" + value + "].").build());
}
- }
+ /**
+ * Eval boolean.
+ *
+ * @param value the value
+ * @return the boolean
+ */
+ public static Boolean eval(Object value) {
+
+ if (value instanceof String) {
+ value = ((String) value).toLowerCase();
+ }
+ if (heatFalse.contains(value)) {
+ return false;
+ } else if (heatTrue.contains(value)) {
+ return true;
+ } else {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withId(ErrorCodes.INVALID_BOOLEAN)
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage("Invalid boolean value [" + value + "].").build());
+ }
+
+ }
- /**
- * Is value boolean boolean.
- *
- * @param value the value
- * @return the boolean
- */
- public static boolean isValueBoolean(Object value) {
- try {
- eval(value);
- return true;
- } catch (CoreException ce) {
- LOG.error("Failed to evaluate value as boolean: {}", value, ce);
- return false;
+ /**
+ * Is value boolean boolean.
+ *
+ * @param value the value
+ * @return the boolean
+ */
+ public static boolean isValueBoolean(Object value) {
+ try {
+ eval(value);
+ return true;
+ } catch (CoreException ce) {
+ LOG.error("Failed to evaluate value as boolean: {}", value, ce);
+ return false;
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java
index 2bc549c058..35276b4f11 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,15 +20,28 @@
package org.openecomp.sdc.heat.datatypes.manifest;
-import org.apache.commons.collections4.CollectionUtils;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.function.Predicate;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.collections4.CollectionUtils;
+
+@Data
public class FileData {
protected static final Set<Type> heatFileTypes =
- new HashSet<>(Arrays.asList(Type.HEAT, Type.HEAT_NET, Type.HEAT_VOL));
+ new HashSet<>(Arrays.asList(Type.HEAT, Type.HEAT_NET, Type.HEAT_VOL));
+
+ @Getter(AccessLevel.NONE)
+ @Setter(AccessLevel.NONE)
private Boolean isBase;
private String parentFile;
private String file;
@@ -40,8 +53,8 @@ public class FileData {
}
public static boolean isHeatFile(Type type) {
- return heatFileTypes.contains(type);
- }
+ return heatFileTypes.contains(type);
+ }
public Boolean getBase() {
return isBase;
@@ -51,43 +64,11 @@ public class FileData {
isBase = base;
}
- public String getFile() {
- return file;
- }
-
- public void setFile(String file) {
- this.file = file;
- }
-
- public String getParentFile() {
- return parentFile;
- }
-
- public void setParentFile(String parentFile) {
- this.parentFile = parentFile;
- }
-
- public Type getType() {
- return type;
- }
-
- public void setType(Type type) {
- this.type = type;
- }
-
- public List<FileData> getData() {
- return data;
- }
-
- public void setData(List<FileData> data) {
- this.data = data;
- }
-
/**
- * Add file data.
- *
- * @param data the data
- */
+ * Add file data.
+ *
+ * @param data the data
+ */
public void addFileData(FileData data) {
if (CollectionUtils.isEmpty(this.data)) {
this.data = new ArrayList<>();
@@ -95,40 +76,32 @@ public class FileData {
this.data.add(data);
}
+ @AllArgsConstructor
+ @Getter
public enum Type {
-
- HEAT("HEAT"),
- HEAT_ENV("HEAT_ENV"),
- HEAT_NET("HEAT_NET"),
- HEAT_VOL("HEAT_VOL"),
- CHEF("CHEF"),
- PUPPET("PUPPET"),
- SHELL("SHELL"),
- YANG("YANG"),
- YANG_XML("YANG_XML"),
- BPEL("BPEL"),
- DG_XML("DG_XML"),
- MURANO_PKG("MURANO_PKG"),
- VENDOR_LICENSE("VENDOR_LICENSE"),
- VF_LICENSE("VF_LICENSE"),
- OTHER("OTHER");
+ HEAT("HEAT"),
+ HEAT_ENV("HEAT_ENV"),
+ HEAT_NET("HEAT_NET"),
+ HEAT_VOL("HEAT_VOL"),
+ CHEF("CHEF"),
+ PUPPET("PUPPET"),
+ SHELL("SHELL"),
+ YANG("YANG"),
+ YANG_XML("YANG_XML"),
+ BPEL("BPEL"),
+ DG_XML("DG_XML"),
+ MURANO_PKG("MURANO_PKG"),
+ VENDOR_LICENSE("VENDOR_LICENSE"),
+ VF_LICENSE("VF_LICENSE"),
+ OTHER("OTHER");
private String displayName;
- Type(String displayName) {
- this.displayName = displayName;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
public static boolean isArtifact(Type fileType) {
- return !Arrays.asList(HEAT,HEAT_ENV, HEAT_VOL).contains(fileType);
+ return !Arrays.asList(HEAT, HEAT_ENV, HEAT_VOL).contains(fileType);
}
- public static boolean canBeAssociated(Type fileType)
- {
+ public static boolean canBeAssociated(Type fileType) {
return HEAT_VOL == fileType;
}
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestContent.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestContent.java
index d89717125a..107b060094 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestContent.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestContent.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,42 +22,13 @@ package org.openecomp.sdc.heat.datatypes.manifest;
import java.util.List;
-public class ManifestContent {
-
- String name;
- String description;
- String version;
- List<FileData> data;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
+import lombok.Data;
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public List<FileData> getData() {
- return data;
- }
+@Data
+public class ManifestContent {
- public void setData(List<FileData> data) {
- this.data = data;
- }
+ private String name;
+ private String description;
+ private String version;
+ private List<FileData> data;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestFile.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestFile.java
index 607f52a86d..6a62740bf5 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestFile.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/ManifestFile.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,24 +20,11 @@
package org.openecomp.sdc.heat.datatypes.manifest;
-public class ManifestFile {
-
- String name;
- ManifestContent content;
-
- public String getName() {
- return name;
- }
+import lombok.Data;
- public void setName(String name) {
- this.name = name;
- }
-
- public ManifestContent getContent() {
- return content;
- }
+@Data
+public class ManifestFile {
- public void setContent(ManifestContent content) {
- this.content = content;
- }
+ private String name;
+ private ManifestContent content;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Constraint.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Constraint.java
index ebbb064ce9..b3658bf5b1 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Constraint.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Constraint.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,56 +23,35 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.ArrayList;
import java.util.List;
-public class Constraint {
- private Object[] length;
- private Integer[] range;
- private List<Object> validValues;
- private String pattern;
-
- public Constraint() {
- }
-
- public Integer[] getRange() {
- return range;
- }
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Setter;
- public void setRange(Integer[] inRange) {
- this.range = new Integer[]{inRange[0], inRange[1]};
- }
-
- public List<Object> getValidValues() {
- return validValues;
- }
+@Data
+public class Constraint {
- public void setValidValues(List<Object> validValues) {
- this.validValues = validValues;
- }
+ private Object[] length;
+ @Setter(AccessLevel.NONE)
+ private Integer[] range;
+ private List<Object> validValues;
+ private String pattern;
- /**
- * Add valid value.
- *
- * @param validValue the valid value
- */
- public void addValidValue(Object validValue) {
- if (this.validValues == null) {
- this.validValues = new ArrayList<>();
+ public Constraint() {
}
- validValues.add(validValue);
- }
- public Object[] getLength() {
- return length;
- }
-
- public void setLength(Object[] length) {
- this.length = length;
- }
-
- public String getPattern() {
- return pattern;
- }
+ public void setRange(Integer[] inRange) {
+ this.range = new Integer[] {inRange[0], inRange[1]};
+ }
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
+ /**
+ * Add valid value.
+ *
+ * @param validValue the valid value
+ */
+ public void addValidValue(Object validValue) {
+ if (this.validValues == null) {
+ this.validValues = new ArrayList<>();
+ }
+ validValues.add(validValue);
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailResourceTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailResourceTypes.java
index 47eaefafec..7538f11593 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailResourceTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailResourceTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,45 +25,45 @@ import java.util.Map;
import java.util.Objects;
public enum ContrailResourceTypes {
- ATTACH_POLICY("OS::Contrail::AttachPolicy"),
- SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
- SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
- NETWORK_POLICY("OS::Contrail::NetworkPolicy"),
- VIRTUAL_NETWORK("OS::Contrail::VirtualNetwork");
+ ATTACH_POLICY("OS::Contrail::AttachPolicy"),
+ SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
+ SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
+ NETWORK_POLICY("OS::Contrail::NetworkPolicy"),
+ VIRTUAL_NETWORK("OS::Contrail::VirtualNetwork");
- private static Map<String, ContrailResourceTypes> stringToContrailResourceTypeMap;
+ private static Map<String, ContrailResourceTypes> stringToContrailResourceTypeMap;
- static {
- stringToContrailResourceTypeMap = new HashMap<>();
+ static {
+ stringToContrailResourceTypeMap = new HashMap<>();
- for (ContrailResourceTypes type : ContrailResourceTypes.values()) {
- stringToContrailResourceTypeMap.put(type.contrailResourceType, type);
+ for (ContrailResourceTypes type : ContrailResourceTypes.values()) {
+ stringToContrailResourceTypeMap.put(type.contrailResourceType, type);
+ }
}
- }
- private String contrailResourceType;
+ private String contrailResourceType;
- ContrailResourceTypes(String contrailResourceType) {
- this.contrailResourceType = contrailResourceType;
- }
+ ContrailResourceTypes(String contrailResourceType) {
+ this.contrailResourceType = contrailResourceType;
+ }
- /**
- * Find by contrail v 2 resource contrail resource types.
- *
- * @param contrailV2Resource the contrail v 2 resource
- * @return the contrail resource types
- */
- public static ContrailResourceTypes findByContrailV2Resource(String contrailV2Resource) {
- return contrailV2Resource == null ? null
- : stringToContrailResourceTypeMap.get(contrailV2Resource);
+ /**
+ * Find by contrail v 2 resource contrail resource types.
+ *
+ * @param contrailV2Resource the contrail v 2 resource
+ * @return the contrail resource types
+ */
+ public static ContrailResourceTypes findByContrailV2Resource(String contrailV2Resource) {
+ return contrailV2Resource == null ? null
+ : stringToContrailResourceTypeMap.get(contrailV2Resource);
- }
+ }
- public static boolean isResourceTypeContrail(String resourceType) {
- return Objects.nonNull(findByContrailV2Resource(resourceType));
- }
+ public static boolean isResourceTypeContrail(String resourceType) {
+ return Objects.nonNull(findByContrailV2Resource(resourceType));
+ }
- public String getContrailResourceType() {
- return contrailResourceType;
- }
+ public String getContrailResourceType() {
+ return contrailResourceType;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailV2ResourceTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailV2ResourceTypes.java
index ff706093f8..40253ad1be 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailV2ResourceTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ContrailV2ResourceTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,36 +25,36 @@ import java.util.Map;
import java.util.Objects;
public enum ContrailV2ResourceTypes {
- NETWROK_IPAM("OS::ContrailV2::NetworkIpam"),
- VIRTUAL_NETWORK("OS::ContrailV2::VirtualNetwork"),
- NETWORK_POLICY("OS::ContrailV2::NetworkPolicy"),
- VIRTUAL_MACHINE_INTERFACE("OS::ContrailV2::VirtualMachineInterface");
+ NETWROK_IPAM("OS::ContrailV2::NetworkIpam"),
+ VIRTUAL_NETWORK("OS::ContrailV2::VirtualNetwork"),
+ NETWORK_POLICY("OS::ContrailV2::NetworkPolicy"),
+ VIRTUAL_MACHINE_INTERFACE("OS::ContrailV2::VirtualMachineInterface");
- private static Map<String, ContrailV2ResourceTypes> stringToContrailV2ResourceTypeMap;
+ private static Map<String, ContrailV2ResourceTypes> stringToContrailV2ResourceTypeMap;
- static {
- stringToContrailV2ResourceTypeMap = new HashMap<>();
+ static {
+ stringToContrailV2ResourceTypeMap = new HashMap<>();
- for (ContrailV2ResourceTypes type : ContrailV2ResourceTypes.values()) {
- stringToContrailV2ResourceTypeMap.put(type.contrailV2ResourceType, type);
+ for (ContrailV2ResourceTypes type : ContrailV2ResourceTypes.values()) {
+ stringToContrailV2ResourceTypeMap.put(type.contrailV2ResourceType, type);
+ }
}
- }
- private String contrailV2ResourceType;
+ private String contrailV2ResourceType;
- ContrailV2ResourceTypes(String contrailV2ResourceType) {
- this.contrailV2ResourceType = contrailV2ResourceType;
- }
+ ContrailV2ResourceTypes(String contrailV2ResourceType) {
+ this.contrailV2ResourceType = contrailV2ResourceType;
+ }
- public static ContrailV2ResourceTypes findByContrailV2Resource(String contrailV2Resource) {
- return stringToContrailV2ResourceTypeMap.get(contrailV2Resource);
- }
+ public static ContrailV2ResourceTypes findByContrailV2Resource(String contrailV2Resource) {
+ return stringToContrailV2ResourceTypeMap.get(contrailV2Resource);
+ }
- public static boolean isResourceTypeContrailV2(String resourceType) {
- return Objects.nonNull(findByContrailV2Resource(resourceType));
- }
+ public static boolean isResourceTypeContrailV2(String resourceType) {
+ return Objects.nonNull(findByContrailV2Resource(resourceType));
+ }
- public String getContrailV2ResourceType() {
- return contrailV2ResourceType;
- }
+ public String getContrailV2ResourceType() {
+ return contrailV2ResourceType;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Environment.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Environment.java
index b2f45d06d9..db5121b014 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Environment.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Environment.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,14 +22,10 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.Map;
-public class Environment {
- Map<String, Object> parameters;
+import lombok.Data;
- public Map<String, Object> getParameters() {
- return parameters;
- }
+@Data
+public class Environment {
- public void setParameters(Map<String, Object> parameters) {
- this.parameters = parameters;
- }
+ private Map<String, Object> parameters;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplate.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplate.java
index 294bb9e47e..3387c43840 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplate.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplate.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,68 +23,16 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.List;
import java.util.Map;
-public class HeatOrchestrationTemplate {
- String heat_template_version;
- String description;
- List<ParameterGroup> parameter_groups;
- Map<String, Parameter> parameters;
- Map<String, Resource> resources;
- Map<String, Output> outputs;
- Map<String, Object> conditions;
-
- public String getHeat_template_version() {
- return heat_template_version;
- }
-
- public void setHeat_template_version(String heat_template_version) {
- this.heat_template_version = heat_template_version;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<ParameterGroup> getParameter_groups() {
- return parameter_groups;
- }
-
- public void setParameter_groups(List<ParameterGroup> parameter_groups) {
- this.parameter_groups = parameter_groups;
- }
+import lombok.Data;
- public Map<String, Parameter> getParameters() {
- return parameters;
- }
-
- public void setParameters(Map<String, Parameter> parameters) {
- this.parameters = parameters;
- }
-
- public Map<String, Resource> getResources() {
- return resources;
- }
-
- public void setResources(Map<String, Resource> resources) {
- this.resources = resources;
- }
-
- public Map<String, Output> getOutputs() {
- return outputs;
- }
-
- public void setOutputs(Map<String, Output> outputs) {
- this.outputs = outputs;
- }
-
- public Map<String, Object> getConditions() {
- return conditions;
- }
+@Data
+public class HeatOrchestrationTemplate {
- public void setConditions(Map<String, Object> conditions) {
- this.conditions = conditions;
- }
+ private String heat_template_version;
+ private String description;
+ private List<ParameterGroup> parameter_groups;
+ private Map<String, Parameter> parameters;
+ private Map<String, Resource> resources;
+ private Map<String, Output> outputs;
+ private Map<String, Object> conditions;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatPseudoParameters.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatPseudoParameters.java
index c822a78a93..7ed8203bfe 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatPseudoParameters.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatPseudoParameters.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,39 +23,33 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.ArrayList;
import java.util.List;
-public enum HeatPseudoParameters {
- OS_STACK_NAME("OS::stack_name"),
- OS_STACK_ID("OS::stack_id"),
- OS_PROJECT_ID("OS::project_id");
-
- private static List<String> pseudoParameterNames;
+import lombok.Getter;
- static {
- pseudoParameterNames = new ArrayList<>();
- for (HeatPseudoParameters parameter : HeatPseudoParameters.values()) {
- pseudoParameterNames.add(parameter.getPseudoParameter());
+@Getter
+public enum HeatPseudoParameters {
+ OS_STACK_NAME("OS::stack_name"),
+ OS_STACK_ID("OS::stack_id"),
+ OS_PROJECT_ID("OS::project_id");
+
+ private static List<String> pseudoParameterNames;
+ private String pseudoParameter;
+
+ static {
+ pseudoParameterNames = new ArrayList<>();
+ for (HeatPseudoParameters parameter : HeatPseudoParameters.values()) {
+ pseudoParameterNames.add(parameter.getPseudoParameter());
+ }
}
- }
-
- private String pseudoParameter;
-
- HeatPseudoParameters(String pseudoParameter) {
- this.pseudoParameter = pseudoParameter;
- }
- public static List<String> getPseudoParameterNames() {
- return pseudoParameterNames;
- }
-
- public static void setPseudoParameterNames(List<String> pseudoParameterNames) {
- HeatPseudoParameters.pseudoParameterNames = pseudoParameterNames;
- }
+ HeatPseudoParameters(String pseudoParameter) {
+ this.pseudoParameter = pseudoParameter;
+ }
- public String getPseudoParameter() {
- return pseudoParameter;
- }
+ public static List<String> getPseudoParameterNames() {
+ return pseudoParameterNames;
+ }
- public void setPseudoParameter(String pseudoParameter) {
- this.pseudoParameter = pseudoParameter;
- }
+ public static void setPseudoParameterNames(List<String> pseudoParameterNames) {
+ HeatPseudoParameters.pseudoParameterNames = pseudoParameterNames;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypes.java
index b73fe385a6..a9598eb67f 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,93 +27,85 @@ import java.util.Map;
import java.util.Objects;
public enum HeatResourcesTypes {
- NOVA_SERVER_RESOURCE_TYPE("OS::Nova::Server"),
- NOVA_SERVER_GROUP_RESOURCE_TYPE("OS::Nova::ServerGroup"),
- NEUTRON_PORT_RESOURCE_TYPE("OS::Neutron::Port"),
- CONTRAIL_NETWORK_RULE_RESOURCE_TYPE("OS::Contrail::NetworkPolicy"),
- CONTRAIL_NETWORK_ATTACH_RULE_RESOURCE_TYPE("OS::Contrail::AttachPolicy"),
- CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::Contrail::VirtualNetwork"),
- CINDER_VOLUME_RESOURCE_TYPE("OS::Cinder::Volume"),
- CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE("OS::Cinder::VolumeAttachment"),
- NEUTRON_NET_RESOURCE_TYPE("OS::Neutron::Net"),
- NEUTRON_SUBNET_RESOURCE_TYPE("OS::Neutron::Subnet"),
- NEUTRON_SECURITY_GROUP_RESOURCE_TYPE("OS::Neutron::SecurityGroup"),
- HEAT_SOFTWARE_CONFIG_TYPE("OS::Heat::SoftwareConfig"),
- HEAT_CLOUD_CONFIG_TYPE("OS::Heat::CloudConfig"),
- HEAT_MULTIPART_MIME_TYPE("OS::Heat::MultipartMime"),
- HEAT_CONTRAIL_NETWORK_IPAM_TYPE("OS::Contrail::NetworkIpam"),
- CONTRAIL_V2_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::ContrailV2::VirtualNetwork"),
- CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE("OS::ContrailV2::VirtualMachineInterface"),
- CONTRAIL_SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
- CONTRAIL_SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
- CONTRAIL_V2_NETWORK_RULE_RESOURCE_TYPE("OS::ContrailV2::NetworkPolicy"),
- RESOURCE_GROUP_RESOURCE_TYPE("OS::Heat::ResourceGroup");
-
- private static Map<String, HeatResourcesTypes> stringToHeatResourceTypeMap;
-
- static {
- stringToHeatResourceTypeMap = new HashMap<>();
-
- for (HeatResourcesTypes type : HeatResourcesTypes.values()) {
- stringToHeatResourceTypeMap.put(type.heatResource, type);
+ NOVA_SERVER_RESOURCE_TYPE("OS::Nova::Server"),
+ NOVA_SERVER_GROUP_RESOURCE_TYPE("OS::Nova::ServerGroup"),
+ NEUTRON_PORT_RESOURCE_TYPE("OS::Neutron::Port"),
+ CONTRAIL_NETWORK_RULE_RESOURCE_TYPE("OS::Contrail::NetworkPolicy"),
+ CONTRAIL_NETWORK_ATTACH_RULE_RESOURCE_TYPE("OS::Contrail::AttachPolicy"),
+ CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::Contrail::VirtualNetwork"),
+ CINDER_VOLUME_RESOURCE_TYPE("OS::Cinder::Volume"),
+ CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE("OS::Cinder::VolumeAttachment"),
+ NEUTRON_NET_RESOURCE_TYPE("OS::Neutron::Net"),
+ NEUTRON_SUBNET_RESOURCE_TYPE("OS::Neutron::Subnet"),
+ NEUTRON_SECURITY_GROUP_RESOURCE_TYPE("OS::Neutron::SecurityGroup"),
+ HEAT_SOFTWARE_CONFIG_TYPE("OS::Heat::SoftwareConfig"),
+ HEAT_CLOUD_CONFIG_TYPE("OS::Heat::CloudConfig"),
+ HEAT_MULTIPART_MIME_TYPE("OS::Heat::MultipartMime"),
+ HEAT_CONTRAIL_NETWORK_IPAM_TYPE("OS::Contrail::NetworkIpam"),
+ CONTRAIL_V2_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::ContrailV2::VirtualNetwork"),
+ CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE("OS::ContrailV2::VirtualMachineInterface"),
+ CONTRAIL_SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
+ CONTRAIL_SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
+ CONTRAIL_V2_NETWORK_RULE_RESOURCE_TYPE("OS::ContrailV2::NetworkPolicy"),
+ RESOURCE_GROUP_RESOURCE_TYPE("OS::Heat::ResourceGroup");
+
+ private static Map<String, HeatResourcesTypes> stringToHeatResourceTypeMap;
+ private String heatResource;
+
+ static {
+ stringToHeatResourceTypeMap = new HashMap<>();
+
+ for (HeatResourcesTypes type : HeatResourcesTypes.values()) {
+ stringToHeatResourceTypeMap.put(type.heatResource, type);
+ }
}
- }
-
- private String heatResource;
-
-
- HeatResourcesTypes(String heatResource) {
- this.heatResource = heatResource;
- }
-
- public static HeatResourcesTypes findByHeatResource(String heatResource) {
- return stringToHeatResourceTypeMap.get(heatResource);
- }
-
- public static boolean isResourceTypeValid(String resourceType) {
- return Objects.nonNull(findByHeatResource(resourceType));
- }
- /**
- * Is resource expected to be exposed boolean.
- *
- * @param resourceType the resource type
- * @return the boolean
- */
- public static boolean isResourceExpectedToBeExposed(String resourceType) {
- //todo - check
- return (resourceType.equals(NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())
- || resourceType.equals(CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource())
- || resourceType.equals(NEUTRON_NET_RESOURCE_TYPE.getHeatResource())
- || resourceType.equals(CINDER_VOLUME_RESOURCE_TYPE.getHeatResource())
- || resourceType.equals(NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())
- );
- }
-
- /**
- * Gets list for resource type.
- *
- * @param types the types
- * @return the list for resource type
- */
- public static Map<HeatResourcesTypes, List<String>> getListForResourceType(
- HeatResourcesTypes... types) {
- Map<HeatResourcesTypes, List<String>> result = new HashMap<>();
-
- for (HeatResourcesTypes type : types) {
- result.put(type, new ArrayList<>());
+ HeatResourcesTypes(String heatResource) {
+ this.heatResource = heatResource;
}
- return result;
- }
+ public static HeatResourcesTypes findByHeatResource(String heatResource) {
+ return stringToHeatResourceTypeMap.get(heatResource);
+ }
- public String getHeatResource() {
+ public static boolean isResourceTypeValid(String resourceType) {
+ return Objects.nonNull(findByHeatResource(resourceType));
+ }
- return heatResource;
- }
+ /**
+ * Is resource expected to be exposed boolean.
+ *
+ * @param resourceType the resource type
+ * @return the boolean
+ */
+ public static boolean isResourceExpectedToBeExposed(String resourceType) {
+ //todo - check
+ return (resourceType.equals(NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())
+ || resourceType.equals(CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource())
+ || resourceType.equals(NEUTRON_NET_RESOURCE_TYPE.getHeatResource())
+ || resourceType.equals(CINDER_VOLUME_RESOURCE_TYPE.getHeatResource())
+ || resourceType.equals(NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())
+ );
+ }
- public void setHeatResource(String heatResource) {
- this.heatResource = heatResource;
- }
+ /**
+ * Gets list for resource type.
+ *
+ * @param types the types
+ * @return the list for resource type
+ */
+ public static Map<HeatResourcesTypes, List<String>> getListForResourceType(
+ HeatResourcesTypes... types) {
+ Map<HeatResourcesTypes, List<String>> result = new HashMap<>();
+
+ for (HeatResourcesTypes type : types) {
+ result.put(type, new ArrayList<>());
+ }
+
+ return result;
+ }
+ public String getHeatResource() {
+ return heatResource;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Output.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Output.java
index 8222edded2..343205d171 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Output.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Output.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,23 +20,11 @@
package org.openecomp.sdc.heat.datatypes.model;
-public class Output {
- String description;
- Object value;
-
- public String getDescription() {
- return description;
- }
+import lombok.Data;
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Object getValue() {
- return value;
- }
+@Data
+public class Output {
- public void setValue(Object value) {
- this.value = value;
- }
+ String description;
+ Object value;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Parameter.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Parameter.java
index d419738942..81372aa68c 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Parameter.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Parameter.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,68 +23,16 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.List;
import java.util.Map;
-public class Parameter {
- String type;
- String label;
- String description;
- Object _default;
- boolean hidden;
- List<Map<String, Object>> constraints;
- boolean immutable;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
+import lombok.Data;
- public Object get_default() {
- return _default;
- }
-
- public void set_default(Object _default) {
- this._default = _default;
- }
-
- public boolean isHidden() {
- return hidden;
- }
-
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
-
- public List<Map<String, Object>> getConstraints() {
- return constraints;
- }
-
- public void setConstraints(List<Map<String, Object>> constraints) {
- this.constraints = constraints;
- }
-
- public boolean isImmutable() {
- return immutable;
- }
+@Data
+public class Parameter {
- public void setImmutable(boolean immutable) {
- this.immutable = immutable;
- }
+ private String type;
+ private String label;
+ private String description;
+ private Object _default;
+ private boolean hidden;
+ private List<Map<String, Object>> constraints;
+ private boolean immutable;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterGroup.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterGroup.java
index 8ab066f4a4..4595466436 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterGroup.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterGroup.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,32 +22,12 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.List;
-public class ParameterGroup {
- String label;
- String description;
- List<String> parameters;
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
+import lombok.Data;
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<String> getParameters() {
- return parameters;
- }
+@Data
+public class ParameterGroup {
- public void setParameters(List<String> parameters) {
- this.parameters = parameters;
- }
+ private String label;
+ private String description;
+ private List<String> parameters;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterType.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterType.java
index 37c430ec36..3f6dc9f7ce 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterType.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ParameterType.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,23 +20,18 @@
package org.openecomp.sdc.heat.datatypes.model;
-public enum ParameterType {
-
- STRING("string"),
- NUMBER("number"),
- JSON("json"),
- BOOLEAN("boolean"),
- COMMA_DELIMITED_LIST("comma_delimited_list");
-
- private String displayName;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
- ParameterType(String displayName) {
- this.displayName = displayName;
- }
-
- public String getDisplayName() {
- return displayName;
- }
+@AllArgsConstructor
+@Getter
+public enum ParameterType {
+ STRING("string"),
+ NUMBER("number"),
+ JSON("json"),
+ BOOLEAN("boolean"),
+ COMMA_DELIMITED_LIST("comma_delimited_list");
+ private String displayName;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PolicyTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PolicyTypes.java
index 3195e61fe5..77a7cd4552 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PolicyTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PolicyTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,38 +24,31 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
public enum PolicyTypes {
- AFFINITY("affinity"),
- ANTI_AFFINITY("anti-affinity");
+ AFFINITY("affinity"),
+ ANTI_AFFINITY("anti-affinity");
- private static Map<String, PolicyTypes> stringToPolicyTypesMap;
+ private static Map<String, PolicyTypes> stringToPolicyTypesMap;
- static {
- stringToPolicyTypesMap = new HashMap<>();
- for (PolicyTypes type : PolicyTypes.values()) {
- stringToPolicyTypesMap.put(type.policy, type);
+ static {
+ stringToPolicyTypesMap = new HashMap<>();
+ for (PolicyTypes type : PolicyTypes.values()) {
+ stringToPolicyTypesMap.put(type.policy, type);
+ }
}
- }
-
- private String policy;
-
- PolicyTypes(String policy) {
- this.policy = policy;
- }
- public static PolicyTypes findByPolicy(String policy) {
- return stringToPolicyTypesMap.get(policy);
- }
+ private String policy;
- public static boolean isGivenPolicyValid(String policyToCheck) {
- return Objects.nonNull(findByPolicy(policyToCheck));
- }
-
- public String getPolicy() {
- return policy;
- }
+ public static PolicyTypes findByPolicy(String policy) {
+ return stringToPolicyTypesMap.get(policy);
+ }
- public void setPolicy(String policy) {
- this.policy = policy;
- }
+ public static boolean isGivenPolicyValid(String policyToCheck) {
+ return Objects.nonNull(findByPolicy(policyToCheck));
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PropertiesMapKeyTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PropertiesMapKeyTypes.java
index e8d43fc10c..46673c2eaa 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PropertiesMapKeyTypes.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/PropertiesMapKeyTypes.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,23 +20,16 @@
package org.openecomp.sdc.heat.datatypes.model;
-public enum PropertiesMapKeyTypes {
- IMAGE("image"),
- FLAVOR("flavor"),
- NETWORKS("networks"),
- RESOURCE_DEF("resource_def");
-
- private String keyMap;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
- PropertiesMapKeyTypes(String keyMap) {
- this.keyMap = keyMap;
- }
-
- public String getKeyMap() {
- return keyMap;
- }
+@Getter
+@AllArgsConstructor
+public enum PropertiesMapKeyTypes {
+ IMAGE("image"),
+ FLAVOR("flavor"),
+ NETWORKS("networks"),
+ RESOURCE_DEF("resource_def");
- public void setKeyMap(String keyMap) {
- this.keyMap = keyMap;
- }
+ private String keyMap;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Resource.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Resource.java
index 2c70105da9..4703f43632 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Resource.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/Resource.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,71 +22,27 @@ package org.openecomp.sdc.heat.datatypes.model;
import java.util.Map;
-public class Resource {
- String type;
- Map<String, Object> properties;
- Object metadata;
- Object depends_on;
- Object update_policy;
- Object deletion_policy;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public Object getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Object metadata) {
- this.metadata = metadata;
- }
+import lombok.Data;
- public Object getDepends_on() {
- return depends_on;
- }
-
- public void setDepends_on(Object depends_on) {
- this.depends_on = depends_on;
- }
-
- public Object getUpdate_policy() {
- return update_policy;
- }
-
- public void setUpdate_policy(Object update_policy) {
- this.update_policy = update_policy;
- }
-
- public Object getDeletion_policy() {
- return deletion_policy;
- }
-
- public void setDeletion_policy(Object deletion_policy) {
- this.deletion_policy = deletion_policy;
- }
+@Data
+public class Resource {
- @Override
- public String toString() {
- return "Resource{"
- + "type='" + type + '\''
- + ", properties=" + properties
- + ", metadata=" + metadata
- + ", depends_on=" + depends_on
- + ", update_policy='" + update_policy + '\''
- + ", deletion_policy='" + deletion_policy + '\''
- + '}';
- }
+ private String type;
+ private Map<String, Object> properties;
+ private Object metadata;
+ private Object depends_on;
+ private Object update_policy;
+ private Object deletion_policy;
+
+ @Override
+ public String toString() {
+ return "Resource{"
+ + "type='" + type + '\''
+ + ", properties=" + properties
+ + ", metadata=" + metadata
+ + ", depends_on=" + depends_on
+ + ", update_policy='" + update_policy + '\''
+ + ", deletion_policy='" + deletion_policy + '\''
+ + '}';
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceReferenceFunctions.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceReferenceFunctions.java
index b36d130597..9c1feb2cc4 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceReferenceFunctions.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceReferenceFunctions.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,25 +20,17 @@
package org.openecomp.sdc.heat.datatypes.model;
-public enum ResourceReferenceFunctions {
- GET_RESOURCE("get_resource"),
- GET_PARAM("get_param"),
- GET_ATTR("get_attr"),
- GET_FILE("get_file"),
- SCHEDULER_HINTS("scheduler_hints");
-
-
- private String function;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
- ResourceReferenceFunctions(String function) {
- this.function = function;
- }
-
- public String getFunction() {
- return function;
- }
+@AllArgsConstructor
+@Getter
+public enum ResourceReferenceFunctions {
+ GET_RESOURCE("get_resource"),
+ GET_PARAM("get_param"),
+ GET_ATTR("get_attr"),
+ GET_FILE("get_file"),
+ SCHEDULER_HINTS("scheduler_hints");
- public void setFunction(String function) {
- this.function = function;
- }
+ private String function;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceTypeToMessageString.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceTypeToMessageString.java
index d7ede70942..c4a13588a1 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceTypeToMessageString.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/model/ResourceTypeToMessageString.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,32 +24,31 @@ import java.util.HashMap;
import java.util.Map;
public enum ResourceTypeToMessageString {
- SERVER_GROUP(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE, "ServerGroup"),
- SECURITY_GROUP(HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE, "SecurityGroup"),
- NETWORK_POLICY(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE, "NetworkPolicy");
+ SERVER_GROUP(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE, "ServerGroup"),
+ SECURITY_GROUP(HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE, "SecurityGroup"),
+ NETWORK_POLICY(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE, "NetworkPolicy");
- private static Map<HeatResourcesTypes, String> resourcesTypesStringMap;
+ private static Map<HeatResourcesTypes, String> resourcesTypesStringMap;
- static {
- resourcesTypesStringMap = new HashMap<>();
+ static {
+ resourcesTypesStringMap = new HashMap<>();
- for (ResourceTypeToMessageString resourceTypeToMessageString : ResourceTypeToMessageString
- .values()) {
- resourcesTypesStringMap
- .put(resourceTypeToMessageString.type, resourceTypeToMessageString.messageString);
+ for (ResourceTypeToMessageString resourceTypeToMessageString : ResourceTypeToMessageString
+ .values()) {
+ resourcesTypesStringMap
+ .put(resourceTypeToMessageString.type, resourceTypeToMessageString.messageString);
+ }
}
- }
- private String messageString;
- private HeatResourcesTypes type;
+ private String messageString;
+ private HeatResourcesTypes type;
+ ResourceTypeToMessageString(HeatResourcesTypes type, String messageString) {
+ this.type = type;
+ this.messageString = messageString;
+ }
- ResourceTypeToMessageString(HeatResourcesTypes type, String messgageString) {
- this.type = type;
- this.messageString = messgageString;
- }
-
- public static String getTypeForMessageFromResourceType(HeatResourcesTypes type) {
- return resourcesTypesStringMap.get(type);
- }
+ public static String getTypeForMessageFromResourceType(HeatResourcesTypes type) {
+ return resourcesTypesStringMap.get(type);
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/Artifact.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/Artifact.java
index 95ae4e59c7..9d1fbe3cb3 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/Artifact.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/Artifact.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,85 +20,50 @@
package org.openecomp.sdc.heat.datatypes.structure;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
-import java.util.ArrayList;
-import java.util.List;
-
+@Getter
+@Setter
+@EqualsAndHashCode
public class Artifact implements Comparable<Artifact> {
- private String fileName;
- private FileData.Type type;
- private List<ErrorMessage> errors;
-
- public Artifact(String fileName, FileData.Type type) {
- this.fileName = fileName;
- this.type = type;
- }
-
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String name) {
- this.fileName = name;
- }
+ private String fileName;
+ @Setter(AccessLevel.NONE)
+ @EqualsAndHashCode.Exclude
+ private FileData.Type type;
- public FileData.Type getType() {
- return type;
- }
+ @EqualsAndHashCode.Exclude
+ private List<ErrorMessage> errors;
- public List<ErrorMessage> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorMessage> errors) {
- this.errors = errors;
- }
-
- /**
- * Add error to error list.
- *
- * @param error the error
- */
- public void addErrorToErrorList(ErrorMessage error) {
- if (this.errors == null || this.errors.isEmpty()) {
- this.errors = new ArrayList<>();
+ public Artifact(String fileName, FileData.Type type) {
+ this.fileName = fileName;
+ this.type = type;
}
- this.errors.add(error);
- }
-
- @Override
- public int hashCode() {
- int result = fileName.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
+ /**
+ * Add error to error list.
+ *
+ * @param error the error
+ */
+ public void addErrorToErrorList(ErrorMessage error) {
+ if (this.errors == null || this.errors.isEmpty()) {
+ this.errors = new ArrayList<>();
+ }
+
+ this.errors.add(error);
}
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
-
- Artifact artifact = (Artifact) obj;
- if (!fileName.equals(artifact.fileName)) {
- return false;
+ @Override
+ public int compareTo(Artifact artifact) {
+ return artifact.getFileName().compareTo(this.getFileName());
}
- return true;
-
- }
-
- @Override
- public int compareTo(Artifact artifact) {
- return artifact.getFileName().compareTo(this.getFileName());
- }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java
index 5313d4d370..8d1b5912df 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,331 +20,253 @@
package org.openecomp.sdc.heat.datatypes.structure;
-
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.heat.datatypes.manifest.FileData;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+
+@Data
public class HeatStructureTree implements Comparable<HeatStructureTree> {
- private String fileName;
- private FileData.Type type;
- private Boolean isBase;
- private HeatStructureTree env;
- private List<ErrorMessage> errors;
- private Set<HeatStructureTree> heat;
- private Set<HeatStructureTree> volume;
- private Set<HeatStructureTree> network;
- private Set<HeatStructureTree> nested;
- private Set<HeatStructureTree> other;
- private Set<Artifact> artifacts;
-
- public HeatStructureTree() {
- }
-
- ;
-
- public HeatStructureTree(String fileName, boolean isBase) {
- setBase(isBase);
- setFileName(fileName);
- }
-
- /**
- * Gets heat structure tree by name.
- *
- * @param filesSet the files set
- * @param filename the filename
- * @return the heat structure tree by name
- */
- public static HeatStructureTree getHeatStructureTreeByName(Set<HeatStructureTree> filesSet,
- String filename) {
- for (HeatStructureTree heatStructureTree : filesSet) {
- if (heatStructureTree.getFileName().equals(filename)) {
- return heatStructureTree;
- }
- }
+ private String fileName;
+ private FileData.Type type;
- return null;
- }
-
- public void setType(FileData.Type type) {
- this.type = type;
- }
-
- public Boolean getBase() {
- return isBase;
- }
-
- public void setBase(Boolean base) {
- isBase = base;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String file) {
- this.fileName = file;
- }
-
- @JsonProperty(value = "heat")
- public Set<HeatStructureTree> getHeat() {
- return heat;
- }
-
- public void setHeat(Set<HeatStructureTree> heat) {
- this.heat = heat;
- }
-
- public Set<HeatStructureTree> getNested() {
- return nested;
- }
-
- public void setNested(Set<HeatStructureTree> nested) {
- this.nested = nested;
- }
-
- public Set<Artifact> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(Set<Artifact> artifacts) {
- this.artifacts = artifacts;
- }
-
- /**
- * Add heat structure tree to nested heat list.
- *
- * @param heatStructureTree the heat structure tree
- */
- public void addHeatStructureTreeToNestedHeatList(HeatStructureTree heatStructureTree) {
- if (this.nested == null) {
- this.nested = new TreeSet<>();
+ @Getter(AccessLevel.NONE)
+ @Setter(AccessLevel.NONE)
+ private Boolean isBase;
+
+ private HeatStructureTree env;
+ private List<ErrorMessage> errors;
+ private Set<HeatStructureTree> heat;
+ private Set<HeatStructureTree> volume;
+ private Set<HeatStructureTree> network;
+ private Set<HeatStructureTree> nested;
+ private Set<HeatStructureTree> other;
+ private Set<Artifact> artifacts;
+
+ public HeatStructureTree() {
}
- if (!findItemInSetByName(this.nested, heatStructureTree)) {
- this.nested.add(heatStructureTree);
+
+ public HeatStructureTree(String fileName, boolean isBase) {
+ this.isBase = isBase;
+ this.fileName = fileName;
}
- }
-
- /**
- * Add artifact to artifact list.
- *
- * @param artifact the artifact
- */
- public void addArtifactToArtifactList(Artifact artifact) {
- if (this.artifacts == null || this.artifacts.isEmpty()) {
- this.artifacts = new TreeSet<>();
+
+ public Boolean getBase() {
+ return isBase;
}
- this.artifacts.add(artifact);
- }
-
- public HeatStructureTree getEnv() {
- return env;
- }
-
- public void setEnv(HeatStructureTree env) {
- this.env = env;
- }
-
- public Set<HeatStructureTree> getVolume() {
- return volume;
- }
-
- public void setVolume(Set<HeatStructureTree> volume) {
- this.volume = volume;
- }
-
- public Set<HeatStructureTree> getNetwork() {
- return network;
- }
-
- public void setNetwork(Set<HeatStructureTree> network) {
- this.network = network;
- }
-
- /**
- * Add network to network list.
- *
- * @param heatStructureTree the heat structure tree
- */
- public void addNetworkToNetworkList(HeatStructureTree heatStructureTree) {
- if (this.network == null) {
- this.network = new TreeSet<>();
+
+ public void setBase(Boolean isBase) {
+ this.isBase = isBase;
}
- if (!findItemInSetByName(this.network, heatStructureTree)) {
- this.network.add(heatStructureTree);
+
+ /**
+ * Gets heat structure tree by name.
+ *
+ * @param filesSet the files set
+ * @param filename the filename
+ * @return the heat structure tree by name
+ */
+ public static HeatStructureTree getHeatStructureTreeByName(Set<HeatStructureTree> filesSet,
+ String filename) {
+ for (HeatStructureTree heatStructureTree : filesSet) {
+ if (heatStructureTree.getFileName().equals(filename)) {
+ return heatStructureTree;
+ }
+ }
+
+ return null;
}
- }
-
- /**
- * Add volume file to volume list.
- *
- * @param heatStructureTree the heat structure tree
- */
- public void addVolumeFileToVolumeList(HeatStructureTree heatStructureTree) {
- if (this.volume == null) {
- this.volume = new TreeSet<>();
+
+ /**
+ * Add heat structure tree to nested heat list.
+ *
+ * @param heatStructureTree the heat structure tree
+ */
+ public void addHeatStructureTreeToNestedHeatList(HeatStructureTree heatStructureTree) {
+ if (this.nested == null) {
+ this.nested = new TreeSet<>();
+ }
+ if (!findItemInSetByName(this.nested, heatStructureTree)) {
+ this.nested.add(heatStructureTree);
+ }
}
- if (!findItemInSetByName(this.volume, heatStructureTree)) {
- this.volume.add(heatStructureTree);
+
+ /**
+ * Add artifact to artifact list.
+ *
+ * @param artifact the artifact
+ */
+ public void addArtifactToArtifactList(Artifact artifact) {
+ if (this.artifacts == null || this.artifacts.isEmpty()) {
+ this.artifacts = new TreeSet<>();
+ }
+ this.artifacts.add(artifact);
}
- }
-
- /**
- * Add heat to heat list.
- *
- * @param heat the heat
- */
- public void addHeatToHeatList(HeatStructureTree heat) {
- if (this.heat == null) {
- this.heat = new TreeSet<>();
+
+ /**
+ * Add network to network list.
+ *
+ * @param heatStructureTree the heat structure tree
+ */
+ public void addNetworkToNetworkList(HeatStructureTree heatStructureTree) {
+ if (this.network == null) {
+ this.network = new TreeSet<>();
+ }
+ if (!findItemInSetByName(this.network, heatStructureTree)) {
+ this.network.add(heatStructureTree);
+ }
}
- this.heat.add(heat);
- }
-
- /**
- * Add other to other list.
- *
- * @param other the other
- */
- public void addOtherToOtherList(HeatStructureTree other) {
- if (this.other == null) {
- this.other = new TreeSet<>();
+ /**
+ * Add volume file to volume list.
+ *
+ * @param heatStructureTree the heat structure tree
+ */
+ public void addVolumeFileToVolumeList(HeatStructureTree heatStructureTree) {
+ if (this.volume == null) {
+ this.volume = new TreeSet<>();
+ }
+ if (!findItemInSetByName(this.volume, heatStructureTree)) {
+ this.volume.add(heatStructureTree);
+ }
}
- this.other.add(other);
- }
-
- /**
- * Find item in set by name boolean.
- *
- * @param searchSet the search set
- * @param toFind the to find
- * @return the boolean
- */
- public boolean findItemInSetByName(Set<HeatStructureTree> searchSet, HeatStructureTree toFind) {
- for (HeatStructureTree heatStructureTree : searchSet) {
- if (heatStructureTree.getFileName().equals(toFind.getFileName())) {
- return true;
- }
+ /**
+ * Add heat to heat list.
+ *
+ * @param heat the heat
+ */
+ public void addHeatToHeatList(HeatStructureTree heat) {
+ if (this.heat == null) {
+ this.heat = new TreeSet<>();
+ }
+
+ this.heat.add(heat);
+ }
+ /**
+ * Add other to other list.
+ *
+ * @param other the other
+ */
+ public void addOtherToOtherList(HeatStructureTree other) {
+ if (this.other == null) {
+ this.other = new TreeSet<>();
+ }
+
+ this.other.add(other);
}
- return false;
- }
-
- /**
- * Remove from volume or network.
- *
- * @param fileNameToRemove the file name to remove
- * @param type the type
- */
- public void removeFromVolumeOrNetwork(String fileNameToRemove, FileData.Type type) {
- Set<HeatStructureTree> volumeOrNetworkSet =
- type.equals(FileData.Type.HEAT_VOL) ? this.volume : this.network;
- HeatStructureTree toRemove = getHeatStructureTreeByName(volumeOrNetworkSet, fileNameToRemove);
-
- volumeOrNetworkSet.remove(toRemove);
- }
-
- @Override
- public int hashCode() {
- int result1 = fileName != null ? fileName.hashCode() : 0;
- result1 = 31 * result1 + (env != null ? env.hashCode() : 0);
- result1 = 31 * result1 + (heat != null ? heat.hashCode() : 0);
- result1 = 31 * result1 + (volume != null ? volume.hashCode() : 0);
- result1 = 31 * result1 + (network != null ? network.hashCode() : 0);
- result1 = 31 * result1 + (artifacts != null ? artifacts.hashCode() : 0);
- result1 = 31 * result1 + (nested != null ? nested.hashCode() : 0);
- result1 = 31 * result1 + (errors != null ? errors.hashCode() : 0);
-
-
- return result1;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
+ /**
+ * Find item in set by name boolean.
+ *
+ * @param searchSet the search set
+ * @param toFind the to find
+ * @return the boolean
+ */
+ public boolean findItemInSetByName(Set<HeatStructureTree> searchSet, HeatStructureTree toFind) {
+ for (HeatStructureTree heatStructureTree : searchSet) {
+ if (heatStructureTree.getFileName().equals(toFind.getFileName())) {
+ return true;
+ }
+ }
+ return false;
}
- if (other == null || getClass() != other.getClass()) {
- return false;
+
+ /**
+ * Remove from volume or network.
+ *
+ * @param fileNameToRemove the file name to remove
+ * @param type the type
+ */
+ public void removeFromVolumeOrNetwork(String fileNameToRemove, FileData.Type type) {
+ Set<HeatStructureTree> volumeOrNetworkSet =
+ type.equals(FileData.Type.HEAT_VOL) ? this.volume : this.network;
+ HeatStructureTree toRemove = getHeatStructureTreeByName(volumeOrNetworkSet, fileNameToRemove);
+
+ volumeOrNetworkSet.remove(toRemove);
}
- HeatStructureTree heatStructureTree = (HeatStructureTree) other;
+ @Override
+ public int hashCode() {
+ int result1 = fileName != null ? fileName.hashCode() : 0;
+ result1 = 31 * result1 + (env != null ? env.hashCode() : 0);
+ result1 = 31 * result1 + (heat != null ? heat.hashCode() : 0);
+ result1 = 31 * result1 + (volume != null ? volume.hashCode() : 0);
+ result1 = 31 * result1 + (network != null ? network.hashCode() : 0);
+ result1 = 31 * result1 + (artifacts != null ? artifacts.hashCode() : 0);
+ result1 = 31 * result1 + (nested != null ? nested.hashCode() : 0);
+ result1 = 31 * result1 + (errors != null ? errors.hashCode() : 0);
- if (fileName != null ? !fileName.equals(heatStructureTree.fileName)
- : heatStructureTree.fileName != null) {
- return false;
- }
- if (env != null ? !env.equals(heatStructureTree.env) : heatStructureTree.env != null) {
- return false;
- }
- if (heat != null ? !heat.equals(heatStructureTree.heat) : heatStructureTree.heat != null) {
- return false;
- }
- if (volume != null ? !volume.equals(heatStructureTree.volume)
- : heatStructureTree.volume != null) {
- return false;
- }
- if (network != null ? !network.equals(heatStructureTree.network)
- : heatStructureTree.network != null) {
- return false;
- }
- if (artifacts != null ? !artifacts.equals(heatStructureTree.artifacts)
- : heatStructureTree.artifacts != null) {
- return false;
- }
- if (nested != null ? !nested.equals(heatStructureTree.nested)
- : heatStructureTree.nested != null) {
- return false;
- }
- if (errors != null ? !errors.equals(heatStructureTree.errors)
- : heatStructureTree.errors != null) {
- return false;
- }
- return true;
- }
-
- public List<ErrorMessage> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorMessage> errors) {
- this.errors = errors;
- }
-
- /**
- * Add error to errors list.
- *
- * @param error the error
- */
- public void addErrorToErrorsList(ErrorMessage error) {
- if (this.errors == null || this.errors.isEmpty()) {
- this.errors = new ArrayList<>();
- }
- if (!this.errors.contains(error)) {
- this.errors.add(error);
+ return result1;
}
- }
- public Set<HeatStructureTree> getOther() {
- return other;
- }
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null || getClass() != other.getClass()) {
+ return false;
+ }
+
+ HeatStructureTree heatStructureTree = (HeatStructureTree) other;
+
+ if (fileName != null ? !fileName.equals(heatStructureTree.fileName)
+ : heatStructureTree.fileName != null) {
+ return false;
+ }
+ if (env != null ? !env.equals(heatStructureTree.env) : heatStructureTree.env != null) {
+ return false;
+ }
+ if (heat != null ? !heat.equals(heatStructureTree.heat) : heatStructureTree.heat != null) {
+ return false;
+ }
+ if (volume != null ? !volume.equals(heatStructureTree.volume)
+ : heatStructureTree.volume != null) {
+ return false;
+ }
+ if (network != null ? !network.equals(heatStructureTree.network)
+ : heatStructureTree.network != null) {
+ return false;
+ }
+ if (artifacts != null ? !artifacts.equals(heatStructureTree.artifacts)
+ : heatStructureTree.artifacts != null) {
+ return false;
+ }
+ if (nested != null ? !nested.equals(heatStructureTree.nested)
+ : heatStructureTree.nested != null) {
+ return false;
+ }
+
+ return errors != null ? errors.equals(heatStructureTree.errors) : heatStructureTree.errors == null;
+ }
- public void setOther(Set<HeatStructureTree> other) {
- this.other = other;
- }
+ /**
+ * Add error to errors list.
+ *
+ * @param error the error
+ */
+ public void addErrorToErrorsList(ErrorMessage error) {
+ if (this.errors == null || this.errors.isEmpty()) {
+ this.errors = new ArrayList<>();
+ }
+ if (!this.errors.contains(error)) {
+ this.errors.add(error);
+ }
+ }
- @Override
- public int compareTo(HeatStructureTree obj) {
- return obj.getFileName().compareTo(this.getFileName());
- }
+ @Override
+ public int compareTo(HeatStructureTree obj) {
+ return obj.getFileName().compareTo(this.getFileName());
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/ValidationStructureList.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/ValidationStructureList.java
index f2acb2810d..27b87b9045 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/ValidationStructureList.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/ValidationStructureList.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,21 +20,14 @@
package org.openecomp.sdc.heat.datatypes.structure;
-public class ValidationStructureList {
- private HeatStructureTree importStructure;
-
- public ValidationStructureList() {
- }
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
- public ValidationStructureList(HeatStructureTree importStructure) {
- this.importStructure = importStructure;
- }
-
- public HeatStructureTree getImportStructure() {
- return importStructure;
- }
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ValidationStructureList {
- public void setImportStructure(HeatStructureTree importStructure) {
- this.importStructure = importStructure;
- }
+ private HeatStructureTree importStructure;
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatResourceUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatResourceUtil.java
index a44b0196d4..4563e686e5 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatResourceUtil.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatResourceUtil.java
@@ -21,6 +21,8 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
public class HeatResourceUtil {
@@ -31,9 +33,9 @@ public class HeatResourceUtil {
private static final String PORT_RESOURCE_ID_REGEX_PREFIX =
WORDS_REGEX + PORT_RESOURCE_ID_REGEX_SUFFIX;
private static final String PORT_INT_RESOURCE_ID_REGEX_PREFIX = PORT_RESOURCE_ID_REGEX_PREFIX
- + UNDERSCORE + "int_"+ WORDS_REGEX + UNDERSCORE;
+ + UNDERSCORE + "int_" + WORDS_REGEX + UNDERSCORE;
private static final String SUB_INTERFACE_INT_RESOURCE_ID_REGEX_PREFIX =
- PORT_RESOURCE_ID_REGEX_PREFIX + UNDERSCORE + "subint_"+ WORDS_REGEX + UNDERSCORE;
+ PORT_RESOURCE_ID_REGEX_PREFIX + UNDERSCORE + "subint_" + WORDS_REGEX + UNDERSCORE;
public static Optional<String> evaluateNetworkRoleFromResourceId(String resourceId,
String resourceType) {
@@ -56,17 +58,23 @@ public class HeatResourceUtil {
}
private static Optional<PortType> getPortType(String resourceType) {
- if (resourceType.equals(
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource())) {
+ if (HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource()
+ .equals(resourceType)) {
return Optional.of(PortType.VMI);
- } else if (resourceType.equals(
- HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource())) {
+ } else if (HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource().equals(resourceType)) {
return Optional.of(PortType.PORT);
}
return Optional.empty();
}
- public static Optional<String> extractNetworkRoleFromSubInterfaceId(String resourceId,
+ /**
+ * Extract network role from sub interface id optional.
+ *
+ * @param resourceId the resource id
+ * @param resourceType the resource type
+ * @return the optional
+ */
+ public static Optional<String> extractNetworkRoleFromSubInterfaceId(String resourceId,
String resourceType) {
Optional<PortType> portType = getPortType(resourceType);
if (portType.isPresent()) {
@@ -79,19 +87,13 @@ public class HeatResourceUtil {
return Optional.empty();
}
+ @AllArgsConstructor
+ @Getter
private enum PortType {
PORT("port"),
VMI("vmi");
private String portTypeName;
-
- PortType(String portTypeName) {
- this.portTypeName = portTypeName;
- }
-
- public String getPortTypeName() {
- return portTypeName;
- }
}
private static String getNetworkRole(String portResourceId, String portIdRegex) {
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatStructureUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatStructureUtil.java
index ef09841727..b73c7e8b8b 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatStructureUtil.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/HeatStructureUtil.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,6 +20,12 @@
package org.openecomp.sdc.heat.services;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
@@ -27,12 +33,6 @@ import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
/**
* Created by TALIO on 2/19/2017.
*/
@@ -42,77 +42,83 @@ public class HeatStructureUtil {
// prevent instantiation
}
- /**
- * Gets referenced values by function name.
- *
- * @param filename the filename
- * @param functionName the function name
- * @param propertyValue the property value
- * @param globalContext the global context
- * @return the referenced values by function name
- */
- public static Set<String> getReferencedValuesByFunctionName(String filename, String functionName,
- Object propertyValue,
- GlobalValidationContext globalContext) {
- Set<String> valuesNames = new HashSet<>();
- if (propertyValue instanceof Map) {
- Map<String, Object> currPropertyMap = (Map<String, Object>) propertyValue;
- if (currPropertyMap.containsKey(functionName)) {
- Object getFunctionValue = currPropertyMap.get(functionName);
- if (!(getFunctionValue instanceof String) && functionName.equals(
- ResourceReferenceFunctions.GET_RESOURCE.getFunction())) {
- globalContext.addMessage(filename, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(globalContext.getMessageCode(),
- Messages.INVALID_GET_RESOURCE_SYNTAX.getErrorMessage(),
- getFunctionValue == null ? "null" : getFunctionValue.toString()));
- return valuesNames;
- }
- if (getFunctionValue instanceof String) {
+ /**
+ * Gets referenced values by function name.
+ *
+ * @param filename the filename
+ * @param functionName the function name
+ * @param propertyValue the property value
+ * @param globalContext the global context
+ * @return the referenced values by function name
+ */
+ public static Set<String> getReferencedValuesByFunctionName(String filename, String functionName,
+ Object propertyValue,
+ GlobalValidationContext globalContext) {
+ Set<String> valuesNames = new HashSet<>();
+ if (propertyValue instanceof Map) {
+ Map<String, Object> currPropertyMap = (Map<String, Object>) propertyValue;
+ if (currPropertyMap.containsKey(functionName)) {
+ Object getFunctionValue = currPropertyMap.get(functionName);
+ if (!(getFunctionValue instanceof String) && functionName.equals(
+ ResourceReferenceFunctions.GET_RESOURCE.getFunction())) {
+ globalContext.addMessage(filename, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(globalContext.getMessageCode(),
+ Messages.INVALID_GET_RESOURCE_SYNTAX.getErrorMessage(),
+ getFunctionValue == null ? "null" : getFunctionValue.toString()));
+ return valuesNames;
+ }
+ if (getFunctionValue instanceof String) {
- if (functionName.equals(ResourceReferenceFunctions.GET_FILE.getFunction())) {
- getFunctionValue = ((String) getFunctionValue).replace("file:///", "");
- }
+ if (functionName.equals(ResourceReferenceFunctions.GET_FILE.getFunction())) {
+ getFunctionValue = ((String) getFunctionValue).replace("file:///", "");
+ }
- valuesNames.add((String) getFunctionValue);
- } else if (getFunctionValue instanceof List) {
- if (CollectionUtils.isNotEmpty((List) getFunctionValue)) {
- if (((List) getFunctionValue).get(0) instanceof String) {
- valuesNames.add(((String) ((List) getFunctionValue).get(0)).replace("file:///", ""));
+ valuesNames.add((String) getFunctionValue);
+ } else if (getFunctionValue instanceof List) {
+ if (CollectionUtils.isNotEmpty((List) getFunctionValue)) {
+ if (((List) getFunctionValue).get(0) instanceof String) {
+ valuesNames.add(((String) ((List) getFunctionValue).get(0)).replace("file:///", ""));
+ } else {
+ valuesNames.addAll(getReferencedValuesByFunctionName(filename, functionName,
+ ((List) getFunctionValue).get(0), globalContext));
+ }
+
+ }
+ } else {
+ valuesNames.addAll(
+ getReferencedValuesByFunctionName(filename, functionName, getFunctionValue,
+ globalContext));
+ }
} else {
- valuesNames.addAll(getReferencedValuesByFunctionName(filename, functionName,
- ((List) getFunctionValue).get(0), globalContext));
+ for (Map.Entry<String, Object> nestedPropertyMap : currPropertyMap.entrySet()) {
+ valuesNames.addAll(getReferencedValuesByFunctionName(filename, functionName,
+ nestedPropertyMap.getValue(), globalContext));
+ }
+ }
+ } else if (propertyValue instanceof List) {
+ List propertyValueArray = (List) propertyValue;
+ for (Object propValue : propertyValueArray) {
+ valuesNames.addAll(
+ getReferencedValuesByFunctionName(filename, functionName, propValue,
+ globalContext));
}
-
- }
- } else {
- valuesNames.addAll(
- getReferencedValuesByFunctionName(filename, functionName, getFunctionValue,
- globalContext));
- }
- } else {
- for (Map.Entry<String, Object> nestedPropertyMap : currPropertyMap.entrySet()) {
- valuesNames.addAll(getReferencedValuesByFunctionName(filename, functionName,
- nestedPropertyMap.getValue(), globalContext));
}
- }
- } else if (propertyValue instanceof List) {
- List propertyValueArray = (List) propertyValue;
- for (Object propValue : propertyValueArray) {
- valuesNames.addAll(
- getReferencedValuesByFunctionName(filename, functionName, propValue,
- globalContext));
- }
- }
- return valuesNames;
- }
+ return valuesNames;
+ }
- public static boolean isNestedResource(String resourceType) {
- if(Objects.isNull(resourceType)){
- return false;
+ /**
+ * Is nested resource.
+ *
+ * @param resourceType the resource type
+ * @return the boolean
+ */
+ public static boolean isNestedResource(String resourceType) {
+ if (Objects.isNull(resourceType)) {
+ return false;
+ }
+ return resourceType.endsWith(".yaml") || resourceType.endsWith(".yml");
}
- return resourceType.endsWith(".yaml") || resourceType.endsWith(".yml");
- }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/manifest/ManifestUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/manifest/ManifestUtil.java
index ef057a9fc9..8c6daac71e 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/manifest/ManifestUtil.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/manifest/ManifestUtil.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,156 +20,151 @@
package org.openecomp.sdc.heat.services.manifest;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.heat.datatypes.manifest.FileData;
-import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+
public class ManifestUtil {
- /**
- * Gets file and its env.
- *
- * @param manifestContent the manifest content
- * @return the file and its env
- */
- public static Map<String, FileData> getFileAndItsEnv(ManifestContent manifestContent) {
- Map<String, FileData> fileEnvMap = new HashMap<>();
- scanFileEnvMap(null, manifestContent.getData(), fileEnvMap);
- return fileEnvMap;
- }
-
-
- /**
- * Scan file env map.
- *
- * @param fileData the file data
- * @param fileDataList the file data list
- * @param fileEnvMap the file env map
- */
- public static void scanFileEnvMap(FileData fileData, List<FileData> fileDataList,
- Map<String, FileData> fileEnvMap) {
-
- if (CollectionUtils.isEmpty(fileDataList)) {
- return;
+ /**
+ * Gets file and its env.
+ *
+ * @param manifestContent the manifest content
+ * @return the file and its env
+ */
+ public static Map<String, FileData> getFileAndItsEnv(ManifestContent manifestContent) {
+ Map<String, FileData> fileEnvMap = new HashMap<>();
+ scanFileEnvMap(null, manifestContent.getData(), fileEnvMap);
+ return fileEnvMap;
}
- for (FileData childFileData : fileDataList) {
- FileData.Type childType = childFileData.getType();
- if (fileData != null) {
- if (childType != null && childType.equals(FileData.Type.HEAT_ENV)) {
- fileEnvMap.put(fileData.getFile(), childFileData);
+
+ /**
+ * Scan file env map.
+ *
+ * @param fileData the file data
+ * @param fileDataList the file data list
+ * @param fileEnvMap the file env map
+ */
+ private static void scanFileEnvMap(FileData fileData, List<FileData> fileDataList,
+ Map<String, FileData> fileEnvMap) {
+
+ if (CollectionUtils.isEmpty(fileDataList)) {
+ return;
+ }
+
+ for (FileData childFileData : fileDataList) {
+ FileData.Type childType = childFileData.getType();
+ if (fileData != null) {
+ if (childType != null && childType.equals(FileData.Type.HEAT_ENV)) {
+ fileEnvMap.put(fileData.getFile(), childFileData);
+ }
+ }
+ scanFileEnvMap(childFileData, childFileData.getData(), fileEnvMap);
}
- }
- scanFileEnvMap(childFileData, childFileData.getData(), fileEnvMap);
- }
- }
-
-
- /**
- * Gets file type map.
- *
- * @param manifestContent the manifest content
- * @return the file type map
- */
- public static Map<String, FileData.Type> getFileTypeMap(ManifestContent manifestContent) {
- Map<String, FileData.Type> fileTypeMap = new HashMap<>();
- scanFileTypeMap(null, manifestContent.getData(), fileTypeMap);
- return fileTypeMap;
- }
-
- private static FileData.Type scanFileTypeMap(FileData fileData, List<FileData> data,
- Map<String, FileData.Type> fileTypeMap) {
- if (fileData != null) {
- fileTypeMap.put(fileData.getFile(), fileData.getType());
- }
- if (data == null) {
- return null;
}
- for (FileData chileFileData : data) {
- FileData.Type type = scanFileTypeMap(chileFileData, chileFileData.getData(), fileTypeMap);
- if (type != null) {
- return type;
- }
+
+ /**
+ * Gets file type map.
+ *
+ * @param manifestContent the manifest content
+ * @return the file type map
+ */
+ public static Map<String, FileData.Type> getFileTypeMap(ManifestContent manifestContent) {
+ Map<String, FileData.Type> fileTypeMap = new HashMap<>();
+ scanFileTypeMap(null, manifestContent.getData(), fileTypeMap);
+ return fileTypeMap;
}
- return null;
- }
+ private static FileData.Type scanFileTypeMap(FileData fileData, List<FileData> data,
+ Map<String, FileData.Type> fileTypeMap) {
+ if (fileData != null) {
+ fileTypeMap.put(fileData.getFile(), fileData.getType());
+ }
+ if (data == null) {
+ return null;
+ }
- /**
- * Gets artifacts.
- *
- * @param manifestContent the manifest content
- * @return the artifacts
- */
- public static Set<String> getArtifacts(ManifestContent manifestContent) {
- Set<String> artifacts = new HashSet<>();
- scanArtifacts(null, manifestContent.getData(), artifacts);
+ for (FileData chileFileData : data) {
+ FileData.Type type = scanFileTypeMap(chileFileData, chileFileData.getData(), fileTypeMap);
+ if (type != null) {
+ return type;
+ }
+ }
+ return null;
+ }
- return artifacts;
- }
+ /**
+ * Gets artifacts.
+ *
+ * @param manifestContent the manifest content
+ * @return the artifacts
+ */
+ public static Set<String> getArtifacts(ManifestContent manifestContent) {
+ Set<String> artifacts = new HashSet<>();
+ scanArtifacts(null, manifestContent.getData(), artifacts);
- private static void scanArtifacts(FileData fileData, List<FileData> data, Set<String> artifacts) {
- if (fileData != null && fileData.getType() != null) {
- if (isArtifact(fileData)) {
- artifacts.add(fileData.getFile());
- }
+ return artifacts;
}
- if (data == null) {
- return;
- }
+ private static void scanArtifacts(FileData fileData, List<FileData> data, Set<String> artifacts) {
+ if (fileData != null && fileData.getType() != null) {
+ if (isArtifact(fileData)) {
+ artifacts.add(fileData.getFile());
+ }
+ }
- for (FileData chileFileData : data) {
- scanArtifacts(chileFileData, chileFileData.getData(), artifacts);
- }
- }
-
- private static boolean isArtifact(FileData fileData) {
- if (FileData.Type.valueOf(fileData.getType().name()) != null
- && !fileData.getType().equals(FileData.Type.HEAT)
- && !fileData.getType().equals(FileData.Type.HEAT_ENV)
- && !fileData.getType().equals(FileData.Type.HEAT_NET)
- && !fileData.getType().equals(FileData.Type.HEAT_VOL)) {
- return true;
+ if (data == null) {
+ return;
+ }
+
+ for (FileData chileFileData : data) {
+ scanArtifacts(chileFileData, chileFileData.getData(), artifacts);
+ }
}
- return false;
- }
-
- /**
- * Gets base files.
- *
- * @param manifestContent the manifest content
- * @return the base files
- */
- public static Set<String> getBaseFiles(ManifestContent manifestContent) {
- Set<String> baseFiles = new HashSet<>();
- scanBase(null, manifestContent.getData(), baseFiles);
- return baseFiles;
- }
-
- private static void scanBase(FileData fileData, List<FileData> data, Set<String> baseFiles) {
- if (fileData != null && fileData.getBase() != null) {
- if (fileData.getBase()) {
- baseFiles.add(fileData.getFile());
- }
+
+ private static boolean isArtifact(FileData fileData) {
+ return FileData.Type.valueOf(fileData.getType().name()) != null
+ && !fileData.getType().equals(FileData.Type.HEAT)
+ && !fileData.getType().equals(FileData.Type.HEAT_ENV)
+ && !fileData.getType().equals(FileData.Type.HEAT_NET)
+ && !fileData.getType().equals(FileData.Type.HEAT_VOL);
}
- if (data == null) {
- return;
+ /**
+ * Gets base files.
+ *
+ * @param manifestContent the manifest content
+ * @return the base files
+ */
+ public static Set<String> getBaseFiles(ManifestContent manifestContent) {
+ Set<String> baseFiles = new HashSet<>();
+ scanBase(null, manifestContent.getData(), baseFiles);
+ return baseFiles;
}
- for (FileData chileFileData : data) {
- scanBase(chileFileData, chileFileData.getData(), baseFiles);
+ private static void scanBase(FileData fileData, List<FileData> data, Set<String> baseFiles) {
+ if (fileData != null && fileData.getBase() != null) {
+ if (fileData.getBase()) {
+ baseFiles.add(fileData.getFile());
+ }
+ }
+
+ if (data == null) {
+ return;
+ }
+
+ for (FileData chileFileData : data) {
+ scanBase(chileFileData, chileFileData.getData(), baseFiles);
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java
index e8fe034176..936f02be67 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java
@@ -12,10 +12,18 @@
* 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.
-*/
+ */
package org.openecomp.sdc.heat.services.tree;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
@@ -31,257 +39,247 @@ import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
public class HeatTreeManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(HeatTreeManager.class);
-
-
- private FileContentHandler heatContentMap = new FileContentHandler();
- private byte[] manifest;
- private HeatStructureTree tree = new HeatStructureTree();
- private Map<String, HeatStructureTree> fileTreeRef = new HashMap<>();
- private Map<String, Artifact> artifactRef = new HashMap<>();
- private Map<String, Artifact> candidateOrphanArtifacts = new HashMap<>();
- private Map<String, HeatStructureTree> nestedFiles = new HashMap<>();
- private Map<HeatStructureTree, HeatStructureTree> volumeFileToParent = new HashMap<>();
- private Map<HeatStructureTree, HeatStructureTree> networkFileToParent = new HashMap<>();
- private Set<String> manifestFiles = new HashSet<>();
-
- /**
- * Add file.
- *
- * @param fileName the file name
- * @param content the content
- */
- public void addFile(String fileName, InputStream content) {
- if (fileName.equals(SdcCommon.MANIFEST_NAME)) {
- manifest = FileUtils.toByteArray(content);
-
- } else {
- heatContentMap.addFile(fileName, content);
+ private static final Logger LOGGER = LoggerFactory.getLogger(HeatTreeManager.class);
+
+
+ private FileContentHandler heatContentMap = new FileContentHandler();
+ private byte[] manifest;
+ private HeatStructureTree tree = new HeatStructureTree();
+ private Map<String, HeatStructureTree> fileTreeRef = new HashMap<>();
+ private Map<String, Artifact> artifactRef = new HashMap<>();
+ private Map<String, Artifact> candidateOrphanArtifacts = new HashMap<>();
+ private Map<String, HeatStructureTree> nestedFiles = new HashMap<>();
+ private Map<HeatStructureTree, HeatStructureTree> volumeFileToParent = new HashMap<>();
+ private Map<HeatStructureTree, HeatStructureTree> networkFileToParent = new HashMap<>();
+ private Set<String> manifestFiles = new HashSet<>();
+
+ /**
+ * Add file.
+ *
+ * @param fileName the file name
+ * @param content the content
+ */
+ public void addFile(String fileName, InputStream content) {
+ if (fileName.equals(SdcCommon.MANIFEST_NAME)) {
+ manifest = FileUtils.toByteArray(content);
+
+ } else {
+ heatContentMap.addFile(fileName, content);
+ }
+ }
+
+ /**
+ * Create tree.
+ */
+ public void createTree() {
+ if (manifest == null) {
+ LOGGER.error("Missing manifest file in the zip.");
+ return;
+ }
+ ManifestContent manifestData =
+ JsonUtil.json2Object(new String(manifest), ManifestContent.class);
+ scanTree(null, manifestData.getData());
+ addNonNestedVolumeNetworkToTree(volumeFileToParent, nestedFiles.keySet(), true);
+ addNonNestedVolumeNetworkToTree(networkFileToParent, nestedFiles.keySet(), false);
+ handleOrphans();
+
+ tree = fileTreeRef.get(SdcCommon.PARENT);
}
- }
-
- /**
- * Create tree.
- */
- public void createTree() {
- if (manifest == null) {
- LOGGER.error("Missing manifest file in the zip.");
- return;
+
+ private void handleOrphans() {
+ tree = fileTreeRef.get(SdcCommon.PARENT);
+ candidateOrphanArtifacts.forEach((key, value) -> tree.addArtifactToArtifactList(value));
+ nestedFiles
+ .values().stream().filter(tree.getHeat()::contains)
+ .forEach(tree.getHeat()::remove);
+
+ heatContentMap.getFileList().stream().filter(this::isNotInManifestFiles)
+ .forEach(this::addTreeOther);
}
- ManifestContent manifestData =
- JsonUtil.json2Object(new String(manifest), ManifestContent.class);
- scanTree(null, manifestData.getData());
- addNonNestedVolumeNetworkToTree(volumeFileToParent, nestedFiles.keySet(), true);
- addNonNestedVolumeNetworkToTree(networkFileToParent, nestedFiles.keySet(), false);
- handleOrphans();
-
- tree = fileTreeRef.get(SdcCommon.PARENT);
- }
-
- private void handleOrphans() {
- tree = fileTreeRef.get(SdcCommon.PARENT);
- candidateOrphanArtifacts.entrySet().stream()
- .forEach(entry -> tree.addArtifactToArtifactList(entry.getValue()));
- nestedFiles
- .values().stream().filter(tree.getHeat()::contains)
- .forEach(tree.getHeat()::remove);
-
- heatContentMap.getFileList().stream().filter(this::isNotInManifestFiles)
- .forEach(this::addTreeOther);
- }
-
- private boolean isNotInManifestFiles(String fileName) {
- return !manifestFiles.contains(fileName);
- }
-
- private void addTreeOther(String fileName) {
- if (tree.getOther() == null) {
- tree.setOther(new HashSet<>());
+
+ private boolean isNotInManifestFiles(String fileName) {
+ return !manifestFiles.contains(fileName);
}
- HeatStructureTree other = new HeatStructureTree(fileName, false);
- fileTreeRef.put(fileName, other);
- tree.getOther().add(other);
- }
+ private void addTreeOther(String fileName) {
+ if (tree.getOther() == null) {
+ tree.setOther(new HashSet<>());
+ }
+ HeatStructureTree other = new HeatStructureTree(fileName, false);
+ fileTreeRef.put(fileName, other);
+ tree.getOther().add(other);
+ }
- private void handleHeatContentReference(HeatStructureTree fileHeatStructureTree,
- GlobalValidationContext globalContext) {
- String fileName = fileHeatStructureTree.getFileName();
+ private void handleHeatContentReference(HeatStructureTree fileHeatStructureTree,
+ GlobalValidationContext globalContext) {
- try (InputStream fileContent = this.heatContentMap.getFileContent(fileName)) {
- HeatOrchestrationTemplate hot =
- new YamlUtil().yamlToObject(fileContent, HeatOrchestrationTemplate.class);
+ String fileName = fileHeatStructureTree.getFileName();
+ try (InputStream fileContent = this.heatContentMap.getFileContent(fileName)) {
+ HeatOrchestrationTemplate hot =
+ new YamlUtil().yamlToObject(fileContent, HeatOrchestrationTemplate.class);
- Set<String> nestedSet = HeatTreeManagerUtil.getNestedFiles(fileName, hot, globalContext);
- addHeatNestedFiles(fileHeatStructureTree, nestedSet);
+ Set<String> nestedSet = HeatTreeManagerUtil.getNestedFiles(hot);
+ addHeatNestedFiles(fileHeatStructureTree, nestedSet);
- Set<String> artifactSet = HeatTreeManagerUtil.getArtifactFiles(fileName, hot, globalContext);
- addHeatArtifactFiles(fileHeatStructureTree, artifactSet);
- } catch (Exception ignore) {
- LOGGER.debug("Invalid YAML received. No need to process content reference - ignoring", ignore);
- }
- }
-
-
- private void addHeatArtifactFiles(HeatStructureTree fileHeatStructureTree,
- Set<String> artifactSet) {
- Artifact artifact;
- for (String artifactName : artifactSet) {
- FileData.Type type =
- candidateOrphanArtifacts.get(artifactName) != null ? candidateOrphanArtifacts
- .get(artifactName).getType() : null;
- artifact = new Artifact(artifactName, type);
- artifactRef.put(artifactName, artifact);
- candidateOrphanArtifacts.remove(artifactName);
- fileHeatStructureTree.addArtifactToArtifactList(artifact);
- }
- }
-
-
- private void addHeatNestedFiles(HeatStructureTree fileHeatStructureTree, Set<String> nestedSet) {
- HeatStructureTree childHeatStructureTree;
- for (String nestedName : nestedSet) {
- childHeatStructureTree = fileTreeRef.get(nestedName);
- if (childHeatStructureTree == null) {
- childHeatStructureTree = new HeatStructureTree();
- childHeatStructureTree.setFileName(nestedName);
- fileTreeRef.put(nestedName, childHeatStructureTree);
- }
- fileHeatStructureTree.addHeatStructureTreeToNestedHeatList(childHeatStructureTree);
- nestedFiles.put(childHeatStructureTree.getFileName(), childHeatStructureTree);
+ Set<String> artifactSet = HeatTreeManagerUtil.getArtifactFiles(fileName, hot, globalContext);
+ addHeatArtifactFiles(fileHeatStructureTree, artifactSet);
+ } catch (Exception exp) {
+ LOGGER.debug("Invalid YAML received. No need to process content reference - ignoring", exp);
+ }
}
- }
-
-
- /**
- * Add errors.
- *
- * @param validationErrors the validation errors
- */
- public void addErrors(Map<String, List<ErrorMessage>> validationErrors) {
-
- validationErrors.entrySet().stream().filter(entry ->{
- return fileTreeRef.get(entry.getKey()) != null;
- }).forEach(entry -> entry.getValue().stream().forEach(fileTreeRef.get(entry.getKey())::addErrorToErrorsList));
-
- validationErrors.entrySet().stream().filter(entry -> {
- return artifactRef.get(entry.getKey()) != null;
- }).forEach(entry -> artifactRef.get(entry.getKey()).setErrors(entry.getValue()));
-
- }
-
- /**
- * Scan tree.
- *
- * @param parent the parent
- * @param data the data
- */
- public void scanTree(String parent, List<FileData> data) {
- String fileName;
- FileData.Type type;
- HeatStructureTree parentHeatStructureTree;
- HeatStructureTree fileHeatStructureTree;
- HeatStructureTree childHeatStructureTree;
- Artifact artifact;
- if (parent == null) {
- parentHeatStructureTree = new HeatStructureTree();
- fileTreeRef.put(SdcCommon.PARENT, parentHeatStructureTree);
- } else {
- parentHeatStructureTree = fileTreeRef.get(parent);
+
+
+ private void addHeatArtifactFiles(HeatStructureTree fileHeatStructureTree,
+ Set<String> artifactSet) {
+ Artifact artifact;
+ for (String artifactName : artifactSet) {
+ FileData.Type type =
+ candidateOrphanArtifacts.get(artifactName) != null ? candidateOrphanArtifacts
+ .get(artifactName).getType() : null;
+ artifact = new Artifact(artifactName, type);
+ artifactRef.put(artifactName, artifact);
+ candidateOrphanArtifacts.remove(artifactName);
+ fileHeatStructureTree.addArtifactToArtifactList(artifact);
+ }
}
- for (FileData fileData : data) {
- fileName = fileData.getFile();
- manifestFiles.add(fileName);
- type = fileData.getType();
- if (Objects.nonNull(type) && FileData.Type.HEAT.equals(type)) {
- fileHeatStructureTree = fileTreeRef.get(fileName);
- if (fileHeatStructureTree == null) {
- fileHeatStructureTree = new HeatStructureTree();
- fileTreeRef.put(fileName, fileHeatStructureTree);
+ private void addHeatNestedFiles(HeatStructureTree fileHeatStructureTree, Set<String> nestedSet) {
+ HeatStructureTree childHeatStructureTree;
+ for (String nestedName : nestedSet) {
+ childHeatStructureTree = fileTreeRef.get(nestedName);
+ if (childHeatStructureTree == null) {
+ childHeatStructureTree = new HeatStructureTree();
+ childHeatStructureTree.setFileName(nestedName);
+ fileTreeRef.put(nestedName, childHeatStructureTree);
+ }
+ fileHeatStructureTree.addHeatStructureTreeToNestedHeatList(childHeatStructureTree);
+ nestedFiles.put(childHeatStructureTree.getFileName(), childHeatStructureTree);
}
- fileHeatStructureTree.setFileName(fileName);
- fileHeatStructureTree.setBase(fileData.getBase());
- fileHeatStructureTree.setType(type);
- handleHeatContentReference(fileHeatStructureTree, null);
- parentHeatStructureTree.addHeatToHeatList(fileHeatStructureTree);
- if (fileData.getData() != null) {
- scanTree(fileName, fileData.getData());
+ }
+
+
+ /**
+ * Add errors.
+ *
+ * @param validationErrors the validation errors
+ */
+ public void addErrors(Map<String, List<ErrorMessage>> validationErrors) {
+
+ validationErrors.entrySet().stream()
+ .filter(entry -> fileTreeRef.get(entry.getKey()) != null)
+ .forEach(entry -> entry.getValue().forEach(fileTreeRef.get(entry.getKey())::addErrorToErrorsList));
+
+ validationErrors.entrySet().stream()
+ .filter(entry -> artifactRef.get(entry.getKey()) != null)
+ .forEach(entry -> artifactRef.get(entry.getKey()).setErrors(entry.getValue()));
+
+ }
+
+ /**
+ * Scan tree.
+ *
+ * @param parent the parent
+ * @param data the data
+ */
+ public void scanTree(String parent, List<FileData> data) {
+ String fileName;
+ FileData.Type type;
+ HeatStructureTree parentHeatStructureTree;
+ HeatStructureTree fileHeatStructureTree;
+ HeatStructureTree childHeatStructureTree;
+ Artifact artifact;
+ if (parent == null) {
+ parentHeatStructureTree = new HeatStructureTree();
+ fileTreeRef.put(SdcCommon.PARENT, parentHeatStructureTree);
+ } else {
+ parentHeatStructureTree = fileTreeRef.get(parent);
}
- } else {
- childHeatStructureTree = new HeatStructureTree();
- childHeatStructureTree.setFileName(fileName);
- childHeatStructureTree.setBase(fileData.getBase());
- childHeatStructureTree.setType(type);
- fileTreeRef.put(childHeatStructureTree.getFileName(), childHeatStructureTree);
-
- if (type == null) {
- parentHeatStructureTree.addOtherToOtherList(childHeatStructureTree);
- } else if (FileData.Type.HEAT_NET.equals(type)) {
- networkFileToParent.put(childHeatStructureTree, parentHeatStructureTree);
- if (fileData.getData() != null) {
- scanTree(fileName, fileData.getData());
- }
- handleHeatContentReference(childHeatStructureTree, null);
-
- } else if (FileData.Type.HEAT_VOL.equals(type)) {
- volumeFileToParent.put(childHeatStructureTree, parentHeatStructureTree);
- if (fileData.getData() != null) {
- scanTree(fileName, fileData.getData());
- }
- handleHeatContentReference(childHeatStructureTree, null);
- } else if (FileData.Type.HEAT_ENV.equals(type)) {
- if (parentHeatStructureTree != null && parentHeatStructureTree.getFileName() != null) {
- parentHeatStructureTree.setEnv(childHeatStructureTree);
- } else {
- if (parentHeatStructureTree.getOther() == null) {
- parentHeatStructureTree.setOther(new HashSet<>());
+
+ for (FileData fileData : data) {
+ fileName = fileData.getFile();
+ manifestFiles.add(fileName);
+ type = fileData.getType();
+
+ if (Objects.nonNull(type) && FileData.Type.HEAT.equals(type)) {
+ fileHeatStructureTree = fileTreeRef.get(fileName);
+ if (fileHeatStructureTree == null) {
+ fileHeatStructureTree = new HeatStructureTree();
+ fileTreeRef.put(fileName, fileHeatStructureTree);
+ }
+ fileHeatStructureTree.setFileName(fileName);
+ fileHeatStructureTree.setBase(fileData.getBase());
+ fileHeatStructureTree.setType(type);
+ handleHeatContentReference(fileHeatStructureTree, null);
+ parentHeatStructureTree.addHeatToHeatList(fileHeatStructureTree);
+ if (fileData.getData() != null) {
+ scanTree(fileName, fileData.getData());
+ }
+ } else {
+ childHeatStructureTree = new HeatStructureTree();
+ childHeatStructureTree.setFileName(fileName);
+ childHeatStructureTree.setBase(fileData.getBase());
+ childHeatStructureTree.setType(type);
+ fileTreeRef.put(childHeatStructureTree.getFileName(), childHeatStructureTree);
+
+ if (type == null) {
+ parentHeatStructureTree.addOtherToOtherList(childHeatStructureTree);
+ } else if (FileData.Type.HEAT_NET.equals(type)) {
+ networkFileToParent.put(childHeatStructureTree, parentHeatStructureTree);
+ if (fileData.getData() != null) {
+ scanTree(fileName, fileData.getData());
+ }
+ handleHeatContentReference(childHeatStructureTree, null);
+
+ } else if (FileData.Type.HEAT_VOL.equals(type)) {
+ volumeFileToParent.put(childHeatStructureTree, parentHeatStructureTree);
+ if (fileData.getData() != null) {
+ scanTree(fileName, fileData.getData());
+ }
+ handleHeatContentReference(childHeatStructureTree, null);
+ } else if (FileData.Type.HEAT_ENV.equals(type)) {
+ if (parentHeatStructureTree != null && parentHeatStructureTree.getFileName() != null) {
+ parentHeatStructureTree.setEnv(childHeatStructureTree);
+ } else {
+ if (parentHeatStructureTree.getOther() == null) {
+ parentHeatStructureTree.setOther(new HashSet<>());
+ }
+ parentHeatStructureTree.getOther().add(childHeatStructureTree);
+ }
+ } else {
+ artifact = new Artifact(fileName, type);
+ if (!artifactRef.keySet().contains(fileName)) {
+ artifactRef.put(fileName, artifact);
+ candidateOrphanArtifacts.put(fileName, artifact);
+ }
+ }
}
- parentHeatStructureTree.getOther().add(childHeatStructureTree);
- }
- } else {
- artifact = new Artifact(fileName, type);
- if (!artifactRef.keySet().contains(fileName)) {
- artifactRef.put(fileName, artifact);
- candidateOrphanArtifacts.put(fileName, artifact);
- }
}
- }
}
- }
-
-
- private void addNonNestedVolumeNetworkToTree(
- Map<HeatStructureTree, HeatStructureTree> netVolToParent, Set<String> nestedFileNames,
- boolean isVolume) {
- for (Map.Entry<HeatStructureTree, HeatStructureTree> entry : netVolToParent.entrySet()) {
- HeatStructureTree netOrVolNode = entry.getKey();
- HeatStructureTree parent = entry.getValue();
- if (!nestedFileNames.contains(netOrVolNode.getFileName())) {
- if (isVolume) {
- parent.addVolumeFileToVolumeList(netOrVolNode);
- } else {
- parent.addNetworkToNetworkList(netOrVolNode);
+
+
+ private void addNonNestedVolumeNetworkToTree(
+ Map<HeatStructureTree, HeatStructureTree> netVolToParent, Set<String> nestedFileNames,
+ boolean isVolume) {
+ for (Map.Entry<HeatStructureTree, HeatStructureTree> entry : netVolToParent.entrySet()) {
+ HeatStructureTree netOrVolNode = entry.getKey();
+ HeatStructureTree parent = entry.getValue();
+ if (!nestedFileNames.contains(netOrVolNode.getFileName())) {
+ if (isVolume) {
+ parent.addVolumeFileToVolumeList(netOrVolNode);
+ } else {
+ parent.addNetworkToNetworkList(netOrVolNode);
+ }
+ }
}
- }
}
- }
- public HeatStructureTree getTree() {
- return tree;
- }
+ public HeatStructureTree getTree() {
+ return tree;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java
index 7a2dfc971b..8c6d1354c4 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java
@@ -12,11 +12,17 @@
* 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.
-*/
+ */
package org.openecomp.sdc.heat.services.tree;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
@@ -30,196 +36,185 @@ import org.openecomp.sdc.heat.datatypes.model.PropertiesMapKeyTypes;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
public class HeatTreeManagerUtil {
- private static final String TYPE = "type";
- private HeatTreeManagerUtil() {
-
- }
-
- /**
- * Init heat tree manager heat tree manager.
- *
- * @param fileContentMap the file content map
- * @return the heat tree manager
- */
- public static HeatTreeManager initHeatTreeManager(FileContentHandler fileContentMap) {
-
- HeatTreeManager heatTreeManager = new HeatTreeManager();
- fileContentMap.getFileList().stream().forEach(
- fileName -> heatTreeManager.addFile(fileName, fileContentMap.getFileContent(fileName)));
-
- return heatTreeManager;
- }
-
- /**
- * Gets nested files.
- *
- * @param filename the filename
- * @param hot the hot
- * @param globalContext the global context
- * @return the nested files
- */
- public static Set<String> getNestedFiles(String filename, HeatOrchestrationTemplate hot,
- GlobalValidationContext globalContext) {
- Set<String> nestedFileList = new HashSet<>();
- hot.getResources().values().stream().filter(
- resource -> resource.getType().endsWith(".yaml") || resource.getType().endsWith(".yml"))
- .forEach(resource -> nestedFileList.add(resource.getType()));
-
- Set<String> resourceDefNestedFiles = getResourceDefNestedFiles(hot);
- nestedFileList.addAll(resourceDefNestedFiles);
- return nestedFileList;
- }
-
- /**
- * Gets artifact files.
- *
- * @param filename the filename
- * @param hot the hot
- * @param globalContext the global context
- * @return the artifact files
- */
- public static Set<String> getArtifactFiles(String filename, HeatOrchestrationTemplate hot,
- GlobalValidationContext globalContext) {
- Set<String> artifactSet = new HashSet<>();
- Collection<Resource> resourcesValue =
- hot.getResources() == null ? null : hot.getResources().values();
- if (CollectionUtils.isNotEmpty(resourcesValue)) {
- for (Resource resource : resourcesValue) {
- Collection<Object> properties =
- resource.getProperties() == null ? null : resource.getProperties().values();
-
- artifactSet.addAll(getArtifactsFromPropertiesAndAddInArtifactSet(properties,
- filename, globalContext));
- }
+ private static final String TYPE = "type";
+
+ private HeatTreeManagerUtil() {
+
}
- return artifactSet;
- }
-
- private static Set<String> getArtifactsFromPropertiesAndAddInArtifactSet(Collection<Object> properties,
- String filename,
- GlobalValidationContext globalContext ){
- Set<String> artifactSet = new HashSet<>();
- if (CollectionUtils.isNotEmpty(properties)) {
-
- for (Object property : properties) {
- Set<String> artifactNames =
- HeatStructureUtil.getReferencedValuesByFunctionName(filename, "get_file", property,
- globalContext);
- artifactSet.addAll(artifactNames);
- }
+
+ /**
+ * Init heat tree manager heat tree manager.
+ *
+ * @param fileContentMap the file content map
+ * @return the heat tree manager
+ */
+ public static HeatTreeManager initHeatTreeManager(FileContentHandler fileContentMap) {
+
+ HeatTreeManager heatTreeManager = new HeatTreeManager();
+ fileContentMap.getFileList().forEach(
+ fileName -> heatTreeManager.addFile(fileName, fileContentMap.getFileContent(fileName)));
+
+ return heatTreeManager;
}
- return artifactSet;
- }
-
- private static Set<String> getResourceDefNestedFiles(HeatOrchestrationTemplate hot) {
- Set<String> resourceDefNestedFiles = new HashSet<>();
- hot.getResources()
- .entrySet().stream().filter(entry -> entry.getValue().getType()
- .equals(HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource()))
- .filter(entry ->
- getResourceDef(entry.getValue()) != null
- && HeatStructureUtil.isNestedResource(
- getResourceDef(entry.getValue())
- .getType()))
- .forEach(entry -> resourceDefNestedFiles.add(
- getResourceDef( entry.getValue()).getType()));
- return resourceDefNestedFiles;
- }
-
- /**
- * Gets resource def.
- *
- * @param resource the resource
- * @return the resource def
- */
- @SuppressWarnings("unchecked")
- public static Resource getResourceDef( Resource resource) {
- Resource resourceDef = null;
- Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
- : (Map<String, Object>) resource.getProperties().get(
- PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
- if (resourceDefValueMap != null && MapUtils.isNotEmpty(resourceDefValueMap) ) {
- Object resourceDefType = resourceDefValueMap.get(TYPE);
- if ( resourceDefType instanceof String && isResourceGroupTypeNested((String) resourceDefType)) {
- resourceDef = new Resource();
- resourceDef.setType((String) resourceDefType);
- //noinspection unchecked
- resourceDef.setProperties((Map<String, Object>) resourceDefValueMap.get("properties"));
- }
+ /**
+ * Will verify the resource type and if type is of nested will return the nested file name
+ *
+ * @param hot Containing all translated data from heat file
+ * @return the nested files
+ */
+ public static Set<String> getNestedFiles(HeatOrchestrationTemplate hot) {
+ Set<String> nestedFileList = new HashSet<>();
+ hot.getResources().values().stream().filter(
+ resource -> resource.getType().endsWith(".yaml") || resource.getType().endsWith(".yml"))
+ .forEach(resource -> nestedFileList.add(resource.getType()));
+
+ Set<String> resourceDefNestedFiles = getResourceDefNestedFiles(hot);
+ nestedFileList.addAll(resourceDefNestedFiles);
+ return nestedFileList;
+ }
+
+ /**
+ * Verify if any artifact present in file whose detail is provided and return Artifact name
+ *
+ * @param filename name of file where artifact is too be looked for
+ * @param hot translated heat data
+ * @param globalContext the global context
+ * @return the artifact files name
+ */
+ public static Set<String> getArtifactFiles(String filename, HeatOrchestrationTemplate hot,
+ GlobalValidationContext globalContext) {
+ Set<String> artifactSet = new HashSet<>();
+ Collection<Resource> resourcesValue =
+ hot.getResources() == null ? null : hot.getResources().values();
+ if (CollectionUtils.isNotEmpty(resourcesValue)) {
+ for (Resource resource : resourcesValue) {
+ Collection<Object> properties =
+ resource.getProperties() == null ? null : resource.getProperties().values();
+
+ artifactSet.addAll(getArtifactsFromPropertiesAndAddInArtifactSet(properties,
+ filename, globalContext));
+ }
+ }
+ return artifactSet;
+ }
+
+ private static Set<String> getArtifactsFromPropertiesAndAddInArtifactSet(Collection<Object> properties,
+ String filename,
+ GlobalValidationContext globalContext) {
+ Set<String> artifactSet = new HashSet<>();
+ if (CollectionUtils.isNotEmpty(properties)) {
+
+ for (Object property : properties) {
+ Set<String> artifactNames =
+ HeatStructureUtil.getReferencedValuesByFunctionName(filename, "get_file", property,
+ globalContext);
+ artifactSet.addAll(artifactNames);
+ }
+ }
+
+ return artifactSet;
+ }
+ private static Set<String> getResourceDefNestedFiles(HeatOrchestrationTemplate hot) {
+ Set<String> resourceDefNestedFiles = new HashSet<>();
+ hot.getResources()
+ .entrySet().stream().filter(entry -> entry.getValue().getType()
+ .equals(HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource()))
+ .filter(entry ->
+ getResourceDef(entry.getValue()) != null
+ && HeatStructureUtil.isNestedResource(
+ getResourceDef(entry.getValue())
+ .getType()))
+ .forEach(entry -> resourceDefNestedFiles.add(
+ getResourceDef(entry.getValue()).getType()));
+ return resourceDefNestedFiles;
}
- return resourceDef;
- }
-
- @SuppressWarnings("unchecked")
- public static void checkResourceGroupTypeValid(String filename, String resourceName,
- Resource resource,
- GlobalValidationContext globalContext) {
- Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
- : (Map<String, Object>) resource.getProperties().get(
- PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
- if (resourceDefValueMap != null && MapUtils.isNotEmpty(resourceDefValueMap) ) {
- Object resourceDefType = resourceDefValueMap.get(TYPE);
- if (Objects.nonNull(resourceDefType) && !(resourceDefType instanceof String) ) {
- globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+
+ /**
+ * Gets resource def.
+ *
+ * @param resource the resource
+ * @return the resource def
+ */
+ @SuppressWarnings("unchecked")
+ public static Resource getResourceDef(Resource resource) {
+ Resource resourceDef = null;
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ : (Map<String, Object>) resource.getProperties().get(
+ PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
+ if (MapUtils.isNotEmpty(resourceDefValueMap)) {
+ Object resourceDefType = resourceDefValueMap.get(TYPE);
+ if (resourceDefType instanceof String && isResourceGroupTypeNested((String) resourceDefType)) {
+ resourceDef = new Resource();
+ resourceDef.setType((String) resourceDefType);
+ //noinspection unchecked
+ resourceDef.setProperties((Map<String, Object>) resourceDefValueMap.get("properties"));
+ }
+
+ }
+ return resourceDef;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void checkResourceGroupTypeValid(String filename, String resourceName,
+ Resource resource,
+ GlobalValidationContext globalContext) {
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ : (Map<String, Object>) resource.getProperties().get(
+ PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
+ if (MapUtils.isNotEmpty(resourceDefValueMap)) {
+ Object resourceDefType = resourceDefValueMap.get(TYPE);
+ if (Objects.nonNull(resourceDefType) && !(resourceDefType instanceof String)) {
+ globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
.getErrorWithParameters(
globalContext.getMessageCode(),
Messages.INVALID_RESOURCE_GROUP_TYPE.getErrorMessage(),
resourceName, resourceDefType.toString()));
- }
+ }
+ }
}
- }
-
- @SuppressWarnings("unchecked")
- public static void checkResourceTypeValid(String filename, String resourceName,
- Resource resource,
- GlobalValidationContext globalContext) {
- Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
- : (Map<String, Object>) resource.getProperties().get(
- PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
- if (resourceDefValueMap != null && MapUtils.isNotEmpty(resourceDefValueMap) ) {
- Object resourceDefType = resourceDefValueMap.get(TYPE);
- if (Objects.isNull(resourceDefType)) {
- globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+
+ @SuppressWarnings("unchecked")
+ public static void checkResourceTypeValid(String filename, String resourceName,
+ Resource resource,
+ GlobalValidationContext globalContext) {
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ : (Map<String, Object>) resource.getProperties().get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
+ if (MapUtils.isNotEmpty(resourceDefValueMap)) {
+ Object resourceDefType = resourceDefValueMap.get(TYPE);
+ if (Objects.isNull(resourceDefType)) {
+ globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
.getErrorWithParameters(
globalContext.getMessageCode(), Messages.INVALID_RESOURCE_TYPE.getErrorMessage(),
"null", resourceName));
- }
+ }
+ }
}
- }
-
- public static boolean isResourceGroupTypeNested(String resourceDefType) {
- return HeatStructureUtil.isNestedResource(resourceDefType);
- }
-
- public static boolean checkIfResourceGroupTypeIsNested(String filename, String resourceName,
- Resource resource,
- GlobalValidationContext globalContext) {
- //noinspection unchecked
- Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
- : (Map<String, Object>) resource.getProperties().get(
- PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
- if (resourceDefValueMap != null && MapUtils.isNotEmpty(resourceDefValueMap) ) {
- Object resourceDefType = resourceDefValueMap.get(TYPE);
- if (resourceDefType instanceof String && isResourceGroupTypeNested((String) resourceDefType)) {
-
- globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+
+ public static boolean isResourceGroupTypeNested(String resourceDefType) {
+ return HeatStructureUtil.isNestedResource(resourceDefType);
+ }
+
+ public static boolean checkIfResourceGroupTypeIsNested(String filename, String resourceName,
+ Resource resource,
+ GlobalValidationContext globalContext) {
+ //noinspection unchecked
+ Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
+ : (Map<String, Object>) resource.getProperties().get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
+ if (MapUtils.isNotEmpty(resourceDefValueMap)) {
+ Object resourceDefType = resourceDefValueMap.get(TYPE);
+ if (resourceDefType instanceof String && isResourceGroupTypeNested((String) resourceDefType)) {
+ globalContext.addMessage(filename, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
.getErrorWithParameters(
globalContext.getMessageCode(),
Messages.INVALID_RESOURCE_GROUP_TYPE.getErrorMessage(),
resourceName, resourceDefType.toString()));
- return true;
- }
+ return true;
+ }
+ }
+ return false;
}
- return false;
- }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java
index c711c72faf..944ab62f9f 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManager.java
@@ -1,9 +1,20 @@
-package org.openecomp.sdc.heat.services.tree;
+/*
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+**/
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+package org.openecomp.sdc.heat.services.tree;
import java.io.File;
import java.util.HashMap;
@@ -12,56 +23,84 @@ import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+
+/**
+ * The type Tosca tree manager.
+ */
public class ToscaTreeManager {
- private FileContentHandler csarContentMap = new FileContentHandler();
- private HeatStructureTree tree = new HeatStructureTree();
- private Map<String, HeatStructureTree> fileTreeRef = new HashMap<>();
+ private FileContentHandler csarContentMap = new FileContentHandler();
+ private HeatStructureTree tree = new HeatStructureTree();
+ private Map<String, HeatStructureTree> fileTreeRef = new HashMap<>();
- public void addFile(String fileName, byte[] content) {
- if (!fileName.equals(SdcCommon.CSAR_MANIFEST_NAME)) {
- csarContentMap.addFile(fileName, content);
- }
- }
- public void createTree() {
- for (Map.Entry<String, byte[]> fileEntry : csarContentMap.getFiles().entrySet()) {
- String[] splitFilename = getFullFileNameAsArray(fileEntry.getKey());
- addFileToTree(splitFilename, 0, splitFilename[0], tree);
+ /**
+ * Add file.
+ *
+ * @param fileName the file name
+ * @param content the content
+ */
+ public void addFile(String fileName, byte[] content) {
+ if (!fileName.equals(SdcCommon.CSAR_MANIFEST_NAME)) {
+ csarContentMap.addFile(fileName, content);
+ }
}
- }
- private void addFileToTree(String[] splitFilename, int startIndex, String fullFileName,
- HeatStructureTree parent) {
- fileTreeRef.putIfAbsent(fullFileName, new HeatStructureTree());
- HeatStructureTree heatStructureTree = fileTreeRef.get(fullFileName);
- heatStructureTree.setFileName(splitFilename[startIndex]);
- if (startIndex < splitFilename.length - 1) {
- addFileToTree(splitFilename, startIndex + 1,
- getFullFileName(fullFileName, splitFilename[startIndex + 1]), heatStructureTree);
+ /**
+ * Create tree.
+ */
+ public void createTree() {
+ for (Map.Entry<String, byte[]> fileEntry : csarContentMap.getFiles().entrySet()) {
+ String[] splitFilename = getFullFileNameAsArray(fileEntry.getKey());
+ addFileToTree(splitFilename, 0, splitFilename[0], tree);
+ }
}
- parent.addHeatStructureTreeToNestedHeatList(heatStructureTree);
- }
- public void addErrors(Map<String, List<ErrorMessage>> validationErrors) {
- validationErrors.entrySet().stream().filter(entry ->
- Objects.nonNull(fileTreeRef.get(entry.getKey()))).forEach(entry -> entry.getValue()
- .forEach(error -> fileTreeRef.get(entry.getKey()).addErrorToErrorsList(error)));
- }
+ private void addFileToTree(String[] splitFilename, int startIndex, String fullFileName,
+ HeatStructureTree parent) {
+ fileTreeRef.putIfAbsent(fullFileName, new HeatStructureTree());
+ HeatStructureTree heatStructureTree = fileTreeRef.get(fullFileName);
+ heatStructureTree.setFileName(splitFilename[startIndex]);
+ if (startIndex < splitFilename.length - 1) {
+ addFileToTree(splitFilename, startIndex + 1,
+ getFullFileName(fullFileName, splitFilename[startIndex + 1]), heatStructureTree);
+ }
+ parent.addHeatStructureTreeToNestedHeatList(heatStructureTree);
+ }
- private String getFullFileName(String parentFullName, String fileName) {
- return parentFullName + File.separator + fileName;
- }
+ /**
+ * Add errors.
+ *
+ * @param validationErrors the validation errors
+ */
+ public void addErrors(Map<String, List<ErrorMessage>> validationErrors) {
+ validationErrors.entrySet().stream().filter(entry ->
+ Objects.nonNull(fileTreeRef.get(entry.getKey()))).forEach(entry -> entry.getValue()
+ .forEach(error -> fileTreeRef.get(entry.getKey()).addErrorToErrorsList(error)));
+ }
- private String[] getFullFileNameAsArray(String filename) {
- if (filename.contains("/")) {
- return filename.split("/");
+ private String getFullFileName(String parentFullName, String fileName) {
+ return parentFullName + File.separator + fileName;
}
- return filename.split(Pattern.quote(File.separator));
- }
+ private String[] getFullFileNameAsArray(String filename) {
+ if (filename.contains("/")) {
+ return filename.split("/");
+ }
+
+ return filename.split(Pattern.quote(File.separator));
+ }
- public HeatStructureTree getTree() {
- return tree;
- }
+ /**
+ * Gets tree.
+ *
+ * @return the tree
+ */
+ public HeatStructureTree getTree() {
+ return tree;
+ }
}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatResourceUtilTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatResourceUtilTest.java
new file mode 100644
index 0000000000..93f8fc9f23
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatResourceUtilTest.java
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ * /
+ *
+ */
+
+package org.openecomp.sdc.heat.services;
+
+import java.util.Optional;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+
+public class HeatResourceUtilTest {
+
+ private static final String ROLE = "role";
+
+ @Test
+ public void testEvaluateNetworkRoleFromResourceIdEmpty() {
+ Assert.assertFalse(HeatResourceUtil.evaluateNetworkRoleFromResourceId(null, null).isPresent());
+ }
+
+ @Test
+ public void testEvaluateNetworkRoleFromResourceIdNeutronExternal() {
+ Optional<String> networkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(
+ "vm_type_1_role_port_1", HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource());
+
+ Assert.assertTrue(networkRole.isPresent());
+ Assert.assertEquals(networkRole.get(), ROLE);
+ }
+
+ @Test
+ public void testEvaluateNetworkRoleFromResourceIdNeutronInternal() {
+ Optional<String> networkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(
+ "vm_type_1_int_role_port_1", HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource());
+
+ Assert.assertTrue(networkRole.isPresent());
+ Assert.assertEquals(networkRole.get(), ROLE);
+ }
+
+ @Test
+ public void testEvaluateNetworkRoleFromResourceIdVMIExternal() {
+ Optional<String> networkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(
+ "vm_type_1_role_vmi_1", HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE
+ .getHeatResource());
+
+ Assert.assertTrue(networkRole.isPresent());
+ Assert.assertEquals(networkRole.get(), ROLE);
+ }
+
+ @Test
+ public void testEvaluateNetworkRoleFromResourceIdVMIInternal() {
+ Optional<String> networkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(
+ "vm_type_1_int_role_vmi_1", HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE
+ .getHeatResource());
+
+ Assert.assertTrue(networkRole.isPresent());
+ Assert.assertEquals(networkRole.get(), ROLE);
+ }
+
+ @Test
+ public void testExtractNetworkRoleFromSubInterfaceIdEmpty() {
+ Assert.assertFalse(HeatResourceUtil.extractNetworkRoleFromSubInterfaceId(null, null).isPresent());
+ }
+
+ @Test
+ public void testExtractNetworkRoleFromSubInterfaceId() {
+ Optional<String> networkRole = HeatResourceUtil.extractNetworkRoleFromSubInterfaceId(
+ "vm_type_1_subint_role_vmi_1", HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE
+ .getHeatResource());
+
+ Assert.assertTrue(networkRole.isPresent());
+ Assert.assertEquals(networkRole.get(), ROLE);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatStructureUtilTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatStructureUtilTest.java
new file mode 100644
index 0000000000..70f149be2c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/HeatStructureUtilTest.java
@@ -0,0 +1,146 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ * /
+ *
+ */
+
+package org.openecomp.sdc.heat.services;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
+
+public class HeatStructureUtilTest {
+
+ @Mock
+ private GlobalValidationContext globalValidationContextMock;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testIsResourceNestedFalse() {
+ Assert.assertFalse(HeatStructureUtil.isNestedResource("Test.txt"));
+ }
+
+ @Test
+ public void testIsResourceNestedNull() {
+ Assert.assertFalse(HeatStructureUtil.isNestedResource(null));
+ }
+
+ @Test
+ public void testIsResourceNestedTrue() {
+ Assert.assertTrue(HeatStructureUtil.isNestedResource("Test.yml"));
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameAddMessageCall() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put(ResourceReferenceFunctions.GET_RESOURCE.getFunction(), Collections.emptyList());
+
+ Mockito.doNothing().when(globalValidationContextMock).addMessage(Mockito.anyString(), Mockito.any(),
+ Mockito.anyString());
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_RESOURCE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Mockito.verify(globalValidationContextMock, Mockito.times(1))
+ .addMessage(Mockito.anyString(), Mockito.any(), Mockito.anyString());
+ Assert.assertTrue(valueNames.isEmpty());
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameGetFile() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put(ResourceReferenceFunctions.GET_FILE.getFunction(), "file:///filename");
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Assert.assertFalse(valueNames.isEmpty());
+ Assert.assertTrue(valueNames.contains("filename"));
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameGetFileValueList() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap
+ .put(ResourceReferenceFunctions.GET_FILE.getFunction(), Collections.singletonList("file:///filename"));
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Assert.assertFalse(valueNames.isEmpty());
+ Assert.assertTrue(valueNames.contains("filename"));
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameGetFileValueListWithAnotherList() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put(ResourceReferenceFunctions.GET_FILE.getFunction(),
+ Collections.singletonList(Collections.emptyList()));
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Assert.assertTrue(valueNames.isEmpty());
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNamePassingPropertyMapWithSet() {
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), Collections.singletonList(new HashSet<>()),
+ globalValidationContextMock);
+
+ Assert.assertTrue(valueNames.isEmpty());
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameGetFileValueListSet() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put(ResourceReferenceFunctions.GET_FILE.getFunction(),
+ new HashSet<>());
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Assert.assertTrue(valueNames.isEmpty());
+ }
+
+ @Test
+ public void testGetReferencedValuesByFunctionNameIncorrectKeyWithSet() {
+ Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put("test", new HashSet<>());
+
+ Set<String> valueNames = HeatStructureUtil.getReferencedValuesByFunctionName("Main.yml",
+ ResourceReferenceFunctions.GET_FILE.getFunction(), propertyMap, globalValidationContextMock);
+
+ Assert.assertTrue(valueNames.isEmpty());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/manifest/ManifestUtilTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/manifest/ManifestUtilTest.java
new file mode 100644
index 0000000000..13cf5c901e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/manifest/ManifestUtilTest.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ * /
+ *
+ */
+
+package org.openecomp.sdc.heat.services.manifest;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+
+public class ManifestUtilTest {
+
+ @Test
+ public void testGetFileAndItsEnvNull() {
+ Assert.assertTrue(ManifestUtil.getFileAndItsEnv(new ManifestContent()).isEmpty());
+ }
+
+ @Test
+ public void testGetFileAndItsEnv() {
+
+ Assert.assertEquals(ManifestUtil.getFileAndItsEnv(createManifestContent()).size(), 1);
+ }
+
+ @Test
+ public void testGetFileTypeMapDataNull() {
+ Assert.assertTrue(ManifestUtil.getFileTypeMap(new ManifestContent()).isEmpty());
+ }
+
+ @Test
+ public void testGetFileTypeMap() {
+ Map<String, FileData.Type> fileTypeMap = ManifestUtil.getFileTypeMap(createManifestContent());
+
+ Assert.assertEquals(fileTypeMap.size(), 2);
+ Assert.assertTrue(fileTypeMap.containsKey("Main.yml") && fileTypeMap.containsKey("Test.yml"));
+ }
+
+ @Test
+ public void testGetFileTypeMapDataBlank() {
+ ManifestContent manifestContent = new ManifestContent();
+ manifestContent.setData(Collections.emptyList());
+
+ Assert.assertTrue(ManifestUtil.getFileTypeMap(manifestContent).isEmpty());
+ }
+
+ @Test
+ public void testGetArtifactsDataNull() {
+ Assert.assertTrue(ManifestUtil.getArtifacts(new ManifestContent()).isEmpty());
+ }
+
+ @Test
+ public void testGetArtifacts() {
+ ManifestContent manifestContent = createManifestContent();
+ manifestContent.getData().get(0).getData().get(0).setType(FileData.Type.OTHER);
+
+ Set<String> typeSet = ManifestUtil.getArtifacts(manifestContent);
+ Assert.assertEquals(typeSet.size(), 1);
+ Assert.assertTrue(typeSet.contains("Test.yml"));
+ }
+
+ @Test
+ public void testGetBaseFilesDataNull() {
+ Assert.assertTrue(ManifestUtil.getArtifacts(new ManifestContent()).isEmpty());
+ }
+
+ @Test
+ public void testGetBaseFiles() {
+ Set<String> typeSet = ManifestUtil.getBaseFiles(createManifestContent());
+ Assert.assertEquals(typeSet.size(), 1);
+ Assert.assertTrue(typeSet.contains("Main.yml"));
+ }
+
+ private ManifestContent createManifestContent() {
+
+ FileData fileData1 = new FileData();
+ fileData1.setFile("Test.yml");
+ fileData1.setType(FileData.Type.HEAT_ENV);
+
+ FileData fileData = new FileData();
+ fileData.setFile("Main.yml");
+ fileData.setType(FileData.Type.HEAT_ENV);
+ fileData.setBase(true);
+
+ fileData.setData(Collections.singletonList(fileData1));
+
+ ManifestContent manifestContent = new ManifestContent();
+ manifestContent.setData(Collections.singletonList(fileData));
+
+ return manifestContent;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
new file mode 100644
index 0000000000..e3e19792f5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ * /
+ *
+ */
+
+package org.openecomp.sdc.heat.services.tree;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+
+public class HeatTreeManagerTest {
+
+ @Test
+ public void testCreateTree() throws IOException {
+ HeatTreeManager heatTreeManager = new HeatTreeManager();
+ addFile(heatTreeManager, "mock/model/MANIFEST.json", SdcCommon.MANIFEST_NAME);
+ addFile(heatTreeManager, "mock/model/first.yaml", "first.yaml");
+ addFile(heatTreeManager, "mock/model/second.yaml", "second.yaml");
+ addFile(heatTreeManager, "mock/model/first.env", "first.env");
+ addFile(heatTreeManager, "mock/model/base_cscf_volume.yaml", "base_cscf_volume.yaml");
+ addFile(heatTreeManager, "mock/model/network.yml", "network.yml");
+ addFile(heatTreeManager, "mock/model/testHeat.yml", "testHeat.yml");
+ addFile(heatTreeManager, "mock/model/nested.yml", "nested.yml");
+ addFile(heatTreeManager, "mock/model/base_cscf_volume.env", "base_cscf_volume.env");
+
+ heatTreeManager.createTree();
+
+ HeatStructureTree heatStructureTree = heatTreeManager.getTree();
+ Assert.assertNotNull(heatStructureTree);
+ Assert.assertEquals(1, heatStructureTree.getHeat().size());
+ Assert.assertEquals(1, heatStructureTree.getNetwork().size());
+ }
+
+ private void addFile(HeatTreeManager heatTreeManager, String fileLocation, String fileName)
+ throws IOException {
+
+ List<URL> urlList = FileUtils.getAllLocations(fileLocation);
+ try (InputStream inputStream = new FileInputStream(new File(urlList.get(0).getPath()))) {
+ heatTreeManager.addFile(fileName, inputStream);
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtilTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtilTest.java
new file mode 100644
index 0000000000..6e34350d19
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtilTest.java
@@ -0,0 +1,230 @@
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ * /
+ *
+ */
+
+package org.openecomp.sdc.heat.services.tree;
+
+import java.io.File;
+import java.net.URL;
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.heat.datatypes.model.Resource;
+
+public class HeatTreeManagerUtilTest {
+
+ private static final String TEST_YML = "test.yml";
+ private static final String TEST = "test";
+ private static final String RESOURCE_DEF = "resource_def";
+
+ @Mock
+ private HeatTreeManager heatTreeManager;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testInitHeatTreeManager() {
+ FileContentHandler fileContentHandler = getFileContentHandler();
+
+ Mockito.doNothing().when(heatTreeManager).addFile(Mockito.any(), Mockito.any());
+ HeatTreeManagerUtil.initHeatTreeManager(fileContentHandler);
+ Mockito.verify(heatTreeManager, Mockito.times(0)).addFile(Mockito.any(), Mockito.any());
+ }
+
+ @Test
+ public void testGetNestedFiles() {
+ HeatOrchestrationTemplate heatOrchestrationTemplate = new HeatOrchestrationTemplate();
+ heatOrchestrationTemplate.setResources(getResourceMap("Type1.yml"));
+ Set<String> nestedFilesSet = HeatTreeManagerUtil.getNestedFiles(heatOrchestrationTemplate);
+
+ Assert.assertNotNull(nestedFilesSet);
+ Assert.assertEquals(nestedFilesSet.size(), 1);
+ }
+
+ @Test
+ public void testGetResourceDefNested() {
+ HeatOrchestrationTemplate heatOrchestrationTemplate = new HeatOrchestrationTemplate();
+ heatOrchestrationTemplate.setResources(getResourceMap("OS::Heat::ResourceGroup"));
+
+ Set<String> nestedFilesSet = HeatTreeManagerUtil.getNestedFiles(heatOrchestrationTemplate);
+ Assert.assertNotNull(nestedFilesSet);
+ Assert.assertTrue(nestedFilesSet.size() == 1 && nestedFilesSet.contains(TEST_YML));
+ }
+
+ @Test
+ public void testGetArtifactFiles() {
+ HeatOrchestrationTemplate heatOrchestrationTemplate = new HeatOrchestrationTemplate();
+ heatOrchestrationTemplate.setResources(getResourceMap("Type1.yml"));
+ Set<String> nestedFilesSet = HeatTreeManagerUtil.getArtifactFiles("filename.yml", heatOrchestrationTemplate,
+ null);
+
+ Assert.assertNotNull(nestedFilesSet);
+ Assert.assertTrue(nestedFilesSet.contains(TEST));
+ }
+
+ @Test
+ public void testGetResourceDefIfProvidedResourceIsNull() {
+ Assert.assertNull(HeatTreeManagerUtil.getResourceDef(new Resource()));
+ }
+
+ @Test
+ public void testGetResourceDef() {
+ Resource resource = new Resource();
+
+ Map<String, Object> resourceMap = new HashMap<>();
+ Map<String, String> nestedResourceMap = new HashMap<String, String>() {{
+ put("type", TEST_YML);
+ }};
+
+ resourceMap.put(RESOURCE_DEF, nestedResourceMap);
+ resource.setProperties(resourceMap);
+ Resource resultResource = HeatTreeManagerUtil.getResourceDef(resource);
+ Assert.assertNotNull(resultResource);
+ Assert.assertEquals(TEST_YML, resultResource.getType());
+ }
+
+ @Test
+ public void testCheckResourceGroupTypeValid() {
+ Resource resource = new Resource();
+
+ Map<String, Object> resourceMap = new HashMap<>();
+ Map<String, Object> nestedResourceMap = new HashMap<String, Object>() {{
+ put("type", Collections.emptyList());
+ }};
+
+ resourceMap.put(RESOURCE_DEF, nestedResourceMap);
+ resource.setProperties(resourceMap);
+
+ GlobalValidationContext globalValidationContextMock = Mockito.mock(GlobalValidationContext.class);
+ Mockito.doNothing().when(globalValidationContextMock).addMessage(Mockito.anyString(), Mockito.any(), Mockito
+ .anyString());
+
+ HeatTreeManagerUtil.checkResourceGroupTypeValid(TEST_YML, TEST, resource, globalValidationContextMock);
+
+ Mockito.verify(globalValidationContextMock, Mockito.times(1))
+ .addMessage(Mockito.anyString(), Mockito.any(), Mockito.anyString());
+ }
+
+ @Test
+ public void testCheckResourceTypeValid() {
+ Resource resource = new Resource();
+
+ Map<String, Object> resourceMap = new HashMap<>();
+ Map<String, Object> nestedResourceMap = new HashMap<String, Object>() {{
+ put("properties", Collections.emptyList());
+ }};
+
+ resourceMap.put(RESOURCE_DEF, nestedResourceMap);
+ resource.setProperties(resourceMap);
+
+ GlobalValidationContext globalValidationContextMock = Mockito.mock(GlobalValidationContext.class);
+ Mockito.doNothing().when(globalValidationContextMock).addMessage(Mockito.anyString(), Mockito.any(), Mockito
+ .anyString());
+
+ HeatTreeManagerUtil.checkResourceTypeValid(TEST_YML, TEST, resource, globalValidationContextMock);
+
+ Mockito.verify(globalValidationContextMock, Mockito.times(1))
+ .addMessage(Mockito.anyString(), Mockito.any(), Mockito.anyString());
+ }
+
+ @Test
+ public void testCheckIfResourceGroupTypeIsNested() {
+ Resource resource = new Resource();
+
+ Map<String, Object> resourceMap = new HashMap<>();
+ Map<String, Object> nestedResourceMap = new HashMap<String, Object>() {{
+ put("type", TEST_YML);
+ }};
+
+ resourceMap.put(RESOURCE_DEF, nestedResourceMap);
+ resource.setProperties(resourceMap);
+
+ GlobalValidationContext globalValidationContextMock = Mockito.mock(GlobalValidationContext.class);
+ Mockito.doNothing().when(globalValidationContextMock).addMessage(Mockito.anyString(), Mockito.any(), Mockito
+ .anyString());
+
+ boolean result = HeatTreeManagerUtil
+ .checkIfResourceGroupTypeIsNested(TEST_YML, TEST, resource, globalValidationContextMock);
+
+ Mockito.verify(globalValidationContextMock, Mockito.times(1))
+ .addMessage(Mockito.anyString(), Mockito.any(), Mockito.anyString());
+
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ public void testCheckIfResourceGroupTypeIsNestedNull() {
+ Assert.assertFalse(HeatTreeManagerUtil.checkIfResourceGroupTypeIsNested(TEST_YML, TEST, new Resource(),
+ null));
+ }
+
+ private FileContentHandler getFileContentHandler() {
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ Map<String, byte[]> filesByteMap = new HashMap<>();
+ List<URL> urlList = FileUtils.getAllLocations("mock/model");
+ File files = new File(urlList.get(0).getPath());
+ if (files.isDirectory()) {
+ int fileCount = 0;
+ for (File file : Objects.requireNonNull(files.listFiles())) {
+ byte[] bytesArray = new byte[(int) file.length()];
+ filesByteMap.put("File" + ++fileCount, bytesArray);
+ }
+ }
+
+ fileContentHandler.setFiles(filesByteMap);
+
+ return fileContentHandler;
+ }
+
+ private Map<String, Resource> getResourceMap(String type) {
+ Resource resource = new Resource();
+ resource.setType(type);
+ Map<String, String> map = new HashMap<>();
+ map.put("get_file", TEST);
+ resource.setProperties(new HashMap<String, Object>() {{
+ put("get_file", Collections.singletonList(map));
+ put("resource_def", new HashMap<String, Object>() {{
+ put("type", TEST_YML);
+ }});
+ }});
+
+
+ return Stream.of(new AbstractMap.SimpleEntry<>("Res1", resource))
+ .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManagerTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManagerTest.java
index 0cfac52318..4ccf7ea623 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManagerTest.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/services/tree/ToscaTreeManagerTest.java
@@ -1,86 +1,103 @@
+/*
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ **/
+
package org.openecomp.sdc.heat.services.tree;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.regex.Pattern;
+
import org.junit.Assert;
import org.junit.Test;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.regex.Pattern;
-
public class ToscaTreeManagerTest {
- private static final String BASE_DIR = "/mock/toscaTree/";
- private static final String IN = "in";
- private static final String OUT = "out";
- private static final String EXPECTED_TREE_FILE = "/expectedTree.json";
- private ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
-
- @Test
- public void testTreeWithDiffFileNames() throws IOException {
- String inputDirectory = BASE_DIR + "diffFileNames/" + IN;
- String outputFileName = BASE_DIR + "diffFileNames/" + OUT + EXPECTED_TREE_FILE;
-
- testTreeManager(inputDirectory, outputFileName);
- }
-
- @Test
- public void testDirectoriesWithSimilarNameUnderDifferentRoots() throws IOException {
- String inputDirectory = BASE_DIR + "similarDirectoryName/" + IN;
- String outputFileName = BASE_DIR + "similarDirectoryName/" + OUT + EXPECTED_TREE_FILE;
-
- testTreeManager(inputDirectory, outputFileName);
- }
-
- @Test
- public void testTwoFilesUnderSameDirectory() throws IOException {
- String inputDirectory = BASE_DIR + "twoFilesUnderSameDirectory/" + IN;
- String outputFileName = BASE_DIR + "twoFilesUnderSameDirectory/" + OUT + EXPECTED_TREE_FILE;
-
- testTreeManager(inputDirectory, outputFileName);
- }
-
- private void testTreeManager(String inputDirectory, String outputFileName) throws IOException {
- initTreeManager(inputDirectory);
- toscaTreeManager.createTree();
- HeatStructureTree tree = toscaTreeManager.getTree();
-
- validateToscaTree(outputFileName, tree);
- }
-
- private void validateToscaTree(String outputFileName, HeatStructureTree tree) throws IOException {
- String actualTree = JsonUtil.object2Json(tree);
- File expectedTreeFile = new File(this.getClass().getResource(outputFileName).getFile());
-
- String expectedTree;
- try(FileInputStream fis = new FileInputStream(expectedTreeFile)) {
- expectedTree = new String(FileUtils.toByteArray(fis));
+
+ private static final String BASE_DIR = "/mock/toscaTree/";
+ private static final String IN = "in";
+ private static final String OUT = "out";
+ private static final String EXPECTED_TREE_FILE = "/expectedTree.json";
+ private ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
+
+ @Test
+ public void testTreeWithDiffFileNames() throws IOException {
+ String inputDirectory = BASE_DIR + "diffFileNames/" + IN;
+ String outputFileName = BASE_DIR + "diffFileNames/" + OUT + EXPECTED_TREE_FILE;
+
+ testTreeManager(inputDirectory, outputFileName);
+ }
+
+ @Test
+ public void testDirectoriesWithSimilarNameUnderDifferentRoots() throws IOException {
+ String inputDirectory = BASE_DIR + "similarDirectoryName/" + IN;
+ String outputFileName = BASE_DIR + "similarDirectoryName/" + OUT + EXPECTED_TREE_FILE;
+
+ testTreeManager(inputDirectory, outputFileName);
+ }
+
+ @Test
+ public void testTwoFilesUnderSameDirectory() throws IOException {
+ String inputDirectory = BASE_DIR + "twoFilesUnderSameDirectory/" + IN;
+ String outputFileName = BASE_DIR + "twoFilesUnderSameDirectory/" + OUT + EXPECTED_TREE_FILE;
+
+ testTreeManager(inputDirectory, outputFileName);
}
- Assert.assertNotNull(expectedTree);
- expectedTree = expectedTree.trim().replace("\r", "");
- Assert.assertEquals(expectedTree, actualTree);
- }
-
- private void initTreeManager(String inputDir) throws IOException {
- String fileName = inputDir.replace("/", File.separator);
- File directory = new File(this.getClass().getResource(inputDir).getFile());
-
- addFilesToTreeManager(fileName, directory.listFiles());
- }
-
- private void addFilesToTreeManager(String baseDir, File[] listFiles) throws IOException {
- for (File file : listFiles) {
- if (file.isDirectory()) {
- addFilesToTreeManager(baseDir, file.listFiles());
- } else {
- toscaTreeManager.addFile(getFileNameWithoutTestDirectory(baseDir, file.getPath()), new byte[2]);
- }
+
+ private void testTreeManager(String inputDirectory, String outputFileName) throws IOException {
+ initTreeManager(inputDirectory);
+ toscaTreeManager.createTree();
+ HeatStructureTree tree = toscaTreeManager.getTree();
+
+ validateToscaTree(outputFileName, tree);
}
- }
- private String getFileNameWithoutTestDirectory(String baseDir, String fileName) {
- return fileName.split(Pattern.quote(baseDir) + Pattern.quote(File.separator))[1];
- }
+ private void validateToscaTree(String outputFileName, HeatStructureTree tree) throws IOException {
+ File expectedTreeFile = new File(this.getClass().getResource(outputFileName).getFile());
+
+ String expectedTree;
+ try (FileInputStream fis = new FileInputStream(expectedTreeFile)) {
+ expectedTree = new String(FileUtils.toByteArray(fis));
+ }
+ Assert.assertNotNull(expectedTree);
+ expectedTree = expectedTree.trim().replace("\r", "");
+ String actualTree = JsonUtil.object2Json(tree);
+ Assert.assertEquals(expectedTree, actualTree);
+ }
+
+ private void initTreeManager(String inputDir) {
+ String fileName = inputDir.replace("/", File.separator);
+ File directory = new File(this.getClass().getResource(inputDir).getFile());
+
+ addFilesToTreeManager(fileName, directory.listFiles());
+ }
+
+ private void addFilesToTreeManager(String baseDir, File[] listFiles) {
+ for (File file : listFiles) {
+ if (file.isDirectory()) {
+ addFilesToTreeManager(baseDir, file.listFiles());
+ } else {
+ toscaTreeManager.addFile(getFileNameWithoutTestDirectory(baseDir, file.getPath()), new byte[2]);
+ }
+ }
+ }
+
+ private String getFileNameWithoutTestDirectory(String baseDir, String fileName) {
+ return fileName.split(Pattern.quote(baseDir) + Pattern.quote(File.separator))[1];
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/MANIFEST.json b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/MANIFEST.json
new file mode 100644
index 0000000000..fefb79cf5b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/MANIFEST.json
@@ -0,0 +1,48 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true,
+ "data": [
+ {
+ "file": "first.env",
+ "type": "HEAT_ENV"
+ },
+ {
+ "file": "base_cscf_volume.yaml",
+ "type": "HEAT_VOL",
+ "data": [
+ {
+ "file": "base_cscf_volume.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "file": "nested.yml",
+ "type": "HEAT",
+ "isBase": false
+ },
+ {
+ "file": "network.yml",
+ "type": "HEAT_NET"
+ },
+ {
+ "file": "testHeat.yml",
+ "type": "OTHER"
+ },
+ {
+ "file": "testHeat.yml",
+ "type": "VF_LICENSE"
+ },
+ {
+ "file": "envSettings.env"
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.env b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.env
new file mode 100644
index 0000000000..9f0eef670c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.env
@@ -0,0 +1,9 @@
+## Name: "base_cscf_volume.env"
+## Date: 20 Mar 2017
+## Kilo Version
+parameters:
+# PSEUDO CONSTANTS
+# -----------------------------------------------------------------------------
+ cif_volume_size_0: 300
+ oam_volume_size_0: 300
+ vcscf_name_delimeter: "_" \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.yaml b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.yaml
new file mode 100644
index 0000000000..145f82e9ec
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/base_cscf_volume.yaml
@@ -0,0 +1,103 @@
+## Name: "base_cscf_volume.yaml"
+## Date: 20 Mar 2017
+## Kilo Version
+heat_template_version: 2015-04-30
+
+description: Volume template for CFX
+
+parameters:
+ vnf_name:
+ type: string
+ description: Unique name for this VF instance
+
+ vcscf_name_delimeter:
+ type: string
+ description: 'delimeter used in concatenating different words while naming (ex: "-","_",".",...)'
+ constraints:
+ - allowed_values: [ '-', '', '_', '.']
+
+ availability_zone_0:
+ type: string
+ description: Storage availability zone for volume of first vm
+
+ availability_zone_1:
+ type: string
+ description: Storage availability zone for volume of second vm
+
+ cif_volume_size_0:
+ type: number
+ description: Size of Volume for cif VMs
+ constraints:
+ - range: { min: 1, max: 300 }
+
+ oam_volume_size_0:
+ type: number
+ description: Size of Volume for oam VMs
+ constraints:
+ - range: { min: 1, max: 300 }
+
+resources:
+ cif_volume_0:
+ type: OS::Cinder::Volume
+ properties:
+ size: { get_param: cif_volume_size_0 }
+ availability_zone: { get_param: availability_zone_0}
+ name:
+ str_replace:
+ template: "$VNF$DELcif$DELvolume$DEL0"
+ params:
+ $VNF: { get_param: vnf_name }
+ $DEL: { get_param: vcscf_name_delimeter }
+
+ cif_volume_1:
+ type: OS::Cinder::Volume
+ properties:
+ availability_zone: { get_param: availability_zone_1}
+ size: { get_param: cif_volume_size_0 }
+ name:
+ str_replace:
+ template: "$VNF$DELcif$DELvolume$DEL1"
+ params:
+ $VNF: { get_param: vnf_name }
+ $DEL: { get_param: vcscf_name_delimeter }
+
+ oam_volume_0:
+ type: OS::Cinder::Volume
+ properties:
+ size: { get_param: oam_volume_size_0 }
+ availability_zone: { get_param: availability_zone_0}
+ name:
+ str_replace:
+ template: "$VNF$DELoam$DELvolume$DEL0"
+ params:
+ $VNF: { get_param: vnf_name }
+ $DEL: { get_param: vcscf_name_delimeter }
+
+ oam_volume_1:
+ type: OS::Cinder::Volume
+ properties:
+ size: { get_param: oam_volume_size_0 }
+ availability_zone: { get_param: availability_zone_1}
+ name:
+ str_replace:
+ template: "$VNF$DELoam$DELvolume$DEL1"
+ params:
+ $VNF: { get_param: vnf_name }
+ $DEL: { get_param: vcscf_name_delimeter }
+
+outputs:
+ cif_volume_id_0:
+ description: volume id for first cif
+ value: {get_resource: cif_volume_0}
+
+ cif_volume_id_1:
+ description: volume id for second cif
+ value: {get_resource: cif_volume_1}
+
+ oam_volume_id_0:
+ description: volume id for first oam
+ value: {get_resource: oam_volume_0}
+
+ oam_volume_id_1:
+ description: volume id for second oam
+ value: {get_resource: oam_volume_1}
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.env b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.env
new file mode 100644
index 0000000000..90bdb18e56
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.env
@@ -0,0 +1,2 @@
+parameters:
+network_ids: Internal2_net_id \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.yaml b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.yaml
new file mode 100644
index 0000000000..02234e9222
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/first.yaml
@@ -0,0 +1,71 @@
+heat_template_version: 2013-05-23
+description: heat expose volume resource
+
+parameters:
+ network_ids:
+ type: string
+ label: FBS2 label
+ description: FBS2 internal id2
+
+resources:
+ vm_config:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ group: ungrouped
+ config:
+ str_replace:
+ template: {get_file: envSettings.env}
+
+ cmaui_port_2:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_resource: test_net1 }
+ fixed_ips: [{"ip_address": {get_param: [cmaui_oam_ips, 0]}}]
+ security_groups: [{get_param: security_group_name}]
+ replacement_policy: AUTO
+
+ test_net1:
+ type: OS::Neutron::Net
+ properties:
+ name: {get_param: jsa_net_name}
+ shared: True
+
+ FSB2_Internal1:
+ type: OS::Neutron::Port
+ properties:
+ network_id: Internal1_net_id
+ FSB2_Internal2:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: [network_ids, 0] }
+ FSB2_OAM:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: Internal1_net_name }
+ FSB2:
+ type: OS::Nova::Server
+ properties:
+ name: fsb2_name_2
+ block_device_mapping: [{device_name: "vda", volume_id : {get_param: cif_volume_id_0 }, delete_on_termination: "false" }]
+ flavor: fsb2_flavor_name
+ availability_zone: availability_zone_0
+ metadata:
+ VNF_id: { get_param: vnfvfVF_id }
+ vf_module_id: { get_param: vf_module_id }
+ networks:
+ - port: { get_resource: FSB2_Internal1 }
+ - port: { get_resource: FSB2_Internal2 }
+ - port: { get_resource: FSB2_OAM }
+
+ test_nested:
+ type: nested.yml
+ properties:
+ p2: { get_resource: cmaui_port_2}
+ net1: { get_resource: test_net1}
+
+outputs:
+ expose_resource_nove_output:
+ description: the pcrf_server
+ value: { get_resource: FSB2 }
+
+
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/nested.yml b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/nested.yml
new file mode 100644
index 0000000000..e68541e3ae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/nested.yml
@@ -0,0 +1,76 @@
+heat_template_version: 2013-05-23
+
+description: cmaui server template for vMMSC
+
+parameters:
+ p1:
+ type: number
+ p2:
+ type: string
+ net1:
+ type: string
+ net2:
+ type: string
+ lb_st_vlan_type_oam:
+ description: dummy
+ type: string
+ mac_address:
+ type: string
+ virtual_ip_address:
+ type: string
+ virtual_ipv6_address:
+ type: string
+ vlan_ids:
+ type: string
+ subinterface_name_prefix:
+ type: string
+ subinterface_instance_index:
+ type: number
+resources:
+
+
+ vdbe_0_subint_untr_vmi_0:
+ type: OS::ContrailV2::VirtualMachineInterface
+ properties:
+ name:
+ str_replace:
+ template: $NAME$VLAN
+ params:
+ $NAME: { get_param: subinterface_name_prefix }
+ $VLAN: { get_param: [ vlan_ids, { get_param: subinterface_instance_index } ] }
+ virtual_machine_interface_properties:
+ {
+ virtual_machine_interface_properties_sub_interface_vlan_tag: { get_param: lb_st_vlan_type_oam }
+ }
+ virtual_machine_interface_mac_addresses:
+ {
+ virtual_machine_interface_mac_addresses_mac_address: [{ get_param: mac_address }],
+ }
+ virtual_machine_interface_allowed_address_pairs:
+ {
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair: [
+ {
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_address_mode: active-standby,
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_mac: { get_param: mac_address },
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip:
+ {
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix: { get_param: virtual_ip_address },
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix_len: 32
+ }
+ },
+ {
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_address_mode: active-standby,
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_mac: { get_param: mac_address },
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip:
+ {
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix: { get_param: virtual_ipv6_address },
+ virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix_len: 128
+ }
+ }
+ ]
+ }
+ virtual_network_refs: [{ get_param: net2 },{ get_param: net1 }]
+ virtual_machine_interface_refs: [{ get_param: p2 }]
+
+
+
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/network.yml b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/network.yml
new file mode 100644
index 0000000000..f069d4dd23
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/network.yml
@@ -0,0 +1,733 @@
+heat_template_version: 2013-05-23
+
+description: heat template that creates MOG stack
+
+parameters:
+ pd_server_names:
+ type: comma_delimited_list
+ label: PD server names
+ description: name of the PD instance
+ pd_image_name:
+ type: string
+ label: image name
+ description: PD image name
+ pd_flavor_name:
+ type: string
+ label: PD flavor name
+ description: flavor name of PD instance
+ oam_server_names:
+ type: comma_delimited_list
+ label: OAM server names
+ description: name of the OAM instance
+ oam_image_name:
+ type: string
+ label: image name
+ description: OAM image name
+ oam_flavor_name:
+ type: string
+ label: OAM flavor name
+ description: flavor name of OAM instance
+ sm_server_names:
+ type: comma_delimited_list
+ label: SM server names
+ description: name of the SM instance
+ sm_image_name:
+ type: string
+ label: image name
+ description: SM image name
+ sm_flavor_name:
+ type: string
+ label: SM flavor name
+ description: flavor name of SM instance
+ ps_server_names:
+ type: comma_delimited_list
+ label: PS server names
+ description: name of the PS instance
+ ps_image_name:
+ type: string
+ label: PS image name
+ description: PS image name
+ ps_flavor_name:
+ type: string
+ label: PS flavor name
+ description: flavor name of PS instance
+ cm_server_names:
+ type: comma_delimited_list
+ label: CM server names
+ description: name of the CM instance
+ cm_image_name:
+ type: string
+ label: image name
+ description: CM image name
+ cm_flavor_name:
+ type: string
+ label: CM flavor name
+ description: flavor name of CM instance
+ availabilityzone_name:
+ type: string
+ label: availabilityzone name
+ description: availabilityzone name
+ oam_net_name:
+ type: string
+ label: oam network name
+ description: name of the oam network
+ oam_net_ips:
+ type: comma_delimited_list
+ label: internet network ips
+ description: ip of the OAM network
+ # internet_net_name:
+ # type: string
+ # label: internet network name
+ # description: id of the internet network
+ # internet_net_ips:
+ # type: comma_delimited_list
+ # label: internet network ips
+ # description: ip of the internet network
+ # internet_net_floating_ip:
+ # type: string
+ # label: mog internet virtual ip
+ # description: mog internet virtual ip
+ sl_net_name:
+ type: string
+ label: silver lining network name
+ description: id of the sl network
+ sl_net_ips:
+ type: comma_delimited_list
+ label: silver lining network ips
+ description: ips of the sl network
+ sl_net_floating_ip:
+ type: string
+ label: mog sl net virtual ip
+ description: mog sl net virtual ip
+ repl_net_name:
+ type: string
+ label: Replication network name
+ description: name of the replication network
+ repl_net_ips:
+ type: comma_delimited_list
+ label: repl network ips
+ description: ips of repl network
+ rx_net_name:
+ type: string
+ label: Rx network name
+ description: Rx network name
+ rx_net_ips:
+ type: comma_delimited_list
+ label: Rx network ips
+ description: Rx network ips
+ rx_net_floating_ip:
+ type: string
+ label: mog rx net virtual ip
+ description: mog rx net virtual ip
+ ran_net_name:
+ type: string
+ label: RAN network name
+ description: RAN network name
+ ran_net_ips:
+ type: comma_delimited_list
+ label: RAN network ips
+ description: RAN network ip
+ ran_net_floating_ip:
+ type: string
+ label: mog ran net virtual ip
+ description: mog ran net virtual ip
+ csb_net_name:
+ type: string
+ label: csb internal network name
+ description: csb internal network name
+ csb_net_start:
+ type: string
+ label: csb internal start
+ description: csb internal start
+ csb_net_end:
+ type: string
+ label: csb internal end
+ description: csb internal end
+ csb_net_cidr:
+ type: string
+ label: csb ineternal cidr
+ description: csb internal cidr
+ csb_net_netmask:
+ type: string
+ description: CSB internal network subnet mask
+ csb_net_ips:
+ type: comma_delimited_list
+ description: mog_csb_net IP addresses
+ dummy_net_name_0:
+ type: string
+ label: csb internal network name
+ description: csb internal network name
+ dummy_net_start_0:
+ type: string
+ label: csb internal start
+ description: csb internal start
+ dummy_net_end_0:
+ type: string
+ label: csb internal end
+ description: csb internal end
+ dummy_net_cidr_0:
+ type: string
+ label: csb ineternal cidr
+ description: csb internal cidr
+ dummy_net_netmask_0:
+ type: string
+ description: CSB internal network subnet mask
+ dummy_net_name_1:
+ type: string
+ label: csb internal network name
+ description: csb internal network name
+ dummy_net_start_1:
+ type: string
+ label: csb internal start
+ description: csb internal start
+ dummy_net_end_1:
+ type: string
+ label: csb internal end
+ description: csb internal end
+ dummy_net_cidr_1:
+ type: string
+ label: csb ineternal cidr
+ description: csb internal cidr
+ dummy_net_netmask_1:
+ type: string
+ description: CSB internal network subnet mask
+
+ security_group_name:
+ type: string
+ label: security group name
+ description: the name of security group
+ cluster-manager-vol-1:
+ type: string
+ label: mog-cm-vol-1
+ description: Cluster Manager volume 1
+ session-manager-vol-1:
+ type: string
+ label: mog-sm-vol-1
+ description: Session Manager volume 1
+ session-manager-vol-2:
+ type: string
+ label: mog-sm-vol-2
+ description: Session Manager volume 2
+ oam-vol-1:
+ type: string
+ label: mog-oam-vol-1
+ description: OAM volume 1
+ oam-vol-2:
+ type: string
+ label: mog-oam-vol-2
+ description: OAM volume 2
+ mog_swift_container:
+ type: string
+ label: mog Config URL
+ description: Config URL
+ mog_script_dir:
+ type: string
+ label: mog Config script directory
+ description: Config script directory
+ mog_script_name:
+ type: string
+ label: mog Config script name
+ description: Config script name
+ mog_parameter_name:
+ type: string
+ label: mog script parameter name
+ description: Config script parameter csv file name
+ cluster-manager-vol-2:
+ type: string
+ label: mog-cm-vol-2
+ description: Cluster Manager volume 2 with ISO image
+
+resources:
+ mog_security_group:
+ type: OS::Neutron::SecurityGroup
+ properties:
+ description: mog security group
+ name: {get_param: security_group_name}
+ rules: [{"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0},
+ {"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0},
+ {"direction": egress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0},
+ {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0},
+ {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0},
+ {"direction": ingress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0}
+ ]
+
+ csb_net:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ name: { get_param: csb_net_name}
+
+ csb_ip_subnet:
+ type: OS::Neutron::Subnet
+ properties:
+ name: {get_param: csb_net_name}
+ network_id: { get_resource: csb_net }
+ cidr: { get_param: csb_net_cidr }
+ allocation_pools: [{"start": {get_param: csb_net_start}, "end": {get_param: csb_net_end}}]
+ enable_dhcp: true
+
+ dummy_net_0:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ name: { get_param: dummy_net_name_0}
+
+ dummy_ip_subnet_0:
+ type: OS::Neutron::Subnet
+ properties:
+ name: {get_param: dummy_net_name_0}
+ network_id: { get_resource: dummy_net_0 }
+ cidr: { get_param: dummy_net_cidr_0 }
+ allocation_pools: [{"start": {get_param: dummy_net_start_0}, "end": {get_param: dummy_net_end_0}}]
+ enable_dhcp: true
+
+ dummy_net_1:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ name: { get_param: dummy_net_name_1}
+
+ dummy_ip_subnet_1:
+ type: OS::Neutron::Subnet
+ properties:
+ name: {get_param: dummy_net_name_1}
+ network_id: { get_resource: dummy_net_1 }
+ cidr: { get_param: dummy_net_cidr_1 }
+ allocation_pools: [{"start": {get_param: dummy_net_start_1}, "end": {get_param: dummy_net_end_1}}]
+ enable_dhcp: true
+
+
+ mogconfig:
+ type: OS::Heat::SoftwareConfig
+ properties:
+ group: ungrouped
+ config:
+ str_replace:
+ template: |
+ #!/bin/bash
+ wget -P script_dir swift_container/script_name
+ wget -P script_dir swift_container/parameter_name
+ chmod 755 script_dir/script_name
+ script_dir/script_name
+ params:
+ swift_container: {get_param: mog_swift_container}
+ script_dir: {get_param: mog_script_dir}
+ script_name: {get_param: mog_script_name}
+ #parameter_name: {get_param: mog_parameter_name}
+
+
+ servergroup_mog01:
+ type: OS::Nova::ServerGroup
+ properties:
+ policies:
+ - anti-affinity
+ server_pd_01:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [pd_server_names, 0]}
+ image: {get_param: pd_image_name}
+ flavor: {get_param: pd_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: pd01_port_0}
+ - port: {get_resource: pd01_port_1}
+ - port: {get_resource: pd01_port_2}
+ - port: {get_resource: pd01_port_3}
+ - port: {get_resource: pd01_port_4}
+ - port: {get_resource: pd01_port_5}
+ - port: {get_resource: pd01_port_6}
+ # - port: {get_resource: pd01_port_7}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog01}}
+ user_data_format: RAW
+
+
+ pd01_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+ pd01_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: oam_net_name}
+ fixed_ips: [{"ip_address": {get_param: [oam_net_ips, 0]}}]
+ security_groups: [{get_resource: mog_security_group}]
+ pd01_port_2:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_0}
+ security_groups: [{get_resource: mog_security_group}]
+ pd01_port_3:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: rx_net_name}
+ fixed_ips: [{"ip_address": {get_param: [rx_net_ips, 0]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: rx_net_floating_ip} }]
+ security_groups: [{get_resource: mog_security_group}]
+ pd01_port_4:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_1}
+ security_groups: [{get_resource: mog_security_group}]
+ pd01_port_5:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: ran_net_name}
+ fixed_ips: [{"ip_address": {get_param: [ran_net_ips, 0]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: ran_net_floating_ip} }]
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd01_port_6:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: sl_net_name}
+ fixed_ips: [{"ip_address": {get_param: [sl_net_ips, 0]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: sl_net_floating_ip}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ # pd01_port_7:
+ #j type: OS::Neutron::Port
+ # properties:
+ # network: {get_param: internet_net_name}
+ # fixed_ips: [{"ip_address": {get_param: [internet_net_ips, 0]}}]
+ # allowed_address_pairs: [{"ip_address": {get_param: internet_net_floating_ip} }]
+ # security_groups: [{get_resource: mog_security_group}]
+
+ server_pd_02:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [pd_server_names, 1]}
+ image: {get_param: pd_image_name}
+ flavor: {get_param: pd_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: pd02_port_0}
+ - port: {get_resource: pd02_port_1}
+ - port: {get_resource: pd01_port_2}
+ - port: {get_resource: pd01_port_3}
+ - port: {get_resource: pd02_port_4}
+ - port: {get_resource: pd02_port_5}
+ - port: {get_resource: pd02_port_6}
+ # - port: {get_resource: pd02_port_7}
+
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog01}}
+ user_data_format: RAW
+
+ pd02_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: oam_net_name}
+ fixed_ips: [{"ip_address": {get_param: [oam_net_ips, 1]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_2:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_0}
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_3:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: rx_net_name}
+ fixed_ips: [{"ip_address": {get_param: [rx_net_ips, 1]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: rx_net_floating_ip} }]
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_4:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_1}
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_5:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: ran_net_name}
+ fixed_ips: [{"ip_address": {get_param: [ran_net_ips, 1]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: ran_net_floating_ip} }]
+ security_groups: [{get_resource: mog_security_group}]
+
+ pd02_port_6:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: sl_net_name}
+ fixed_ips: [{"ip_address": {get_param: [sl_net_ips, 1]}}]
+ allowed_address_pairs: [{"ip_address": {get_param: sl_net_floating_ip}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ # pd02_port_7:
+ # type: OS::Neutron::Port
+ # properties:
+ # network: {get_param: internet_net_name}
+ # fixed_ips: [{"ip_address": {get_param: [internet_net_ips, 1]}}]
+ # allowed_address_pairs: [{"ip_address": {get_param: internet_net_floating_ip} }]
+ # security_groups: [{get_resource: mog_security_group}]
+
+ servergroup_mog02:
+ type: OS::Nova::ServerGroup
+ properties:
+ policies:
+ - anti-affinity
+ server_oam01:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [oam_server_names, 0]}
+ image: {get_param: oam_image_name}
+ flavor: {get_param: oam_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: oam01_port_0}
+ - port: {get_resource: oam01_port_1}
+# block_device_mapping:
+# - device_name: vdd
+# volume_id: { get_param: oam-vol-1 }
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog02}}
+ user_data_format: RAW
+
+ oam01_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ oam01_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: oam_net_name}
+ fixed_ips: [{"ip_address": {get_param: [oam_net_ips, 2]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+
+ server_oam02:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [oam_server_names, 1]}
+ image: {get_param: oam_image_name}
+ flavor: {get_param: oam_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: oam02_port_0}
+ - port: {get_resource: oam02_port_1}
+# block_device_mapping:
+# - device_name: vdd
+# volume_id: { get_param: oam-vol-2 }
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog02}}
+ user_data_format: RAW
+
+ oam02_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ oam02_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: oam_net_name}
+ fixed_ips: [{"ip_address": {get_param: [oam_net_ips, 3]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+
+ server_sm01:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [sm_server_names, 0]}
+ image: {get_param: sm_image_name}
+ flavor: {get_param: sm_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: sm01_port_0}
+ - port: {get_resource: sm01_port_1}
+# block_device_mapping:
+# - device_name: vdd
+# volume_id: { get_param: session-manager-vol-1 }
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog02}}
+ user_data_format: RAW
+
+ sm01_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ sm01_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_0}
+ security_groups: [{get_resource: mog_security_group}]
+
+ sm01_port_2:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: repl_net_name}
+ fixed_ips: [{"ip_address": {get_param: [repl_net_ips, 0]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ server_sm02:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [sm_server_names, 1]}
+ image: {get_param: sm_image_name}
+ flavor: {get_param: sm_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+# block_device_mapping:
+# - device_name: vdd
+# volume_id: { get_param: session-manager-vol-2 }
+ networks:
+ - port: {get_resource: sm02_port_0}
+ - port: {get_resource: sm02_port_1}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog02}}
+ user_data_format: RAW
+
+ sm02_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ sm02_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: dummy_net_0}
+ security_groups: [{get_resource: mog_security_group}]
+
+ sm02_port_2:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: repl_net_name}
+ fixed_ips: [{"ip_address": {get_param: [repl_net_ips, 1]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ servergroup_mog03:
+ type: OS::Nova::ServerGroup
+ properties:
+ policies:
+ - anti-affinity
+ server_ps01:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [ps_server_names, 0]}
+ image: {get_param: ps_image_name}
+ flavor: {get_param: ps_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: ps01_port_0}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog03}}
+ user_data_format: RAW
+
+ ps01_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ server_ps02:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [ps_server_names, 1]}
+ image: {get_param: ps_image_name}
+ flavor: {get_param: ps_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: ps02_port_0}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog03}}
+ user_data_format: RAW
+
+ ps02_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ server_ps03:
+ type: OS::Nova::Server
+ properties:
+ name: {get_param: [ps_server_names, 2]}
+ image: {get_param: ps_image_name}
+ flavor: {get_param: ps_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: ps03_port_0}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog03}}
+ user_data_format: RAW
+
+ ps03_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ server_ps04:
+ type: OS::Nova::Server
+ properties:
+ name: {get_param: [ps_server_names, 3]}
+ image: {get_param: ps_image_name}
+ flavor: {get_param: ps_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: ps04_port_0}
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog03}}
+ user_data_format: RAW
+
+ ps04_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ security_groups: [{get_resource: mog_security_group}]
+
+ server_cm01:
+ type: OS::Nova::Server
+ properties:
+# config_drive: "True"
+ name: {get_param: [cm_server_names, 0]}
+ image: {get_param: cm_image_name}
+ flavor: {get_param: cm_flavor_name}
+ availability_zone: {get_param: availabilityzone_name}
+ networks:
+ - port: {get_resource: cm01_port_0}
+ - port: {get_resource: cm01_port_1}
+# block_device_mapping:
+# - device_name: vdd
+# volume_id: { get_param: cluster-manager-vol-2 }
+# - device_name: vde
+# volume_id: { get_param: cluster-manager-vol-1 }
+ user_data:
+ scheduler_hints: {group: {get_resource: servergroup_mog03}}
+ user_data_format: RAW
+
+ cm01_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_resource: csb_net}
+ fixed_ips: [{"ip_address": {get_param: [csb_net_ips, 10]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
+ cm01_port_1:
+ type: OS::Neutron::Port
+ properties:
+ network: {get_param: oam_net_name}
+ fixed_ips: [{"ip_address": {get_param: [oam_net_ips, 4]}}]
+ security_groups: [{get_resource: mog_security_group}]
+
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/second.yaml b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/second.yaml
new file mode 100644
index 0000000000..bb06b9d60a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/resources/mock/model/second.yaml
@@ -0,0 +1,14 @@
+heat_template_version: 2013-05-23
+
+description: heat second
+
+resources:
+ network_expose:
+ type: OS::Neutron::Net
+
+outputs:
+ expose_resource_network_output:
+ description: the pcrf_server
+ value: { get_resource: network_expose }
+
+