summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/openecomp-tosca-datatype/pom.xml5
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ActivityDefinition.java41
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java9
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Credential.java55
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java9
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EventFilter.java32
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java19
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java29
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java59
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java111
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java18
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java9
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java65
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java9
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java19
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PreconditionDefinition.java32
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java15
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java9
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Repository.java32
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java33
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/StepDefinition.java71
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TimeInterval.java24
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java10
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Trigger.java99
-rw-r--r--common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/WorkflowDefinition.java55
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java73
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java48
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java49
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceObjectErrorBuilder.java24
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceOperationObjectErrorBuilder.java22
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidInterfaceValueErrorBuilder.java21
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java155
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java174
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml12
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml109
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml112
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml112
38 files changed, 1657 insertions, 126 deletions
diff --git a/common/openecomp-tosca-datatype/pom.xml b/common/openecomp-tosca-datatype/pom.xml
index 7fbedef7cd..27a13c6a21 100644
--- a/common/openecomp-tosca-datatype/pom.xml
+++ b/common/openecomp-tosca-datatype/pom.xml
@@ -20,5 +20,10 @@
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>${commons.collections.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ActivityDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ActivityDefinition.java
new file mode 100644
index 0000000000..47800a4c2a
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ActivityDefinition.java
@@ -0,0 +1,41 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+public class ActivityDefinition {
+
+ private String delegate;
+ private String set_state;
+ private String call_operation;
+ private String inline;
+
+ public String getDelegate() {
+ return delegate;
+ }
+
+ public void setDelegate(String delegate) {
+ this.delegate = delegate;
+ }
+
+ public String getSet_state() {
+ return set_state;
+ }
+
+ public void setSet_state(String set_state) {
+ this.set_state = set_state;
+ }
+
+ public String getCall_operation() {
+ return call_operation;
+ }
+
+ public void setCall_operation(String call_operation) {
+ this.call_operation = call_operation;
+ }
+
+ public String getInline() {
+ return inline;
+ }
+
+ public void setInline(String inline) {
+ this.inline = inline;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java
index 873796445d..64428d3920 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java
@@ -29,6 +29,7 @@ public class ArtifactType {
private String derived_from;
private String version;
+ private Map<String, String> metadata;
private String description;
private String mime_type;
private List<String> file_ext;
@@ -51,6 +52,14 @@ public class ArtifactType {
this.version = version;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public String getDescription() {
return description;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Credential.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Credential.java
new file mode 100644
index 0000000000..19138ca69f
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Credential.java
@@ -0,0 +1,55 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.util.Map;
+
+public class Credential {
+ private String protocol;
+ private String token_type;
+ private String token;
+ private Map<String, String> keys;
+ private String user;
+
+ public Credential(){
+ this.token_type = "password";
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getToken_type() {
+ return token_type;
+ }
+
+ public void setToken_type(String token_type) {
+ this.token_type = token_type;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public Map<String, String> getKeys() {
+ return keys;
+ }
+
+ public void setKeys(Map<String, String> keys) {
+ this.keys = keys;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java
index 7a3732e9ad..84ec4cb030 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java
@@ -27,6 +27,7 @@ public class DataType {
private String derived_from;
private String version;
+ Map<String, String> metadata;
private String description;
private List<Constraint> constraints;
private Map<String, PropertyDefinition> properties;
@@ -67,6 +68,14 @@ public class DataType {
this.version = version;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
/**
* Gets description.
*
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EventFilter.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EventFilter.java
new file mode 100644
index 0000000000..794997050f
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EventFilter.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+public class EventFilter {
+
+ private String node;
+ private String requirement;
+ private String capability;
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public String getRequirement() {
+ return requirement;
+ }
+
+ public void setRequirement(String requirement) {
+ this.requirement = requirement;
+ }
+
+ public String getCapability() {
+ return capability;
+ }
+
+ public void setCapability(String capability) {
+ this.capability = capability;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java
index 00eebbf273..0da5207479 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java
@@ -29,8 +29,10 @@ public class GroupDefinition {
private String type;
private String description;
+ private Map<String, String> metadata;
private Map<String, Object> properties;
private List<String> members;
+ private Map<String, Object> interfaces;
public String getType() {
return type;
@@ -63,4 +65,21 @@ public class GroupDefinition {
public void setMembers(List<String> members) {
this.members = members;
}
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public Map<String, Object> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(
+ Map<String, Object> interfaces) {
+ this.interfaces = interfaces;
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java
index 9f857e1fcc..81badd2af9 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java
@@ -29,9 +29,12 @@ public class GroupType {
private String derived_from;
private String version;
+ private Map<String, String> metadata;
private String description;
private Map<String, PropertyDefinition> properties;
private List<String> members;
+ private List<Map<String, RequirementDefinition>> requirements;
+ private Map<String, CapabilityDefinition> capabilities;
private Map<String, Object> interfaces;
public String getDerived_from() {
@@ -50,6 +53,32 @@ public class GroupType {
this.version = version;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public List<Map<String, RequirementDefinition>> getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(
+ List<Map<String, RequirementDefinition>> requirements) {
+ this.requirements = requirements;
+ }
+
+ public Map<String, CapabilityDefinition> getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(
+ Map<String, CapabilityDefinition> capabilities) {
+ this.capabilities = capabilities;
+ }
+
public String getDescription() {
return description;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java
index ecfbbaff21..745f49dcfa 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.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,7 +20,62 @@
package org.openecomp.sdc.tosca.datatypes.model;
+import org.apache.commons.collections4.MapUtils;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
public class InterfaceDefinition {
+
+ private String type;
+ private Map<String, PropertyDefinition> inputs;
+ private Map<String, OperationDefinition> operations;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(
+ Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
+ }
+
+ public Map<String, OperationDefinition> getOperations() {
+ return operations;
+ }
+
+ public void addOperation(String operationName, OperationDefinition operationDefinition) {
+ if (MapUtils.isEmpty(this.operations)) {
+ this.operations = new HashMap<>();
+ }
+ this.operations.put(operationName, operationDefinition);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof InterfaceDefinition)) {
+ return false;
+ }
+ InterfaceDefinition that = (InterfaceDefinition) o;
+ return Objects.equals(type, that.type) &&
+ Objects.equals(inputs, that.inputs) &&
+ Objects.equals(operations, that.operations);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, inputs, operations);
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java
index a9f0b2d917..22d8e7c6ff 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java
@@ -20,7 +20,118 @@
package org.openecomp.sdc.tosca.datatypes.model;
+import org.apache.commons.collections4.MapUtils;
+import java.util.HashMap;
+import java.util.Map;
public class InterfaceType {
+ private String derived_from;
+ private String version;
+ private Map<String, String> metadata;
+ private String description;
+ private Map<String, PropertyDefinition> inputs;
+ private Map<String, OperationDefinition> operations;
+
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(
+ Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
+ }
+
+ public String getDerived_from() {
+ return derived_from;
+ }
+
+ public void setDerived_from(String derived_from) {
+ this.derived_from = derived_from;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, OperationDefinition> getOperations() {
+ return operations;
+ }
+
+ public void setOperations(
+ Map<String, OperationDefinition> operations) {
+ this.operations = operations;
+ }
+
+ public void addOperation(String operationName, OperationDefinition operationDefinition) {
+ if(MapUtils.isEmpty(this.operations)){
+ this.operations = new HashMap<>();
+ }
+ this.operations.put(operationName, operationDefinition);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof InterfaceType)) {
+ return false;
+ }
+
+ InterfaceType that = (InterfaceType) o;
+
+ if (getDerived_from() != null ? !getDerived_from().equals(that.getDerived_from())
+ : that.getDerived_from() != null) {
+ return false;
+ }
+ if (getVersion() != null ? !getVersion().equals(that.getVersion())
+ : that.getVersion() != null) {
+ return false;
+ }
+ if (getMetadata() != null ? !getMetadata().equals(that.getMetadata())
+ : that.getMetadata() != null) {
+ return false;
+ }
+ if (getDescription() != null ? !getDescription().equals(that.getDescription())
+ : that.getDescription() != null) {
+ return false;
+ }
+ if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) {
+ return false;
+ }
+ return getOperations() != null ? getOperations().equals(that.getOperations())
+ : that.getOperations() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getDerived_from() != null ? getDerived_from().hashCode() : 0;
+ result = 31 * result + (getVersion() != null ? getVersion().hashCode() : 0);
+ result = 31 * result + (getMetadata() != null ? getMetadata().hashCode() : 0);
+ result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
+ result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0);
+ result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0);
+ return result;
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java
index bfbf343e6d..01b1c6a959 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java
@@ -30,12 +30,13 @@ public class NodeTemplate implements Template {
private String type;
private String description;
+ private Map<String, String> metadata;
private List<String> directives;
private Map<String, Object> properties;
private Map<String, Object> attributes;
private List<Map<String, RequirementAssignment>> requirements;
private Map<String, CapabilityAssignment> capabilities;
- private Map<String, InterfaceDefinition> interfaces;
+ private Map<String, Object> interfaces;
private Map<String, ArtifactDefinition> artifacts;
private NodeFilter node_filter;
private String copy;
@@ -56,6 +57,14 @@ public class NodeTemplate implements Template {
this.description = description;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public List<String> getDirectives() {
return directives;
}
@@ -96,11 +105,11 @@ public class NodeTemplate implements Template {
this.capabilities = capabilities;
}
- public Map<String, InterfaceDefinition> getInterfaces() {
+ public Map<String, Object> getInterfaces() {
return interfaces;
}
- public void setInterfaces(Map<String, InterfaceDefinition> interfaces) {
+ public void setInterfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces;
}
@@ -131,8 +140,7 @@ public class NodeTemplate implements Template {
@Override
public NodeTemplate clone() {
YamlUtil yamlUtil = new YamlUtil();
- NodeTemplate clone = yamlUtil.yamlToObject(yamlUtil.objectToYaml(this), NodeTemplate.class);
- return clone;
+ return yamlUtil.yamlToObject(yamlUtil.objectToYaml(this), NodeTemplate.class);
}
@Override
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java
index f1eb5acc24..f12345e1f4 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java
@@ -27,6 +27,7 @@ public class NodeType {
private String derived_from;
private String version;
+ private Map<String, String> metadata;
private String description;
private Map<String, PropertyDefinition> properties;
private Map<String, AttributeDefinition> attributes;
@@ -52,6 +53,14 @@ public class NodeType {
this.version = version;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public String getDescription() {
return description;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java
new file mode 100644
index 0000000000..591e94ee1d
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/OperationDefinition.java
@@ -0,0 +1,65 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.util.Map;
+
+public class OperationDefinition {
+
+ private String description;
+ private String implementation;
+ private Map<String, PropertyDefinition> inputs;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getImplementation() {
+ return implementation;
+ }
+
+ public void setImplementation(String implementation) {
+ this.implementation = implementation;
+ }
+
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(
+ Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof OperationDefinition)) {
+ return false;
+ }
+
+ OperationDefinition that = (OperationDefinition) o;
+
+ if (getDescription() != null ? !getDescription().equals(that.getDescription())
+ : that.getDescription() != null) {
+ return false;
+ }
+ if (getImplementation() != null ? !getImplementation().equals(that.getImplementation())
+ : that.getImplementation() != null) {
+ return false;
+ }
+ return getInputs() != null ? getInputs().equals(that.getInputs()) : that.getInputs() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getDescription() != null ? getDescription().hashCode() : 0;
+ result = 31 * result + (getImplementation() != null ? getImplementation().hashCode() : 0);
+ result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0);
+ return result;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java
index 90f44ae36a..6907ea6480 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java
@@ -26,6 +26,7 @@ import java.util.Map;
public class PolicyDefinition implements Template {
private String type;
private String description;
+ private Map<String, String> metadata;
private Map<String, Object> properties;
private List<String> targets;
@@ -45,6 +46,14 @@ public class PolicyDefinition implements Template {
this.description = description;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public Map<String, Object> getProperties() {
return properties;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java
index 3c3b931e06..55a13d5a6c 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java
@@ -29,9 +29,11 @@ public class PolicyType {
private String derived_from;
private String version;
+ private Map<String, String> metadata;
private String description;
private Map<String, PropertyDefinition> properties;
private List<String> targets;
+ private List<Trigger> triggers;
public String getDerived_from() {
return derived_from;
@@ -72,4 +74,21 @@ public class PolicyType {
public void setTargets(List<String> targets) {
this.targets = targets;
}
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public List<Trigger> getTriggers() {
+ return triggers;
+ }
+
+ public void setTriggers(
+ List<Trigger> triggers) {
+ this.triggers = triggers;
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PreconditionDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PreconditionDefinition.java
new file mode 100644
index 0000000000..adbb335f6a
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PreconditionDefinition.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+public class PreconditionDefinition {
+
+ private String target;
+ private String target_relationship;
+ private Constraint condition;
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget_relationship() {
+ return target_relationship;
+ }
+
+ public void setTarget_relationship(String target_relationship) {
+ this.target_relationship = target_relationship;
+ }
+
+ public Constraint getCondition() {
+ return condition;
+ }
+
+ public void setCondition(Constraint condition) {
+ this.condition = condition;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java
index 5ba748dcee..d354807c2f 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java
@@ -28,11 +28,12 @@ public class RelationshipTemplate implements Template {
private String type;
private String description;
+ private Map<String, String> metadata;
private Map<String, Object> properties;
private Map<String, Object> attributes;
private Map<String, RequirementAssignment> requirements;
private Map<String, CapabilityAssignment> capabilities;
- private Map<String, InterfaceDefinition> interfaces;
+ private Map<String, Object> interfaces;
private String copy;
public String getType() {
@@ -51,6 +52,14 @@ public class RelationshipTemplate implements Template {
this.description = description;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public Map<String, Object> getProperties() {
return properties;
}
@@ -83,11 +92,11 @@ public class RelationshipTemplate implements Template {
this.capabilities = capabilities;
}
- public Map<String, InterfaceDefinition> getInterfaces() {
+ public Map<String, Object> getInterfaces() {
return interfaces;
}
- public void setInterfaces(Map<String, InterfaceDefinition> interfaces) {
+ public void setInterfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java
index 2d113775a1..463d3d2364 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java
@@ -27,6 +27,7 @@ public class RelationshipType {
private String derived_from;
private String version;
+ private Map<String, String> metadata;
private String description;
private Map<String, PropertyDefinition> properties;
private Map<String, AttributeDefinition> attributes;
@@ -51,6 +52,14 @@ public class RelationshipType {
this.version = version;
}
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
public String getDescription() {
return description;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Repository.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Repository.java
new file mode 100644
index 0000000000..3d3a5924d1
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Repository.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+public class Repository {
+
+ private String description;
+ private String url;
+ private Credential credential;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Credential getCredential() {
+ return credential;
+ }
+
+ public void setCredential(Credential credential) {
+ this.credential = credential;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java
index 297a2498bb..c02679d2af 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-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.
@@ -16,16 +16,20 @@
package org.openecomp.sdc.tosca.datatypes.model;
+import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.tosca.datatypes.model.heatextend.AnnotationType;
+
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
public class ServiceTemplate implements Template {
private String tosca_definitions_version;
private Map<String, String> metadata;
+ private Object dsl_definitions;
+ private Map<String, Repository> repositories;
private String description;
private List<Map<String, Import>> imports;
private Map<String, ArtifactType> artifact_types;
@@ -55,6 +59,23 @@ public class ServiceTemplate implements Template {
this.metadata = metadata;
}
+ public Object getDsl_definitions() {
+ return dsl_definitions;
+ }
+
+ public void setDsl_definitions(Object dsl_definitions) {
+ this.dsl_definitions = dsl_definitions;
+ }
+
+ public Map<String, Repository> getRepositories() {
+ return repositories;
+ }
+
+ public void setRepositories(
+ Map<String, Repository> repositories) {
+ this.repositories = repositories;
+ }
+
public String getDescription() {
return description;
}
@@ -128,6 +149,14 @@ public class ServiceTemplate implements Template {
this.interface_types = interface_types;
}
+ public void addInterfaceType(String interfaceKey, InterfaceType interfaceType) {
+ if (MapUtils.isEmpty(this.interface_types)) {
+ this.interface_types = new HashMap<>();
+ }
+
+ this.interface_types.put(interfaceKey, interfaceType);
+ }
+
public Map<String, PolicyType> getPolicy_types() {
return policy_types;
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/StepDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/StepDefinition.java
new file mode 100644
index 0000000000..7a5c7b7884
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/StepDefinition.java
@@ -0,0 +1,71 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.util.List;
+
+public class StepDefinition {
+
+ private String target;
+ private String target_relationship;
+ private String operation_host;
+ private List<Constraint> filter;
+ private List<ActivityDefinition> activities;
+ private String on_success;
+ private String on_failure;
+
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget_relationship() {
+ return target_relationship;
+ }
+
+ public void setTarget_relationship(String target_relationship) {
+ this.target_relationship = target_relationship;
+ }
+
+ public String getOperation_host() {
+ return operation_host;
+ }
+
+ public void setOperation_host(String operation_host) {
+ this.operation_host = operation_host;
+ }
+
+ public List<Constraint> getFilter() {
+ return filter;
+ }
+
+ public void setFilter(List<Constraint> filter) {
+ this.filter = filter;
+ }
+
+ public List<ActivityDefinition> getActivities() {
+ return activities;
+ }
+
+ public void setActivities(List<ActivityDefinition> activities) {
+ this.activities = activities;
+ }
+
+ public String getOn_success() {
+ return on_success;
+ }
+
+ public void setOn_success(String on_success) {
+ this.on_success = on_success;
+ }
+
+ public String getOn_failure() {
+ return on_failure;
+ }
+
+ public void setOn_failure(String on_failure) {
+ this.on_failure = on_failure;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TimeInterval.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TimeInterval.java
new file mode 100644
index 0000000000..efce557fd5
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TimeInterval.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.sql.Timestamp;
+
+public class TimeInterval {
+ private Timestamp start_time;
+ private Timestamp end_time;
+
+ public Timestamp getStart_time() {
+ return start_time;
+ }
+
+ public void setStart_time(Timestamp start_time) {
+ this.start_time = start_time;
+ }
+
+ public Timestamp getEnd_time() {
+ return end_time;
+ }
+
+ public void setEnd_time(Timestamp end_time) {
+ this.end_time = end_time;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java
index 88c76e59d4..fe1b2ea313 100644
--- a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.tosca.datatypes.model;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -34,6 +35,7 @@ public class TopologyTemplate {
private Map<String, ParameterDefinition> outputs;
private SubstitutionMapping substitution_mappings;
private Map<String, PolicyDefinition> policies;
+ private List<WorkflowDefinition> workflows;
public String getDescription() {
return description;
@@ -111,4 +113,12 @@ public class TopologyTemplate {
public void setPolicies(Map<String, PolicyDefinition> policies) {
this.policies = policies;
}
+
+ public List<WorkflowDefinition> getWorkflows() {
+ return workflows;
+ }
+
+ public void setWorkflows(List<WorkflowDefinition> workflows) {
+ this.workflows = workflows;
+ }
}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Trigger.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Trigger.java
new file mode 100644
index 0000000000..615630fa88
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Trigger.java
@@ -0,0 +1,99 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.sql.Time;
+
+public class Trigger {
+
+ private String description;
+ private String event_type;
+ private TimeInterval schedule;
+ private EventFilter target_filter;
+ private Constraint condition;
+ private Constraint constraint;
+ private String period;
+ private int evaluations;
+ private String method;
+ //action - String or operation?
+ private Object action;
+
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getEvent_type() {
+ return event_type;
+ }
+
+ public void setEvent_type(String event_type) {
+ this.event_type = event_type;
+ }
+
+ public TimeInterval getSchedule() {
+ return schedule;
+ }
+
+ public void setSchedule(TimeInterval schedule) {
+ this.schedule = schedule;
+ }
+
+ public EventFilter getTarget_filter() {
+ return target_filter;
+ }
+
+ public void setTarget_filter(EventFilter target_filter) {
+ this.target_filter = target_filter;
+ }
+
+ public Constraint getCondition() {
+ return condition;
+ }
+
+ public void setCondition(Constraint condition) {
+ this.condition = condition;
+ }
+
+ public Constraint getConstraint() {
+ return constraint;
+ }
+
+ public void setConstraint(Constraint constraint) {
+ this.constraint = constraint;
+ }
+
+ public String getPeriod() {
+ return period;
+ }
+
+ public void setPeriod(String period) {
+ this.period = period;
+ }
+
+ public int getEvaluations() {
+ return evaluations;
+ }
+
+ public void setEvaluations(int evaluations) {
+ this.evaluations = evaluations;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public Object getAction() {
+ return action;
+ }
+
+ public void setAction(Object action) {
+ this.action = action;
+ }
+}
diff --git a/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/WorkflowDefinition.java b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/WorkflowDefinition.java
new file mode 100644
index 0000000000..20f0863d2e
--- /dev/null
+++ b/common/openecomp-tosca-datatype/src/main/java/org/openecomp/sdc/tosca/datatypes/model/WorkflowDefinition.java
@@ -0,0 +1,55 @@
+package org.openecomp.sdc.tosca.datatypes.model;
+
+import java.util.List;
+import java.util.Map;
+
+public class WorkflowDefinition {
+ private String description;
+ private Map<String, String> metadata;
+ private Map<String, PropertyDefinition> inputs;
+ private List<PreconditionDefinition> preconditions;
+ private Map<String, StepDefinition> steps;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(
+ Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
+ }
+
+ public List<PreconditionDefinition> getPreconditions() {
+ return preconditions;
+ }
+
+ public void setPreconditions(
+ List<PreconditionDefinition> preconditions) {
+ this.preconditions = preconditions;
+ }
+
+ public Map<String, StepDefinition> getSteps() {
+ return steps;
+ }
+
+ public void setSteps(
+ Map<String, StepDefinition> steps) {
+ this.steps = steps;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index 25c89e1270..18750e4d0a 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.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,8 @@
package org.openecomp.sdc.common.utils;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -39,12 +41,16 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class CommonUtil {
+ private static final String DEFAULT = "default";
+ private static final String _DEFAULT = "_default";
private CommonUtil() {
// prevent instantiation
@@ -53,37 +59,37 @@ public class CommonUtil {
public static FileContentHandler validateAndUploadFileContent(OnboardingTypesEnum type,
byte[] uploadedFileData)
throws IOException {
- return getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(type, uploadedFileData);
+ return getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(type,
+ uploadedFileData);
}
/**
* Gets files out of the zip AND validates zip is flat (no folders)
*
- *
- * @param type
* @param uploadFileData zip file
* @return FileContentHandler if input is valid and has no folders
*/
private static FileContentHandler getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(
OnboardingTypesEnum type, byte[] uploadFileData)
throws IOException {
- Pair<FileContentHandler,List<String> > pair = getFileContentMapFromOrchestrationCandidateZip(uploadFileData);
+ Pair<FileContentHandler, List<String>> pair =
+ getFileContentMapFromOrchestrationCandidateZip(uploadFileData);
- if(isFileOriginFromZip(type.toString())) {
+ if (isFileOriginFromZip(type.toString())) {
validateNoFolders(pair.getRight());
}
return pair.getLeft();
}
- public static Pair<FileContentHandler,List<String> > getFileContentMapFromOrchestrationCandidateZip(
- byte[] uploadFileData)
- throws IOException {
+ public static Pair<FileContentHandler, List<String>> getFileContentMapFromOrchestrationCandidateZip(
+ byte[] uploadFileData)
+ throws IOException {
ZipEntry zipEntry;
List<String> folderList = new ArrayList<>();
FileContentHandler mapFileContent = new FileContentHandler();
- try ( ByteArrayInputStream in = new ByteArrayInputStream(uploadFileData);
- ZipInputStream inputZipStream = new ZipInputStream(in)){
+ try (ByteArrayInputStream in = new ByteArrayInputStream(uploadFileData);
+ ZipInputStream inputZipStream = new ZipInputStream(in)) {
byte[] fileByteContent;
String currentEntryName;
@@ -93,10 +99,10 @@ public class CommonUtil {
fileByteContent = FileUtils.toByteArray(inputZipStream);
int index = lastIndexFileSeparatorIndex(currentEntryName);
- if (index != -1) { //todo ?
+ if (index != -1) {
folderList.add(currentEntryName);
}
- if(isFile(currentEntryName)) {
+ if (isFile(currentEntryName)) {
mapFileContent.addFile(currentEntryName, fileByteContent);
}
}
@@ -105,7 +111,7 @@ public class CommonUtil {
throw new IOException(exception);
}
- return new ImmutablePair<>(mapFileContent,folderList);
+ return new ImmutablePair<>(mapFileContent, folderList);
}
private static boolean isFile(String currentEntryName) {
@@ -149,8 +155,41 @@ public class CommonUtil {
return validateFilesExtensions(allowedExtensions, files);
}
- public static boolean isFileOriginFromZip(String fileOrigin){
- return Objects.nonNull(fileOrigin)
+ public static boolean isFileOriginFromZip(String fileOrigin) {
+ return Objects.nonNull(fileOrigin)
&& fileOrigin.equalsIgnoreCase(OnboardingTypesEnum.ZIP.toString());
}
+
+ public static Set<String> getClassFieldNames(Class<? extends Object> classType) {
+ Set<String> fieldNames = new HashSet<>();
+ Arrays.stream(classType.getDeclaredFields()).forEach(field -> fieldNames.add(field.getName()));
+
+ return fieldNames;
+ }
+
+ public static <T> Optional<T> createObjectUsingSetters(Object objectCandidate,
+ Class<T> classToCreate)
+ throws Exception {
+ if (Objects.isNull(objectCandidate)) {
+ return Optional.empty();
+ }
+
+ Map<String, Object> objectAsMap = getObjectAsMap(objectCandidate);
+ T result = classToCreate.newInstance();
+ BeanUtils.populate(result, objectAsMap);
+
+ return Optional.of(result);
+ }
+
+ public static Map<String, Object> getObjectAsMap(Object obj) {
+ Map<String, Object> objectAsMap = obj instanceof Map ? (Map<String, Object>) obj
+ : new ObjectMapper().convertValue(obj, Map.class);
+
+ if (objectAsMap.containsKey(DEFAULT)) {
+ Object defaultValue = objectAsMap.get(DEFAULT);
+ objectAsMap.remove(DEFAULT);
+ objectAsMap.put(_DEFAULT, defaultValue);
+ }
+ return objectAsMap;
+ }
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
index f8b9f75b8f..e9a8f58426 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -436,36 +436,24 @@ public class ToscaConverterImpl implements ToscaConverter {
return CsarFileTypes.externalFile;
}
- private Optional<Manifest> getCsarManifest(Map<String, byte[]> csarFiles) throws IOException {
- Optional<byte[]> manifestContent = getManifestContent(csarFiles);
-
- if (manifestContent.isPresent()) {
- ByteArrayInputStream byteInputStream = new ByteArrayInputStream(manifestContent.get());
-
- return Optional.of(new Manifest(byteInputStream));
- }
-
- return Optional.empty();
- }
-
- private NodeTemplate convertNodeTemplate(Object candidateNodeTemplate) {
- NodeTemplate nodeTemplate = new NodeTemplate();
-
- Map<String, Object> nodeTemplateAsMap = (Map<String, Object>) candidateNodeTemplate;
- nodeTemplate.setArtifacts((Map<String, ArtifactDefinition>) nodeTemplateAsMap.get("artifacts"));
- nodeTemplate.setAttributes((Map<String, Object>) nodeTemplateAsMap.get("attributes"));
- nodeTemplate.setCopy((String) nodeTemplateAsMap.get("copy"));
- nodeTemplate.setDescription((String) nodeTemplateAsMap.get("description"));
- nodeTemplate.setDirectives((List<String>) nodeTemplateAsMap.get("directives"));
- nodeTemplate.setInterfaces(
- (Map<String, InterfaceDefinition>) nodeTemplateAsMap.get("interfaces"));
- nodeTemplate.setNode_filter((NodeFilter) nodeTemplateAsMap.get("node_filter"));
- nodeTemplate.setProperties((Map<String, Object>) nodeTemplateAsMap.get("properties"));
- nodeTemplate.setRequirements(
- (List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
- nodeTemplate.setType((String) nodeTemplateAsMap.get("type"));
- nodeTemplate.setCapabilities(
- convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
+ private NodeTemplate convertNodeTemplate(Object candidateNodeTemplate) {
+ NodeTemplate nodeTemplate = new NodeTemplate();
+
+ Map<String, Object> nodeTemplateAsMap = (Map<String, Object>) candidateNodeTemplate;
+ nodeTemplate.setArtifacts((Map<String, ArtifactDefinition>) nodeTemplateAsMap.get("artifacts"));
+ nodeTemplate.setAttributes((Map<String, Object>) nodeTemplateAsMap.get("attributes"));
+ nodeTemplate.setCopy((String) nodeTemplateAsMap.get("copy"));
+ nodeTemplate.setDescription((String) nodeTemplateAsMap.get("description"));
+ nodeTemplate.setDirectives((List<String>) nodeTemplateAsMap.get("directives"));
+ nodeTemplate.setInterfaces(
+ (Map<String, Object>) nodeTemplateAsMap.get("interfaces"));
+ nodeTemplate.setNode_filter((NodeFilter) nodeTemplateAsMap.get("node_filter"));
+ nodeTemplate.setProperties((Map<String, Object>) nodeTemplateAsMap.get("properties"));
+ nodeTemplate.setRequirements(
+ (List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
+ nodeTemplate.setType((String) nodeTemplateAsMap.get("type"));
+ nodeTemplate.setCapabilities(
+ convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
return nodeTemplate;
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
index 802827e343..2236622222 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
@@ -17,13 +17,12 @@
package org.openecomp.core.impl;
import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
import org.openecomp.core.converter.errors.CreateToscaObjectErrorBuilder;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
@@ -34,13 +33,10 @@ import java.util.stream.Stream;
public class ToscaConverterUtil {
- private static final String SET = "set";
private static final String DEFAULT = "default";
private static final String DEFAULT_CAPITAL = "Default";
private static final Set<String> DEFAULT_VALUE_KEYS;
- private static final Logger LOGGER = LoggerFactory.getLogger(ToscaConverterUtil.class);
-
static {
DEFAULT_VALUE_KEYS =
Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet());
@@ -50,11 +46,11 @@ public class ToscaConverterUtil {
// static utility methods only, prevent instantiation
}
- public static <T> Optional<T> createObjectFromClass(String objectId,
+ static <T> Optional<T> createObjectFromClass(String objectId,
Object objectCandidate,
Class<T> classToCreate) {
try {
- return createObjectUsingSetters(objectCandidate, classToCreate);
+ return CommonUtil.createObjectUsingSetters(objectCandidate, classToCreate);
} catch (Exception ex) {
throw new CoreException(
new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId)
@@ -62,45 +58,8 @@ public class ToscaConverterUtil {
}
}
- private static <T> Optional<T> createObjectUsingSetters(Object objectCandidate,
- Class<T> classToCreate)
- throws ReflectiveOperationException {
- if (Objects.isNull(objectCandidate)
- || !(objectCandidate instanceof Map)) {
- return Optional.empty();
- }
-
- Map<String, Object> objectAsMap = (Map<String, Object>) objectCandidate;
- Field[] classFields = classToCreate.getDeclaredFields();
- T result = classToCreate.newInstance();
-
- for (Field field : classFields) {
- Object fieldValueToAssign = objectAsMap.get(field.getName());
- String methodName = SET + StringUtils.capitalize(field.getName());
-
- if(shouldSetterMethodNeedsToGetInvoked(classToCreate, field, fieldValueToAssign, methodName)) {
- classToCreate.getMethod(methodName, field.getType()).invoke(result, fieldValueToAssign);
- }
- }
-
- return Optional.of(result);
- }
- private static <T> boolean shouldSetterMethodNeedsToGetInvoked(Class<T> classToCreate,
- Field field,
- Object fieldValueToAssign,
- String methodName) {
-
- try {
- return Objects.nonNull(fieldValueToAssign)
- && Objects.nonNull(classToCreate.getMethod(methodName, field.getType()));
- } catch (NoSuchMethodException e) {
- LOGGER.debug(String.format("Could not extract method '%s' from class '%s'. returning false " +
- "with filedType '%s'.", methodName, classToCreate, field.getType()), e);
- return false;
- }
- }
- public static Optional<Object> getDefaultValue(Object entryValue,
+ static Optional<Object> getDefaultValue(Object entryValue,
Object objectToAssignDefaultValue) {
if (!(entryValue instanceof Map)
|| Objects.isNull(objectToAssignDefaultValue)) {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceObjectErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceObjectErrorBuilder.java
new file mode 100644
index 0000000000..9eb2a4d5b2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceObjectErrorBuilder.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.tosca.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class CreateInterfaceObjectErrorBuilder {
+
+ private static final String COULD_NOT_CREATE_OBJECT_MSG =
+ "Could not create %s from %s. Reason - %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public CreateInterfaceObjectErrorBuilder(String interfaceClassName,
+ String interfaceId,
+ String reason) {
+ builder.withId(ToscaErrorCodes.INVALID_INTERFACE_VALUE);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(
+ String.format(COULD_NOT_CREATE_OBJECT_MSG, interfaceClassName, interfaceId, reason));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceOperationObjectErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceOperationObjectErrorBuilder.java
new file mode 100644
index 0000000000..83ead4fe66
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/CreateInterfaceOperationObjectErrorBuilder.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.tosca.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class CreateInterfaceOperationObjectErrorBuilder {
+ private static final String COULD_NOT_CREATE_OBJECT_MSG =
+ "Could not create Operation from %s. Reason - %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public CreateInterfaceOperationObjectErrorBuilder(String operationId,
+ String reason) {
+ builder.withId(ToscaErrorCodes.INVALID_INTERFACE_VALUE);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(
+ String.format(COULD_NOT_CREATE_OBJECT_MSG, operationId, reason));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java
index 099f0771f2..2e449e4acc 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.tosca.errors;
-public class ToscaErrorCodes {
+class ToscaErrorCodes {
static final String INVALID_SUBSTITUTE_NODE_TEMPLATE = "INVALID_SUBSTITUTE_NODE_TEMPLATE";
static final String INVALID_SUBSTITUTION_SERVICE_TEMPLATE =
@@ -31,6 +31,7 @@ public class ToscaErrorCodes {
static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE =
"TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE";
static final String TOSCA_INVALID_ADD_ACTION_NULL_ENTITY = "TOSCA_INVALID_ADD_ACTION_NULL_ENTITY";
+ static final String INVALID_INTERFACE_VALUE = "INVALID_INTERFACE_VALUE";
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidInterfaceValueErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidInterfaceValueErrorBuilder.java
new file mode 100644
index 0000000000..09b36a083c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidInterfaceValueErrorBuilder.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.tosca.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class ToscaInvalidInterfaceValueErrorBuilder {
+
+ private static final String INVALID_INTERFACE_MSG =
+ "Cannot create interface object. reason - %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public ToscaInvalidInterfaceValueErrorBuilder(String reason) {
+ builder.withId(ToscaErrorCodes.INVALID_INTERFACE_VALUE);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_INTERFACE_MSG, reason));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
index 8da2fc8c54..aef23be03f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
@@ -20,10 +20,13 @@
package org.openecomp.sdc.tosca.services;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
@@ -36,8 +39,11 @@ import org.openecomp.sdc.tosca.datatypes.model.Constraint;
import org.openecomp.sdc.tosca.datatypes.model.EntrySchema;
import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceType;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.OperationDefinition;
import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition;
import org.openecomp.sdc.tosca.datatypes.model.PolicyDefinition;
import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
@@ -49,8 +55,11 @@ import org.openecomp.sdc.tosca.datatypes.model.Status;
import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate;
import org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt;
+import org.openecomp.sdc.tosca.errors.CreateInterfaceObjectErrorBuilder;
+import org.openecomp.sdc.tosca.errors.CreateInterfaceOperationObjectErrorBuilder;
import org.openecomp.sdc.tosca.errors.InvalidAddActionNullEntityErrorBuilder;
import org.openecomp.sdc.tosca.errors.InvalidRequirementAssignmentErrorBuilder;
+import org.openecomp.sdc.tosca.errors.ToscaInvalidInterfaceValueErrorBuilder;
import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import java.io.ByteArrayInputStream;
@@ -67,6 +76,7 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
/**
* The type Data model util.
@@ -83,6 +93,7 @@ public class DataModelUtil {
private static final Logger logger = LoggerFactory.getLogger(DataModelUtil.class);
private static final String SERVICE_TEMPLATE = "Service Template";
private static final String NODE_TYPE = "Node Type";
+ private static final String OPERATIONS = "operations";
/**
* Add substitution mapping.
@@ -1162,6 +1173,150 @@ public class DataModelUtil {
return capabilityMapping;
}
+
+ public static void addInterfaceOperation(ServiceTemplate serviceTemplate,
+ String interfaceId,
+ String operationId,
+ OperationDefinition operationDefinition) {
+ Map<String, Object> interfaceTypes = serviceTemplate.getInterface_types();
+ if (MapUtils.isEmpty(interfaceTypes)
+ || Objects.isNull(interfaceTypes.get(interfaceId))) {
+ return;
+ }
+
+ Object interfaceObject = interfaceTypes.get(interfaceId);
+ Map<String, Object> interfaceAsMap = CommonUtil.getObjectAsMap(interfaceObject);
+ interfaceAsMap.put(operationId, operationDefinition);
+ }
+
+ public static Map<String, InterfaceType> getInterfaceTypes(ServiceTemplate serviceTemplate) {
+ Map<String, Object> interfaceTypes = serviceTemplate.getInterface_types();
+
+ if (MapUtils.isEmpty(interfaceTypes)) {
+ return new HashMap<>();
+ }
+
+ Map<String, InterfaceType> convertedInterfaceTypes = new HashMap<>();
+ for (Map.Entry<String, Object> interfaceEntry : interfaceTypes.entrySet()) {
+ try {
+ Optional<InterfaceType> interfaceType =
+ convertObjToInterfaceType(interfaceEntry.getKey(), interfaceEntry.getValue());
+ interfaceType.ifPresent(
+ interfaceValue -> convertedInterfaceTypes.put(interfaceEntry.getKey(), interfaceValue));
+ } catch (Exception e) {
+ throw new CoreException(
+ new ToscaInvalidInterfaceValueErrorBuilder(e.getMessage()).build());
+ }
+ }
+
+ return convertedInterfaceTypes;
+ }
+
+ public static Optional<InterfaceDefinition> convertObjToInterfaceDefinition(
+ String interfaceId, Object interfaceObj)
+ throws CoreException {
+
+ try {
+ Optional<InterfaceDefinition> interfaceDefinition =
+ CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceDefinition.class);
+ interfaceDefinition.ifPresent(interfaceDefinition1 -> updateInterfaceDefinitionOperations(
+ CommonUtil.getObjectAsMap(interfaceObj),
+ interfaceDefinition1));
+ return interfaceDefinition;
+ } catch (Exception ex) {
+ throw new CoreException(
+ new CreateInterfaceObjectErrorBuilder(InterfaceDefinition.class.getName(), interfaceId,
+ ex.getMessage()).build());
+ }
+
+ }
+
+ public static Optional<Object> convertInterfaceDefinitionToObj(
+ InterfaceDefinition interfaceDefinition) {
+ return converInetrfaceToToscaInterfaceObj(interfaceDefinition);
+ }
+
+ public static Optional<InterfaceType> convertObjToInterfaceType(String interfaceId,
+ Object interfaceObj)
+ throws CoreException {
+ try {
+ Optional<InterfaceType> interfaceType =
+ CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceType.class);
+ interfaceType.ifPresent(
+ interfaceType1 -> updateInterfaceTypeOperations(CommonUtil.getObjectAsMap(interfaceObj),
+ interfaceType1));
+ return interfaceType;
+ } catch (Exception ex) {
+ throw new CoreException(
+ new CreateInterfaceObjectErrorBuilder(InterfaceType.class.getName(), interfaceId,
+ ex.getMessage()).build());
+ }
+ }
+
+ public static Optional<Object> convertInterfaceTypeToObj(InterfaceType interfaceType) {
+ return converInetrfaceToToscaInterfaceObj(interfaceType);
+ }
+
+ private static Optional<Object> converInetrfaceToToscaInterfaceObj(Object interfaceEntity) {
+ if (Objects.isNull(interfaceEntity)) {
+ return Optional.empty();
+ }
+
+ Map<String, Object> interfaceAsMap = CommonUtil.getObjectAsMap(interfaceEntity);
+ Map<String, Object> operations = (Map<String, Object>) interfaceAsMap.get(OPERATIONS);
+ if (MapUtils.isNotEmpty(operations)) {
+ interfaceAsMap.remove(OPERATIONS);
+ interfaceAsMap.putAll(operations);
+ }
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
+ return Optional.of(objectMapper.convertValue(interfaceAsMap, Object.class));
+ }
+
+ private static void updateInterfaceTypeOperations(Map<String, Object> interfaceAsMap,
+ InterfaceType interfaceType) {
+
+ Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceType.class);
+
+ for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
+ Optional<OperationDefinition> operationDefinition =
+ createOperation(entry.getKey(), entry.getValue(), fieldNames);
+ operationDefinition
+ .ifPresent(operation -> interfaceType.addOperation(entry.getKey(), operation));
+ }
+ }
+
+ private static Optional<OperationDefinition> createOperation(String propertyName,
+ Object operationCandidate,
+ Set<String> fieldNames)
+ throws CoreException {
+ if (!fieldNames.contains(propertyName)) {
+ try {
+ return CommonUtil.createObjectUsingSetters(operationCandidate, OperationDefinition.class);
+ } catch (Exception ex) {
+ throw new CoreException(
+ new CreateInterfaceOperationObjectErrorBuilder(propertyName, ex.getMessage()).build());
+ }
+ }
+
+ return Optional.empty();
+ }
+
+ private static void updateInterfaceDefinitionOperations(Map<String, Object> interfaceAsMap,
+ InterfaceDefinition interfaceDefinition) {
+
+ Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinition.class);
+
+ for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
+ Optional<OperationDefinition> operationDefinition =
+ createOperation(entry.getKey(), entry.getValue(), fieldNames);
+ operationDefinition
+ .ifPresent(operation -> interfaceDefinition.addOperation(entry.getKey(), operation));
+
+ }
+ }
+
public static void addSubstitutionNodeTypeRequirements(NodeType substitutionNodeType,
List<Map<String, RequirementDefinition>>
requirementsList,
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
index 60f59dbd81..31dc3ab035 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
@@ -29,9 +29,12 @@ import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.tosca.datatypes.model.Constraint;
import org.openecomp.sdc.tosca.datatypes.model.Directive;
import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceType;
import org.openecomp.sdc.tosca.datatypes.model.NodeFilter;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.OperationDefinition;
import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition;
import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
@@ -52,13 +55,23 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public class ToscaModelTest {
+ private YamlUtil yamlUtil = new YamlUtil();
+ private static final String INTERFACE_ID = "inter_1";
+ private static final String NODE_TEMPLATE_ID = "firstNodeTemplate";
+ private static final String BASE_DIR = "/mock/model";
+ private static final String ST = "/serviceTemplate.yaml";
+ private static final String ST_WITH_INTERFACE = "/serviceTemplateWithInterface.yaml";
+ private static final String ST_WITH_OPERATIONS = "/serviceTemplateWithInterfaceAndOperation.yaml";
+ private static final String ST_WITH_INTERFACE_DEF =
+ "/serviceTemplateWithNodeTemplateInterface.yaml";
+
@Test
public void testServiceTemplateJavaToYaml() {
-
ServiceTemplate serviceTemplate = new ServiceTemplate();
Map<String, String> metadata = new HashMap<>();
metadata.put("Template_author", "OPENECOMP");
@@ -80,6 +93,14 @@ public class ToscaModelTest {
imports.add(importsMap);
serviceTemplate.setImports(imports);
+ OperationDefinition operationDefinition = new OperationDefinition();
+ operationDefinition.setDescription("test operation");
+ InterfaceType interfaceType = new InterfaceType();
+ interfaceType.setDerived_from("derived_from");
+ interfaceType.setDescription("desc");
+ interfaceType.addOperation("test", operationDefinition);
+ serviceTemplate.addInterfaceType("test_interface", interfaceType);
+
ArtifactType artifact = new ArtifactType();
artifact.setMime_type("application/java-archive");
ArrayList<String> ext = new ArrayList<>();
@@ -272,30 +293,163 @@ public class ToscaModelTest {
@Test
public void testYamlToServiceTemplateObj() throws IOException {
- try (InputStream yamlFile = new YamlUtil().loadYamlFileIs("/mock/model/serviceTemplate.yaml")) {
- ServiceTemplate serviceTemplateFromYaml =
- new YamlUtil().yamlToObject(yamlFile, ServiceTemplate.class);
- Assert.assertNotNull(serviceTemplateFromYaml);
- }
+ ServiceTemplate serviceTemplateFromYaml =
+ getServiceTemplate(BASE_DIR + ST);
+ Assert.assertNotNull(serviceTemplateFromYaml);
}
+ @Test
+ public void testYamlWithInterfaceToServiceTemplateObj() throws IOException {
+ ServiceTemplate serviceTemplateWithOperation =
+ getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
+ Assert.assertNotNull(serviceTemplateWithOperation);
+
+ InterfaceType expectedInterfaceType = getInterfaceType();
+
+ Map<String, InterfaceType> interfaceTypes =
+ DataModelUtil.getInterfaceTypes(serviceTemplateWithOperation);
+ Assert.assertEquals(1, interfaceTypes.size());
+ InterfaceType actualInterfaceType = interfaceTypes.get(INTERFACE_ID);
+ Assert.assertEquals(expectedInterfaceType, actualInterfaceType);
+ }
+
+ @Test
+ public void testAddOperationToInterface() throws IOException {
+ YamlUtil yamlUtil = new YamlUtil();
+ ServiceTemplate serviceTemplateWithInterface =
+ getServiceTemplate(BASE_DIR + ST_WITH_INTERFACE);
+ ServiceTemplate serviceTemplateWithOperation =
+ getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
+
+ OperationDefinition operationDefinition = getOperationDefinition();
+
+ DataModelUtil
+ .addInterfaceOperation(serviceTemplateWithInterface, INTERFACE_ID, "start",
+ operationDefinition);
+ String expectedServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithOperation);
+ String actualServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithInterface);
+ Assert.assertEquals(expectedServiceTemplate, actualServiceTemplate);
+ }
+
+ @Test
+ public void testInterfaceTypeToObjConversion() throws IOException {
+ ServiceTemplate serviceTemplateWithInterface =
+ getServiceTemplate(BASE_DIR + ST_WITH_INTERFACE);
+ ServiceTemplate serviceTemplateWithOperation =
+ getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
+ InterfaceType interfaceType = getInterfaceType();
+
+ Optional<Object> interfaceAsObj = DataModelUtil.convertInterfaceTypeToObj(interfaceType);
+ Assert.assertTrue(interfaceAsObj.isPresent());
+
+ Map<String, Object> interfaceTypes = new HashMap<>();
+ interfaceTypes.put(INTERFACE_ID, interfaceAsObj.get());
+ serviceTemplateWithInterface.setInterface_types(interfaceTypes);
+
+ String expectedServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithOperation);
+ String actualServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithInterface);
+ Assert.assertEquals(expectedServiceTemplate, actualServiceTemplate);
+ }
+
+ @Test
+ public void testObjToInterfaceTypeConversion() throws IOException, ReflectiveOperationException {
+ ServiceTemplate serviceTemplateWithOperation =
+ getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
+ Map<String, Object> interfaceTypes = serviceTemplateWithOperation.getInterface_types();
+ Object interfaceObj = interfaceTypes.get(INTERFACE_ID);
+ Optional<InterfaceType> actualInterfaceType =
+ DataModelUtil.convertObjToInterfaceType(INTERFACE_ID, interfaceObj);
+
+ Assert.assertTrue(actualInterfaceType.isPresent());
+ InterfaceType expectedInterfaceType = getInterfaceType();
+ Assert.assertEquals(expectedInterfaceType, actualInterfaceType.get());
+ }
+
+ @Test
+ public void testInterfaceDefinitionToObjConversion() throws IOException {
+ ServiceTemplate serviceTemplate =
+ getServiceTemplate(BASE_DIR + ST);
+ ServiceTemplate serviceTemplateWithInterfaceDef =
+ getServiceTemplate(BASE_DIR + ST_WITH_INTERFACE_DEF);
+
+ NodeTemplate nodeTemplate =
+ DataModelUtil.getNodeTemplate(serviceTemplate, NODE_TEMPLATE_ID);
+ InterfaceDefinition interfaceDefinition = getInterfaceDefinition();
+ Optional<Object> interfaceObj = DataModelUtil.convertInterfaceDefinitionToObj(interfaceDefinition);
+
+ Assert.assertTrue(interfaceObj.isPresent());
+ Map<String, Object> interfaces = new HashMap<>();
+ interfaces.put(INTERFACE_ID, interfaceObj.get());
+ nodeTemplate.setInterfaces(interfaces);
+
+ String expectedServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithInterfaceDef);
+ String actualServiceTemplate = yamlUtil.objectToYaml(serviceTemplate);
+ Assert.assertEquals(expectedServiceTemplate, actualServiceTemplate);
+ }
+
+ @Test
+ public void testObjToInterfaceDefinitionConversion()
+ throws IOException, ReflectiveOperationException {
+ ServiceTemplate serviceTemplateWithInterfaceDef =
+ getServiceTemplate(BASE_DIR + ST_WITH_INTERFACE_DEF);
+ NodeTemplate nodeTemplateWithInterface =
+ DataModelUtil.getNodeTemplate(serviceTemplateWithInterfaceDef, NODE_TEMPLATE_ID);
+ Map<String, Object> interfaces = nodeTemplateWithInterface.getInterfaces();
+ Object interfaceObj = interfaces.get(INTERFACE_ID);
+ Optional<InterfaceDefinition> actualInterfaceDefinition =
+ DataModelUtil.convertObjToInterfaceDefinition(INTERFACE_ID, interfaceObj);
+
+ Assert.assertTrue(actualInterfaceDefinition.isPresent());
+
+ InterfaceDefinition expectedInterfaceDefinition = getInterfaceDefinition();
+ Assert.assertEquals(expectedInterfaceDefinition, actualInterfaceDefinition.get());
+ }
@Test
public void testYamlToServiceTemplateIncludingHeatExtend() throws IOException {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
try (InputStream yamlFile =
- toscaExtensionYamlUtil.loadYamlFileIs("/mock/model/serviceTemplateHeatExtend.yaml")) {
+ toscaExtensionYamlUtil.loadYamlFileIs(BASE_DIR + "/serviceTemplateHeatExtend.yaml")) {
ServiceTemplate serviceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
ParameterDefinitionExt parameterDefinitionExt =
- (ParameterDefinitionExt) serviceTemplateFromYaml.getTopology_template().getInputs()
- .get("inParam1");
+ (ParameterDefinitionExt) serviceTemplateFromYaml.getTopology_template().getInputs()
+ .get("inParam1");
Assert.assertNotNull(parameterDefinitionExt.getLabel());
String backToYamlString = toscaExtensionYamlUtil.objectToYaml(serviceTemplateFromYaml);
Assert.assertNotNull(backToYamlString);
}
}
+ private ServiceTemplate getServiceTemplate(String inputPath) throws IOException {
+ try (InputStream yamlFile = yamlUtil.loadYamlFileIs(inputPath)) {
+ return yamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ }
+ }
+
+ private InterfaceType getInterfaceType() {
+ OperationDefinition operationDefinition = getOperationDefinition();
+ InterfaceType interfaceType = new InterfaceType();
+ interfaceType.setDescription("test interface");
+ interfaceType.addOperation("start", operationDefinition);
+ return interfaceType;
+ }
+
+ private OperationDefinition getOperationDefinition() {
+ OperationDefinition operationDefinition = new OperationDefinition();
+ operationDefinition.setDescription("start operation");
+ operationDefinition.setImplementation("start.sh");
+ return operationDefinition;
+ }
+
+ private InterfaceDefinition getInterfaceDefinition() {
+ OperationDefinition operationDefinition = getOperationDefinition();
+ InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ interfaceDefinition.setType("test interface");
+ interfaceDefinition.addOperation("start", operationDefinition);
+ return interfaceDefinition;
+ }
+
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml
index c49f30f97b..a2bc15ea19 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml
@@ -68,7 +68,7 @@ topology_template:
entry_schema:
type: tosca.myType
node_templates:
- firatNodeTemplate:
+ firstNodeTemplate:
type: nodeTypeRef
directives:
- selectable
@@ -98,16 +98,6 @@ topology_template:
capability: capA
node: nodeA
relationship: relationB
- capabilities:
- cap1:
- properties:
- num_cpus: '{ get_input: cpus }'
- attributes:
- num_cpus: '66'
- node_filter:
- properties:
- test1:
- - equal: 1 MB
substitution_mappings:
node_type: myNodeType.node
capabilities:
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml
new file mode 100644
index 0000000000..46d61079a2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml
@@ -0,0 +1,109 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+metadata:
+ template_name: Test
+ template_author: OPENECOMP
+ template_version: 1.0.0
+description: testing desc tosca service template
+imports:
+- myfile1:
+ file: path1/path2/file1.yaml
+- myfile2:
+ file: path1/path2/file2.yaml
+artifact_types:
+ one_artifact:
+ mime_type: application/java-archive
+ file_ext:
+ - yaml
+ - xml
+interface_types:
+ inter_1:
+ description: test interface
+node_types:
+ compute_node_type:
+ derived_from: tosca.nodes.Root
+ version: 1.0.0
+ description: tosca compute test
+ properties:
+ cpu_num:
+ type: integer
+ description: Number of CPUs requested for a software node instance
+ required: true
+ default: 1
+ status: SUPPORTED
+ constraints:
+ - greater_or_equal: 5.0
+ - equal: 5
+ - greater_than: 6.02
+ - in_range:
+ - 0
+ - UNBOUNDED
+ attributes:
+ attDef1:
+ type: string
+ default: hi
+ status: SUPPORTED
+ requirements:
+ - re1:
+ capability: tosca.cap1
+ occurrences:
+ - 5
+ - 1
+ capabilities:
+ cap1:
+ type: tosca.cap
+ valid_source_types:
+ - node1
+ - node2
+ occurrences:
+ - 1
+ - UNBOUNDED
+topology_template:
+ description: topologi template descroption
+ inputs:
+ inParam1:
+ type: string
+ description: desc
+ required: false
+ default: my default val
+ constraints:
+ - greater_than: 6
+ - greater_or_equal: 9
+ entry_schema:
+ type: tosca.myType
+ node_templates:
+ firstNodeTemplate:
+ type: nodeTypeRef
+ directives:
+ - selectable
+ - substitutable
+ properties:
+ prop2: '{ get_input: my_mysql_rootpw }'
+ prop1: abcd
+ attributes:
+ att2: '{ get_input: my_mysql_rootpw }'
+ att1: att1Val
+ requirements:
+ - req1:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ node_filter:
+ properties:
+ propName1:
+ - greater_or_equal: 9
+ propName2:
+ - min_length: 1
+ - max_length: 2
+ occurrences:
+ - 1
+ - 2
+ - req2:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ substitution_mappings:
+ node_type: myNodeType.node
+ capabilities:
+ database_endpoint:
+ - database
+ - database_endpoint
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml
new file mode 100644
index 0000000000..90376b7205
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml
@@ -0,0 +1,112 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+metadata:
+ template_name: Test
+ template_author: OPENECOMP
+ template_version: 1.0.0
+description: testing desc tosca service template
+imports:
+- myfile1:
+ file: path1/path2/file1.yaml
+- myfile2:
+ file: path1/path2/file2.yaml
+artifact_types:
+ one_artifact:
+ mime_type: application/java-archive
+ file_ext:
+ - yaml
+ - xml
+interface_types:
+ inter_1:
+ description: test interface
+ start:
+ description: start operation
+ implementation: start.sh
+node_types:
+ compute_node_type:
+ derived_from: tosca.nodes.Root
+ version: 1.0.0
+ description: tosca compute test
+ properties:
+ cpu_num:
+ type: integer
+ description: Number of CPUs requested for a software node instance
+ required: true
+ default: 1
+ status: SUPPORTED
+ constraints:
+ - greater_or_equal: 5.0
+ - equal: 5
+ - greater_than: 6.02
+ - in_range:
+ - 0
+ - UNBOUNDED
+ attributes:
+ attDef1:
+ type: string
+ default: hi
+ status: SUPPORTED
+ requirements:
+ - re1:
+ capability: tosca.cap1
+ occurrences:
+ - 5
+ - 1
+ capabilities:
+ cap1:
+ type: tosca.cap
+ valid_source_types:
+ - node1
+ - node2
+ occurrences:
+ - 1
+ - UNBOUNDED
+topology_template:
+ description: topologi template descroption
+ inputs:
+ inParam1:
+ type: string
+ description: desc
+ required: false
+ default: my default val
+ constraints:
+ - greater_than: 6
+ - greater_or_equal: 9
+ entry_schema:
+ type: tosca.myType
+ node_templates:
+ firstNodeTemplate:
+ type: nodeTypeRef
+ directives:
+ - selectable
+ - substitutable
+ properties:
+ prop2: '{ get_input: my_mysql_rootpw }'
+ prop1: abcd
+ attributes:
+ att2: '{ get_input: my_mysql_rootpw }'
+ att1: att1Val
+ requirements:
+ - req1:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ node_filter:
+ properties:
+ propName1:
+ - greater_or_equal: 9
+ propName2:
+ - min_length: 1
+ - max_length: 2
+ occurrences:
+ - 1
+ - 2
+ - req2:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ substitution_mappings:
+ node_type: myNodeType.node
+ capabilities:
+ database_endpoint:
+ - database
+ - database_endpoint
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml
new file mode 100644
index 0000000000..6df071c570
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml
@@ -0,0 +1,112 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+metadata:
+ template_name: Test
+ template_author: OPENECOMP
+ template_version: 1.0.0
+description: testing desc tosca service template
+imports:
+- myfile1:
+ file: path1/path2/file1.yaml
+- myfile2:
+ file: path1/path2/file2.yaml
+artifact_types:
+ one_artifact:
+ mime_type: application/java-archive
+ file_ext:
+ - yaml
+ - xml
+node_types:
+ compute_node_type:
+ derived_from: tosca.nodes.Root
+ version: 1.0.0
+ description: tosca compute test
+ properties:
+ cpu_num:
+ type: integer
+ description: Number of CPUs requested for a software node instance
+ required: true
+ default: 1
+ status: SUPPORTED
+ constraints:
+ - greater_or_equal: 5.0
+ - equal: 5
+ - greater_than: 6.02
+ - in_range:
+ - 0
+ - UNBOUNDED
+ attributes:
+ attDef1:
+ type: string
+ default: hi
+ status: SUPPORTED
+ requirements:
+ - re1:
+ capability: tosca.cap1
+ occurrences:
+ - 5
+ - 1
+ capabilities:
+ cap1:
+ type: tosca.cap
+ valid_source_types:
+ - node1
+ - node2
+ occurrences:
+ - 1
+ - UNBOUNDED
+topology_template:
+ description: topologi template descroption
+ inputs:
+ inParam1:
+ type: string
+ description: desc
+ required: false
+ default: my default val
+ constraints:
+ - greater_than: 6
+ - greater_or_equal: 9
+ entry_schema:
+ type: tosca.myType
+ node_templates:
+ firstNodeTemplate:
+ type: nodeTypeRef
+ directives:
+ - selectable
+ - substitutable
+ interfaces:
+ inter_1:
+ type: test interface
+ start:
+ description: start operation
+ implementation: start.sh
+ properties:
+ prop2: '{ get_input: my_mysql_rootpw }'
+ prop1: abcd
+ attributes:
+ att2: '{ get_input: my_mysql_rootpw }'
+ att1: att1Val
+ requirements:
+ - req1:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ node_filter:
+ properties:
+ propName1:
+ - greater_or_equal: 9
+ propName2:
+ - min_length: 1
+ - max_length: 2
+ occurrences:
+ - 1
+ - 2
+ - req2:
+ capability: capA
+ node: nodeA
+ relationship: relationB
+ substitution_mappings:
+ node_type: myNodeType.node
+ capabilities:
+ database_endpoint:
+ - database
+ - database_endpoint