summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/core/pom.xml141
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt342
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt86
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt78
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt93
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt94
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt374
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt28
-rw-r--r--components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory17
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt49
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt15
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt35
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt52
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt72
-rw-r--r--components/core/src/test/resources/dictionary/dictionary_schema.json4
-rw-r--r--components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts44
-rwxr-xr-xcomponents/core/src/test/resources/templates/base-config-data.json36
-rwxr-xr-xcomponents/core/src/test/resources/templates/base-config-template.vtl61
-rw-r--r--components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json82
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json12
-rw-r--r--components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json8
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json3
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json5
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/nf-role.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json4
-rw-r--r--[-rwxr-xr-x]components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json (renamed from components/model-catalog/resource-dictionary/starter-dictionary/db-source.json)6
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json4
-rw-r--r--components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json (renamed from components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json)6
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vm-type.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json4
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json4
-rw-r--r--components/parent/pom.xml58
-rw-r--r--components/pom.xml2
-rw-r--r--components/resource-dict/load/model_type/node_type/source-primary-db.json (renamed from components/resource-dict/load/model_type/node_type/source-db.json)0
-rw-r--r--components/resource-dict/load/resource_dictionary/nf-role.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/nfc-naming-code.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/primary-db-source.json (renamed from components/resource-dict/load/resource_dictionary/db-source.json)6
-rw-r--r--components/resource-dict/load/resource_dictionary/private-prefix-id.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/protected-prefix-id.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vf-module-label.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vf-module-type.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vf-naming-policy.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vf-nf-code.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vm-type.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json4
-rw-r--r--components/resource-dict/load/resource_dictionary/vnfc-model-version.json4
-rw-r--r--components/resource-dict/pom.xml2
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt2
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt156
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java12
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java6
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java6
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java2
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java2
-rw-r--r--components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt (renamed from components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt)2
-rw-r--r--components/resource-dict/src/test/resources/validation/cyclic.json2
-rw-r--r--components/resource-dict/src/test/resources/validation/duplicate.json2
-rw-r--r--components/resource-dict/src/test/resources/validation/success.json2
75 files changed, 1487 insertions, 650 deletions
diff --git a/components/core/pom.xml b/components/core/pom.xml
index 8b6c524d0..03d46f493 100644
--- a/components/core/pom.xml
+++ b/components/core/pom.xml
@@ -1,63 +1,78 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~ Modifications Copyright © 2018 IBM.
- ~
- ~ 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.
- -->
-
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.components</groupId>
- <artifactId>parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
- <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
- <artifactId>core</artifactId>
- <name>Controller Blueprints Core</name>
-
- <dependencies>
- <dependency>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-xml</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-yaml</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jsonSchema</artifactId>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~ Modifications Copyright © 2018 IBM.
+ ~
+ ~ 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.
+ -->
+
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ <name>Controller Blueprints Core</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-yaml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jsonSchema</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </dependency>
+ <!--Testing dependencies-->
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
+
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 102e2ebd3..4c2d6e2fc 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -1,172 +1,172 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.onap.ccsdk.apps.controllerblueprints.core
-
-/**
- * BluePrintConstants
- *
- * @author Brinda Santh
- */
-object BluePrintConstants {
-
- const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
- const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
- const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
- const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
-
- const val STATUS_SUCCESS: String = "success"
- const val STATUS_FAILURE: String = "failure"
-
- const val TYPE_DEFAULT: String = "default"
-
- const val DATA_TYPE_STRING: String = "string"
- const val DATA_TYPE_INTEGER: String = "integer"
- const val DATA_TYPE_FLOAT: String = "float"
- const val DATA_TYPE_BOOLEAN: String = "boolean"
- const val DATA_TYPE_TIMESTAMP: String = "timestamp"
- const val DATA_TYPE_NULL: String = "null"
- const val DATA_TYPE_LIST: String = "list"
- const val DATA_TYPE_MAP: String = "map"
-
- const val USER_SYSTEM: String = "System"
-
- const val PATH_DIVIDER: String = "/"
- const val PATH_SERVICE_TEMPLATE: String = "service_template"
- const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
- const val PATH_METADATA: String = "metadata"
- const val PATH_NODE_TYPES: String = "node_types"
- const val PATH_POLICY_TYPES: String = "policy_types"
- const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"
- const val PATH_ARTIFACT_TYPES: String = "artifact_types"
- const val PATH_DATA_TYPES: String = "data_types"
- const val PATH_INPUTS: String = "inputs"
- const val PATH_NODE_WORKFLOWS: String = "workflows"
- const val PATH_NODE_TEMPLATES: String = "node_templates"
- const val PATH_CAPABILITIES: String = "capabilities"
- const val PATH_REQUIREMENTS: String = "requirements"
- const val PATH_INTERFACES: String = "interfaces"
- const val PATH_OPERATIONS: String = "operations"
- const val PATH_OUTPUTS: String = "outputs"
- const val PATH_PROPERTIES: String = "properties"
- const val PATH_ATTRIBUTES: String = "attributes"
- const val PATH_ARTIFACTS: String = "artifacts"
-
- const val MODEL_DIR_MODEL_TYPE: String = "definition-type"
-
- const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
- const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
- const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
- const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"
- const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"
-
- const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"
- const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"
- const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"
- const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"
- const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"
- const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"
- const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"
-
- const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"
- const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"
- const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"
- const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
- const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
-
- const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
- const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
- const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
- @Deprecated("Artifacts will be attached to Node Template")
- const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
- const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
-
- const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
- const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
- const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
- const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
- const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"
- const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
-
- const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
-
- const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
-
- const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"
- const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"
- const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"
- const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"
- const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"
- const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"
- const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"
- // Custom capabilities
- const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"
- const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"
- const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"
- const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
- const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
-
- const val EXPRESSION_GET_INPUT: String = "get_input"
- const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
- const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
- const val EXPRESSION_GET_PROPERTY: String = "get_property"
- const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"
- const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"
-
- const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"
- const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"
- const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"
- const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"
- const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"
- const val PROPERTY_BLUEPRINT_NAME: String = "template_name"
- const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"
-
- const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata"
- const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"
- const val TOSCA_DEFINITIONS_DIR: String = "Definitions"
- const val TOSCA_PLANS_DIR: String = "Plans"
- const val TOSCA_SCRIPTS_DIR: String = "Scripts"
- const val TOSCA_MAPPINGS_DIR: String = "Mappings"
- const val TOSCA_TEMPLATES_DIR: String = "Templates"
-
- const val METADATA_USER_GROUPS = "user-groups"
- const val METADATA_TEMPLATE_NAME = "template_name"
- const val METADATA_TEMPLATE_VERSION = "template_version"
- const val METADATA_TEMPLATE_AUTHOR = "template_author"
- const val METADATA_TEMPLATE_TAGS = "template_tags"
- const val METADATA_WORKFLOW_NAME = "workflow_name"
-
- const val PAYLOAD_DATA = "payload-data"
- const val PROPERTY_CURRENT_STEP = "current-step"
- const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
- const val PROPERTY_CURRENT_INTERFACE = "current-interface"
- const val PROPERTY_CURRENT_OPERATION = "current-operation"
- const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
- const val PROPERTY_EXECUTION_REQUEST = "execution-request"
-
- const val OPERATION_PROCESS = "process"
- const val OPERATION_PREPARE = "prepare"
-
- const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
- const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
- const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
-
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core
+
+/**
+ * BluePrintConstants
+ *
+ * @author Brinda Santh
+ */
+object BluePrintConstants {
+
+ const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
+ const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
+ const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
+ const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
+
+ const val STATUS_SUCCESS: String = "success"
+ const val STATUS_FAILURE: String = "failure"
+
+ const val TYPE_DEFAULT: String = "default"
+
+ const val DATA_TYPE_STRING: String = "string"
+ const val DATA_TYPE_INTEGER: String = "integer"
+ const val DATA_TYPE_FLOAT: String = "float"
+ const val DATA_TYPE_BOOLEAN: String = "boolean"
+ const val DATA_TYPE_TIMESTAMP: String = "timestamp"
+ const val DATA_TYPE_NULL: String = "null"
+ const val DATA_TYPE_LIST: String = "list"
+ const val DATA_TYPE_MAP: String = "map"
+
+ const val USER_SYSTEM: String = "System"
+
+ const val PATH_DIVIDER: String = "/"
+ const val PATH_SERVICE_TEMPLATE: String = "service_template"
+ const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
+ const val PATH_METADATA: String = "metadata"
+ const val PATH_NODE_TYPES: String = "node_types"
+ const val PATH_POLICY_TYPES: String = "policy_types"
+ const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"
+ const val PATH_ARTIFACT_TYPES: String = "artifact_types"
+ const val PATH_DATA_TYPES: String = "data_types"
+ const val PATH_INPUTS: String = "inputs"
+ const val PATH_NODE_WORKFLOWS: String = "workflows"
+ const val PATH_NODE_TEMPLATES: String = "node_templates"
+ const val PATH_CAPABILITIES: String = "capabilities"
+ const val PATH_REQUIREMENTS: String = "requirements"
+ const val PATH_INTERFACES: String = "interfaces"
+ const val PATH_OPERATIONS: String = "operations"
+ const val PATH_OUTPUTS: String = "outputs"
+ const val PATH_PROPERTIES: String = "properties"
+ const val PATH_ATTRIBUTES: String = "attributes"
+ const val PATH_ARTIFACTS: String = "artifacts"
+
+ const val MODEL_DIR_MODEL_TYPE: String = "definition-type"
+
+ const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
+ const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
+ const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
+ const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"
+ const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"
+
+ const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"
+ const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"
+ const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"
+ const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"
+ const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"
+ const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"
+ const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"
+
+ const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"
+ const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"
+ const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"
+ const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
+ const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
+
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
+ @Deprecated("Artifacts will be attached to Node Template")
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
+
+ const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
+ const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
+ const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
+ const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
+ const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"
+ const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
+
+ const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
+
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
+
+ const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"
+ const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"
+ const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"
+ const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"
+ const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"
+ // Custom capabilities
+ const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"
+ const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
+
+ const val EXPRESSION_GET_INPUT: String = "get_input"
+ const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
+ const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
+ const val EXPRESSION_GET_PROPERTY: String = "get_property"
+ const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"
+ const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"
+
+ const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"
+ const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"
+ const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"
+ const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"
+ const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"
+ const val PROPERTY_BLUEPRINT_NAME: String = "template_name"
+ const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"
+
+ const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata"
+ const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"
+ const val TOSCA_DEFINITIONS_DIR: String = "Definitions"
+ const val TOSCA_PLANS_DIR: String = "Plans"
+ const val TOSCA_SCRIPTS_DIR: String = "Scripts"
+ const val TOSCA_MAPPINGS_DIR: String = "Mappings"
+ const val TOSCA_TEMPLATES_DIR: String = "Templates"
+
+ const val METADATA_USER_GROUPS = "user-groups"
+ const val METADATA_TEMPLATE_NAME = "template_name"
+ const val METADATA_TEMPLATE_VERSION = "template_version"
+ const val METADATA_TEMPLATE_AUTHOR = "template_author"
+ const val METADATA_TEMPLATE_TAGS = "template_tags"
+ const val METADATA_WORKFLOW_NAME = "workflow_name"
+
+ const val PAYLOAD_DATA = "payload-data"
+ const val PROPERTY_CURRENT_STEP = "current-step"
+ const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
+ const val PROPERTY_CURRENT_INTERFACE = "current-interface"
+ const val PROPERTY_CURRENT_OPERATION = "current-operation"
+ const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
+ const val PROPERTY_EXECUTION_REQUEST = "execution-request"
+
+ const val OPERATION_PROCESS = "process"
+ const val OPERATION_PREPARE = "prepare"
+
+ const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
+ const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
+ const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
+
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index 9767b2e17..663c1fe6c 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -502,7 +502,7 @@ class InterfaceAssignment {
A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations.
*/
-class NodeTemplate {
+open class NodeTemplate {
@get:JsonIgnore
var id: String? = null
var description: String? = null
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt
new file mode 100644
index 000000000..f7bfb857c
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.script
+
+import org.jetbrains.kotlin.script.util.LocalFilesResolver
+import java.io.File
+import kotlin.script.dependencies.ScriptContents
+import kotlin.script.dependencies.ScriptDependenciesResolver
+import kotlin.script.experimental.annotations.KotlinScript
+import kotlin.script.experimental.api.*
+import kotlin.script.experimental.jvm.JvmDependency
+import kotlin.script.experimental.jvm.dependenciesFromCurrentContext
+import kotlin.script.experimental.jvm.jvm
+
+
+@KotlinScript(fileExtension = "kts",
+ compilationConfiguration = ComponentScriptConfiguration::class)
+abstract class ComponentScript {
+
+}
+
+object ComponentScriptConfiguration : ScriptCompilationConfiguration(
+ {
+ // defaultImports(DependsOn::class, Repository::class)
+ jvm {
+ dependenciesFromCurrentContext(
+ wholeClasspath = true
+ )
+ }
+// refineConfiguration {
+// onAnnotations(DependsOn::class, Repository::class, handler = ::configureLocalFileDepsOnAnnotations)
+// }
+ }
+)
+
+
+private val resolver = LocalFilesResolver()
+
+fun configureLocalFileDepsOnAnnotations(context: ScriptConfigurationRefinementContext):
+ ResultWithDiagnostics<ScriptCompilationConfiguration> {
+
+ val annotations = context.collectedData?.get(ScriptCollectedData.foundAnnotations)?.takeIf { it.isNotEmpty() }
+ ?: return context.compilationConfiguration.asSuccess()
+
+ val scriptContents = object : ScriptContents {
+ override val annotations: Iterable<Annotation> = annotations
+ override val file: File? = null
+ override val text: CharSequence? = null
+ }
+
+ val diagnostics = arrayListOf<ScriptDiagnostic>()
+
+ fun report(severity: ScriptDependenciesResolver.ReportSeverity, message: String, position: ScriptContents.Position?) {
+ //TODO
+ }
+
+ return try {
+ val newDepsFromResolver = resolver.resolve(scriptContents, emptyMap(), ::report, null).get()
+ ?: return context.compilationConfiguration.asSuccess(diagnostics)
+
+ val resolvedClasspath = newDepsFromResolver.classpath.toList().takeIf { it.isNotEmpty() }
+ ?: return context.compilationConfiguration.asSuccess(diagnostics)
+
+ ScriptCompilationConfiguration(context.compilationConfiguration) {
+ dependencies.append(JvmDependency(resolvedClasspath))
+
+ }.asSuccess(diagnostics)
+
+ } catch (e: Throwable) {
+ ResultWithDiagnostics.Failure(*diagnostics.toTypedArray(), e.asDiagnostics())
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt
new file mode 100644
index 000000000..8ae091511
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.script
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import java.io.File
+import java.io.InputStream
+import java.io.Reader
+import javax.script.ScriptEngineManager
+import kotlin.script.experimental.api.ResultValue
+import kotlin.script.experimental.api.ResultWithDiagnostics
+import kotlin.script.experimental.api.resultOrNull
+import kotlin.script.experimental.host.toScriptSource
+import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
+
+
+open class BluePrintScriptService(classLoader: ClassLoader? = Thread.currentThread().contextClassLoader) {
+
+ /**
+ * Get the Script Class instance
+ */
+ inline fun <reified T> scriptClassNewInstance(scriptFile: File, scriptClassName: String): T {
+
+ val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<ComponentScript>()
+
+ val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
+
+ val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptFile.toScriptSource(), compilationConfiguration,
+ null)
+
+ when (evalResponse) {
+ is ResultWithDiagnostics.Success -> {
+ val returnValue = evalResponse.resultOrNull()?.returnValue as ResultValue.Value
+ return returnValue.value.castOrError()
+ }
+ is ResultWithDiagnostics.Failure -> {
+ throw BluePrintProcessorException(evalResponse.reports.joinToString("\n"))
+ }
+ else -> {
+ throw BluePrintProcessorException("Failed to process script ${scriptFile.absolutePath}")
+ }
+ }
+
+ }
+
+ val engine = ScriptEngineManager(classLoader).getEngineByExtension("kts")
+
+ inline fun <R> safeEval(evaluation: () -> R?) = try {
+ evaluation()
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Cannot load script", e)
+ }
+
+ inline fun <reified T> Any?.castOrError() = takeIf { it is T }?.let { it as T }
+ ?: throw IllegalArgumentException("Cannot cast $this to expected type ${T::class}")
+
+ inline fun <reified T> load(script: String): T = safeEval { engine.eval(script) }.castOrError()
+
+ inline fun <reified T> load(reader: Reader): T = safeEval { engine.eval(reader) }.castOrError()
+
+ inline fun <reified T> load(inputStream: InputStream): T = load(inputStream.reader())
+
+ inline fun <reified T> loadAll(vararg inputStream: InputStream): List<T> = inputStream.map(::load)
+}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt
new file mode 100644
index 000000000..bda20a444
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.script
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.slf4j.LoggerFactory
+import kotlin.script.experimental.api.*
+import kotlin.script.experimental.host.BasicScriptingHost
+import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
+import kotlin.script.experimental.jvmhost.JvmScriptCompiler
+
+val defaultBlueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfiguration)
+
+open class BlueprintScriptingHost(evaluator: ScriptEvaluator
+) : BasicScriptingHost(defaultBlueprintScriptCompiler, evaluator) {
+
+ override fun eval(
+ script: SourceCode,
+ scriptCompilationConfiguration: ScriptCompilationConfiguration,
+ configuration: ScriptEvaluationConfiguration?
+ ): ResultWithDiagnostics<EvaluationResult> =
+
+ runInCoroutineContext {
+
+ compiler(script, scriptCompilationConfiguration)
+ .onSuccess {
+ evaluator(it, configuration)
+ }
+ }
+}
+
+
+open class BluePrintScriptEvaluator(private val scriptClassName: String) : ScriptEvaluator {
+
+ val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!!
+
+ override suspend operator fun invoke(
+ compiledScript: CompiledScript<*>,
+ scriptEvaluationConfiguration: ScriptEvaluationConfiguration?
+ ): ResultWithDiagnostics<EvaluationResult> =
+ try {
+ val res = compiledScript.getClass(scriptEvaluationConfiguration)
+ when (res) {
+ is ResultWithDiagnostics.Failure -> res
+ is ResultWithDiagnostics.Success -> {
+ val scriptClass = res.value
+ val args = ArrayList<Any?>()
+ scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach {
+ args.add(it.value)
+ }
+ scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let {
+ args.addAll(it)
+ }
+ scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let {
+ args.addAll(it)
+ }
+
+ val completeScriptClass = "Script\$$scriptClassName"
+ log.info("Searching for class type($completeScriptClass)")
+ /**
+ * Search for Class Name
+ */
+ val instanceClass = scriptClass.java.classes
+ .single { it.name == completeScriptClass }
+ //.single { it.name == "Script\$SampleBlueprintsFunctionNode" }
+
+
+ val instance = instanceClass.newInstance()
+ ?: throw BluePrintProcessorException("failed to create instance from the script")
+
+ ResultWithDiagnostics.Success(EvaluationResult(ResultValue.Value(completeScriptClass,
+ instance, instance.javaClass.typeName),
+ scriptEvaluationConfiguration))
+ }
+ }
+ } catch (e: Throwable) {
+ ResultWithDiagnostics.Failure(e.asDiagnostics("Error evaluating script"))
+ }
+} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
index bc1f4b437..1a6d096d8 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
@@ -148,7 +148,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates
fun nodeTemplateByName(name: String): NodeTemplate =
- nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name) ")
+ nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {
return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt
new file mode 100644
index 000000000..d175fddea
--- /dev/null
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.service
+
+import com.fasterxml.jackson.core.io.CharTypes
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.TextNode
+import org.apache.commons.lang3.BooleanUtils
+import org.apache.commons.lang3.StringUtils
+import org.apache.velocity.VelocityContext
+import org.apache.velocity.app.Velocity
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import java.io.StringWriter
+
+open class BluePrintTemplateService {
+
+ companion object {
+
+ /**
+ * Generate Content from Velocity Template and JSON Content.
+ */
+ fun generateContent(template: String, json: String,
+ ignoreJsonNull: Boolean = false,
+ additionalContext: MutableMap<String, Any> = hashMapOf()): String {
+ Velocity.init()
+ val mapper = ObjectMapper()
+ val nodeFactory = BluePrintJsonNodeFactory()
+ mapper.setNodeFactory(nodeFactory)
+
+ val jsonNode = mapper.readValue<JsonNode>(json, JsonNode::class.java)
+ ?: throw BluePrintProcessorException("couldn't get json node from json")
+
+ if (ignoreJsonNull)
+ JacksonUtils.removeJsonNullNode(jsonNode)
+
+ val velocityContext = VelocityContext()
+ velocityContext.put("StringUtils", StringUtils::class.java)
+ velocityContext.put("BooleanUtils", BooleanUtils::class.java)
+ /**
+ * Add the Custom Velocity Context API
+ */
+ additionalContext.forEach { name, value -> velocityContext.put(name, value) }
+ /**
+ * Add the JSON Data to the context
+ */
+ jsonNode.fields().forEach { entry ->
+ velocityContext.put(entry.key, entry.value)
+ }
+
+ val stringWriter = StringWriter()
+ Velocity.evaluate(velocityContext, stringWriter, "TemplateData", template)
+ stringWriter.flush()
+ return stringWriter.toString()
+ }
+ }
+}
+
+/**
+ * Customise JsonNodeFactory adn TextNode, Since it introduces quotes for string data.
+ */
+open class BluePrintJsonNodeFactory : JsonNodeFactory() {
+ override fun textNode(text: String): TextNode {
+ return BluePrintTextNode(text)
+ }
+}
+
+open class BluePrintTextNode(v: String) : TextNode(v) {
+ override fun toString(): String {
+ var len = this._value.length
+ len = len + 2 + (len shr 4)
+ val sb = StringBuilder(len)
+ CharTypes.appendQuoted(sb, this._value)
+ return sb.toString()
+ }
+
+}
+
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 01874455a..6321a8385 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.apps.controllerblueprints.core.utils
import com.att.eelf.configuration.EELFLogger
@@ -23,6 +22,9 @@ import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
@@ -40,241 +42,221 @@ import java.nio.charset.Charset
*
* @author Brinda Santh
*/
-object JacksonUtils {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- inline fun <reified T : Any> readValue(content: String): T =
- jacksonObjectMapper().readValue(content, T::class.java)
+class JacksonUtils {
+ companion object {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ inline fun <reified T : Any> readValue(content: String): T =
+ jacksonObjectMapper().readValue(content, T::class.java)
- @JvmStatic
- fun <T> readValue(content: String, valueType: Class<T>): T? {
- return jacksonObjectMapper().readValue(content, valueType)
- }
+ fun <T> readValue(content: String, valueType: Class<T>): T? {
+ return jacksonObjectMapper().readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
- return jacksonObjectMapper().treeToValue(node, valueType)
- }
+ fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
+ return jacksonObjectMapper().treeToValue(node, valueType)
+ }
- @JvmStatic
- fun getContent(fileName: String): String = runBlocking {
- async {
- try {
- File(fileName).readText(Charsets.UTF_8)
- } catch (e: Exception) {
- throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ fun removeJsonNullNode(node: JsonNode) {
+ val it = node.iterator()
+ while (it.hasNext()) {
+ val child = it.next()
+ if (child.isNull) {
+ it.remove()
+ } else {
+ removeJsonNullNode(child)
+ }
}
- }.await()
- }
+ }
- @JvmStatic
- fun getClassPathFileContent(fileName: String): String {
- return runBlocking {
- withContext(Dispatchers.Default) {
- IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
+ fun getContent(fileName: String): String = runBlocking {
+ async {
+ try {
+ File(fileName).readText(Charsets.UTF_8)
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ }
+ }.await()
+ }
+
+ fun getClassPathFileContent(fileName: String): String {
+ return runBlocking {
+ withContext(Dispatchers.Default) {
+ IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
}
}
- }
- @JvmStatic
- fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getContent(fileName)
- return readValue(content, valueType)
- }
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getContent(fileName)
+ return readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getClassPathFileContent(fileName)
- return readValue(content, valueType)
- }
+ fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getClassPathFileContent(fileName)
+ return readValue(content, valueType)
+ }
- @JvmStatic
- fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
+ return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ }
- @JvmStatic
- fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
- val content: String = getClassPathFileContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
+ val content: String = getClassPathFileContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNodeFromFile(fileName: String): JsonNode {
- val content: String = getContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNodeFromFile(fileName: String): JsonNode {
+ val content: String = getContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNode(content: String): JsonNode {
- return jacksonObjectMapper().readTree(content)
- }
+ fun jsonNode(content: String): JsonNode {
+ return jacksonObjectMapper().readTree(content)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any): String {
- return getJson(any, false)
- }
+ fun getJson(any: kotlin.Any): String {
+ return getJson(any, false)
+ }
- @JvmStatic
- fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
- val wrapperMap = hashMapOf<String, Any>()
- wrapperMap[wrapper] = any
- return getJson(wrapperMap, pretty)
- }
+ fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
+ val wrapperMap = hashMapOf<String, Any>()
+ wrapperMap[wrapper] = any
+ return getJson(wrapperMap, pretty)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
- val objectMapper = jacksonObjectMapper()
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
- if (pretty) {
- objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.writeValueAsString(any)
}
- return objectMapper.writeValueAsString(any)
- }
- @JvmStatic
- fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
- return getListFromJson(node.toString(), valueType)
- }
+ fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.valueToTree(any)
+ }
- @JvmStatic
- fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
- val objectMapper = jacksonObjectMapper()
- val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
- return objectMapper.readValue<List<T>>(content, javaType)
- }
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
- @JvmStatic
- fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
+ val objectMapper = jacksonObjectMapper()
+ val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
+ return objectMapper.readValue<List<T>>(content, javaType)
+ }
- @JvmStatic
- fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getClassPathFileContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
- val objectMapper = jacksonObjectMapper()
- val typeRef = object : TypeReference<MutableMap<String, T>>() {}
- return objectMapper.readValue(content, typeRef)
- }
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getClassPathFileContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
- val content: String = getContent(fileName)
- return getMapFromJson(content, valueType)
- }
+ fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
+ val objectMapper = jacksonObjectMapper()
+ val typeRef = object : TypeReference<MutableMap<String, T>>() {}
+ return objectMapper.readValue(content, typeRef)
+ }
- @JvmStatic
- fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
- } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
- return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = getContent(fileName)
+ return getMapFromJson(content, valueType)
}
- return false
- }
- @JvmStatic
- fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
- when (primitiveType) {
- BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
- BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
- BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
- else -> return false
+ fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
+ } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
+ return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ }
+ return false
}
- }
- @JvmStatic
- fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
- when (type) {
- BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
- BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
- else -> return false
+ fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
+ BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
+ BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
+ else -> return false
+ }
}
- }
-/*
- @JvmStatic
- fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.put(key, value as String)
- } else {
- objectNode.put(key, value as String)
+ fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
+ BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
+ else -> return false
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.add(value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.add(value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.add(value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.add(value as String)
- } else {
- objectNode.add(value as String)
+ fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)
+ else -> objectNode.put(key, value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, 0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, 0.0)
- } else {
- objectNode.put(key, "")
+ fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)
+ else -> arrayNode.add(value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- arrayNode.add(false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- arrayNode.add(0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- arrayNode.add(0.0)
- } else {
- arrayNode.add("")
+ fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)
+ else -> objectNode.put(key, "")
+ }
+ }
+
+ fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)
+ else -> arrayNode.add("")
+ }
}
- }
- @JvmStatic
- fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {
- if (nodeValue == null || nodeValue is NullNode) {
- objectNode.set(key, nodeValue)
- } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {
- objectNode.put(key, nodeValue.asBoolean())
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {
- objectNode.put(key, nodeValue.asInt())
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {
- objectNode.put(key, nodeValue.floatValue())
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {
- objectNode.put(key, nodeValue.asText())
+ fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {
+ if (nodeValue == null || nodeValue is NullNode) {
+ objectNode.set(key, nodeValue)
+ } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ populatePrimitiveValues(key, nodeValue, type, objectNode)
} else {
- objectNode.put(key, nodeValue.asText())
+ objectNode.set(key, nodeValue)
+ }
+ }
+
+ fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)
+ else -> return JacksonUtils.getJsonNode(value)
}
- } else {
- objectNode.set(key, nodeValue)
}
}
- */
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
index 1a138c3a6..f55449efa 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
@@ -19,7 +19,10 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
@@ -42,14 +45,35 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
// Step Validation Start
paths.add("steps")
- workflow.steps?.forEach { stepName, _ ->
+ workflow.steps?.forEach { stepName, step ->
paths.add(stepName)
paths.joinToString(BluePrintConstants.PATH_DIVIDER)
- // TODO("Step Validation")
+
+ // Validate target
+ step.target?.let {
+ try {
+ val nodeTemplate = bluePrintRuntimeService.bluePrintContext().nodeTemplateByName(it)
+
+ val nodeTypeDerivedFrom = bluePrintRuntimeService.bluePrintContext().nodeTemplateNodeType(it).derivedFrom
+
+ check(nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_DG) {
+ "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected is " +
+ "'${BluePrintConstants.MODEL_TYPE_NODE_DG}'"
+ }
+ } catch (e: Exception) {
+ bluePrintRuntimeService.getBluePrintError()
+ .addError("Failed to validate Workflow($workflowName)'s step($stepName)'s " +
+ "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
+ }
+ }
paths.removeAt(paths.lastIndex)
}
paths.removeAt(paths.lastIndex)
// Step Validation Ends
paths.removeAt(paths.lastIndex)
+
+ workflow.inputs?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!)
+ }
}
} \ No newline at end of file
diff --git a/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
new file mode 100644
index 000000000..89838f44f
--- /dev/null
+++ b/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
@@ -0,0 +1,17 @@
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# 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.
+#
+
+org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt
new file mode 100644
index 000000000..5c5ad3ba1
--- /dev/null
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.script
+
+import org.junit.Ignore
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import java.io.File
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+class BluePrintScriptServiceTest {
+
+ @Test
+ fun `invoke script`() {
+ val scriptContent = "11 + 11"
+ val value = BluePrintScriptService()
+ .load<Int>(scriptContent)
+ assertEquals(22, value, "failed to execute command")
+ }
+
+ @Test
+ @Ignore
+ fun `invoke script component node`() {
+
+ //println(classpathFromClasspathProperty()?.joinToString("\n"))
+
+ val scriptFile = File("src/test/resources/scripts/SampleBlueprintFunctionNode.kts")
+
+ val functionNode = BluePrintScriptService()
+ .scriptClassNewInstance<BlueprintFunctionNode<String, String>>(scriptFile,
+ "SampleBlueprintFunctionNode")
+ assertNotNull(functionNode, "failed to get instance from script")
+ }
+} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 1dfb89a5d..c01b14b31 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest {
val inputDataPath = "src/test/resources/data/default-context.json"
- val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)
+ val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)
bluePrintRuntimeService.assignInputs(inputNode)
val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")
@@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest {
"ResourceAssignmentComponent", "process")
assertNotNull(inContext, "Failed to populate interface input property values")
- assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
- assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
- }
+ assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
+ assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ }
@Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
@@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest {
val bluePrintRuntimeService = getBluePrintRuntimeService()
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
- jsonNodeFromObject("context1-value"))
+ JacksonUtils.jsonNodeFromObject("context1-value"))
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
- jsonNodeFromObject("context2-value"))
+ JacksonUtils.jsonNodeFromObject("context2-value"))
val keys = listOf("context1", "context2")
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt
new file mode 100644
index 000000000..663a3751a
--- /dev/null
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.service
+
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import kotlin.test.assertNotNull
+
+class BluePrintTemplateServiceTest {
+
+ @Test
+ fun testGenerateContent() {
+
+ val template = JacksonUtils.getClassPathFileContent("templates/base-config-template.vtl")
+ val json = JacksonUtils.getClassPathFileContent("templates/base-config-data.json")
+
+ val content = BluePrintTemplateService.generateContent(template, json)
+ assertNotNull(content, "failed to generate content for velocity template")
+
+ }
+} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
deleted file mode 100644
index ad55c7761..000000000
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.onap.ccsdk.apps.controllerblueprints.core.utils
-
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import kotlin.test.assertEquals
-import kotlin.test.assertNotNull
-
-@Deprecated("Reactor will be replacecd by coroutines by default.")
-class JacksonReactorUtilsTest {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- @Test
- fun testReadValues() {
-
- val serviceTemplate = JacksonReactorUtils.readValueFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json",
- ServiceTemplate::class.java).block()
-
- assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
- assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
-
- val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block()
- assertNotNull(jsonContent, "Failed to get json content")
-
- val jsonNode = JacksonReactorUtils.jsonNodeFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json")
- .block()
- assertNotNull(jsonContent, "Failed to get json Node")
- }
-
- @Test(expected = BluePrintException::class)
- fun testReadValuesFailure() {
- JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json")
- .block()
- }
-} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
index c98f2ac3c..344b0cca8 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
@@ -16,28 +16,86 @@
package org.onap.ccsdk.apps.controllerblueprints.core.validation
+import io.mockk.every
+import io.mockk.mockk
+import org.junit.Ignore
import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Step
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import kotlin.test.assertEquals
import kotlin.test.assertTrue
class BluePrintValidatorServiceImplTest {
- val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
-
+ private val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+ private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
fun testValidateOfType() {
- val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ assertTrue(valid, "failed in blueprint Validation")
+ }
+
+ @Test
+ fun testValidateWorkflowFailToFoundNodeTemplate() {
+ val workflowName = "resource-assignment"
- val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+ val step = Step()
+ step.target = "TestCaseFailNoNodeTemplate"
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
- val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0])
+ }
- val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ @Test
+ fun testValidateWorkflowFailNodeTemplateNotDgGeneric() {
+ val workflowName = "resource-assignment"
+ val nodeTemplateName = "resource-assignment-process"
- assertTrue(valid, "failed in blueprint Validation")
+ val nodeTemplate = mockk<NodeTemplate>()
+ every { nodeTemplate.type } returns "TestNodeType"
+ val nodeType = mockk<NodeType>()
+ every { nodeType.derivedFrom } returns "tosca.nodes.TEST"
+
+ val blueprintContext = mockk<BluePrintContext>()
+ every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate
+ every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType
+
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234")
+
+ every { bluePrintRuntime.getBluePrintError() } returns BluePrintError()
+ every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
+
+ val step = Step()
+ step.target = nodeTemplateName
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
+
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0])
}
+
+ @Test
+ fun testValidateWorkflowSuccess() {
+ val workflowName = "resource-assignment"
+ workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName))
+ }
+
}
diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json
index d03170050..f9ef9eeed 100644
--- a/components/core/src/test/resources/dictionary/dictionary_schema.json
+++ b/components/core/src/test/resources/dictionary/dictionary_schema.json
@@ -104,7 +104,7 @@
}
}
},
- "db": {
+ "primary-db": {
"type": "object",
"properties": {
"query": {
@@ -210,7 +210,7 @@
}
}
},
- "db": {
+ "primary-db": {
"type": "object",
"properties": {
"names": {
diff --git a/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts b/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts
new file mode 100644
index 000000000..44cc957d2
--- /dev/null
+++ b/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+
+open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String>{
+
+ override fun getName(): String {
+ return "Kotlin-Script-Function-Node"
+ }
+
+ override fun prepareRequest(executionRequest: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun prepareResponse(): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun apply(t: String): String {
+ return "$t-status"
+ }
+} \ No newline at end of file
diff --git a/components/core/src/test/resources/templates/base-config-data.json b/components/core/src/test/resources/templates/base-config-data.json
new file mode 100755
index 000000000..2acc6fcdd
--- /dev/null
+++ b/components/core/src/test/resources/templates/base-config-data.json
@@ -0,0 +1,36 @@
+{
+ "node0_hostname": "sdnc-host",
+ "node0_backup_router_address": "2001:1890:1253::192:168:100:1",
+ "servers": [
+ "Server1",
+ "Server2",
+ "Server3"
+ ],
+ "tacplus-servers": [
+ {
+ "tacplus-server-name": "tacplus-server-name1",
+ "tacplus-server-source-address": "enc-dsdsasa1"
+ },
+ {
+ "tacplus-server-name": "tacplus-server-name2",
+ "tacplus-server-source-address": "enc-dsdsasa2"
+ }
+ ],
+ "classes": [
+ {
+ "name": "superuser-class",
+ "idle-timeout": 5,
+ "permissions": "all"
+ },
+ {
+ "name": "tacacs-adv-class",
+ "idle-timeout": 5
+ },
+ {
+ "name": "tacacs-base-class",
+ "idle-timeout": 5
+ }
+ ],
+ "system-password": "teamops-system-password",
+ "root-password": "teamops-root-password"
+}
diff --git a/components/core/src/test/resources/templates/base-config-template.vtl b/components/core/src/test/resources/templates/base-config-template.vtl
new file mode 100755
index 000000000..f7b1269b3
--- /dev/null
+++ b/components/core/src/test/resources/templates/base-config-template.vtl
@@ -0,0 +1,61 @@
+<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"
+xmlns:a="http://xml.juniper.net/junos/15.1X49/junos">
+ <version>15.1X49-D50.3</version>
+ <groups>
+ <name>node0</name>
+ <system>
+ #foreach($server in ${servers})
+ <server-host-name>$StringUtils.upperCase("$server")</server-host-name>
+ #end
+ </system>
+ <system>
+ <host-name>${node0_hostname}</host-name>
+ <backup-router>
+ <address>${node0_backup_router_address}</address>
+ <destination>$node0_backup_router_address</destination>
+ </backup-router>
+ #foreach($tacplus-server in ${tacplus-servers})
+ <tacplus-server>
+ <name>$tacplus-server.tacplus-server-name</name>
+ <source-address>$tacplus-server.tacplus-server-source-address</source-address>
+ </tacplus-server>
+ #end
+ <login>
+ <message>ONAP information assets</message>
+ #foreach($class in ${classes})
+ <class>
+ <name>$class.name</name>
+ <idle-timeout>$class.idle-timeout</idle-timeout>
+ #if ($class.permissions)
+ <permissions>$class.permissions</permissions>
+ #end
+ </class>
+ #end
+ <user>
+ <name>readonly</name>
+ <full-name>Read Only Account Access</full-name>
+ <uid>1001</uid>
+ <class>tacacs-base-class</class>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Read - Write Account Access</full-name>
+ <uid>1002</uid>
+ <class>tacacs-adv-class</class>
+ <authentication>
+ <encrypted-password>${system-password}</encrypted-password>
+ </authentication>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Emergency Access Only</full-name>
+ <uid>1000</uid>
+ <class>superuser-class</class>
+ <authentication>
+ <encrypted-password>${root-password}</encrypted-password>
+ </authentication>
+ </user>
+ </login>
+ </system>
+ </groups>
+</configuration> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
index 1137c1d58..13847bbb4 100644
--- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
+++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json
@@ -411,7 +411,7 @@
},
"input-param": false,
"dictionary-name": "nf-role",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vnf-model-customization-uuid"
],
@@ -531,7 +531,7 @@
},
"input-param": false,
"dictionary-name": "protected-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -555,7 +555,7 @@
},
"input-param": false,
"dictionary-name": "unprotected-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -579,7 +579,7 @@
},
"input-param": false,
"dictionary-name": "vf-nf-code",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vnf-model-customization-uuid"
],
@@ -740,7 +740,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -788,7 +788,7 @@
},
"input-param": false,
"dictionary-name": "vfccustomizationuuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -836,7 +836,7 @@
},
"input-param": false,
"dictionary-name": "vm-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -860,7 +860,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-invariant-uuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -884,7 +884,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-version",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -933,7 +933,7 @@
},
"input-param": false,
"dictionary-name": "nfc-naming-code",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -1107,7 +1107,7 @@
},
"input-param": false,
"dictionary-name": "unprotected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1131,7 +1131,7 @@
},
"input-param": false,
"dictionary-name": "protected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1205,7 +1205,7 @@
},
"input-param": false,
"dictionary-name": "onap_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1302,7 +1302,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-label",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -1326,7 +1326,7 @@
},
"input-param": false,
"dictionary-name": "private-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1535,7 +1535,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -1583,7 +1583,7 @@
},
"input-param": false,
"dictionary-name": "vfccustomizationuuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -1631,7 +1631,7 @@
},
"input-param": false,
"dictionary-name": "vm-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1655,7 +1655,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-invariant-uuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -1679,7 +1679,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-version",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -1728,7 +1728,7 @@
},
"input-param": false,
"dictionary-name": "nfc-naming-code",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -1902,7 +1902,7 @@
},
"input-param": false,
"dictionary-name": "unprotected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -1926,7 +1926,7 @@
},
"input-param": false,
"dictionary-name": "onap_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2148,7 +2148,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-label",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -2172,7 +2172,7 @@
},
"input-param": false,
"dictionary-name": "private-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2357,7 +2357,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -2405,7 +2405,7 @@
},
"input-param": false,
"dictionary-name": "vfccustomizationuuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -2453,7 +2453,7 @@
},
"input-param": false,
"dictionary-name": "vm-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2477,7 +2477,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-invariant-uuid",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -2501,7 +2501,7 @@
},
"input-param": false,
"dictionary-name": "vnfc-model-version",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -2550,7 +2550,7 @@
},
"input-param": false,
"dictionary-name": "nfc-naming-code",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vfccustomizationuuid"
],
@@ -2725,7 +2725,7 @@
},
"input-param": false,
"dictionary-name": "unprotected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2749,7 +2749,7 @@
},
"input-param": false,
"dictionary-name": "protected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2773,7 +2773,7 @@
},
"input-param": false,
"dictionary-name": "onap_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -2946,7 +2946,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-label",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -2970,7 +2970,7 @@
},
"input-param": false,
"dictionary-name": "private-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -3018,7 +3018,7 @@
},
"input-param": false,
"dictionary-name": "protected-prefix-id",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -3082,7 +3082,7 @@
},
"input-param": false,
"dictionary-name": "vf-module-type",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vf-module-model-customization-uuid"
],
@@ -3226,7 +3226,7 @@
},
"input-param": false,
"dictionary-name": "nf-role",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"vnf-model-customization-uuid"
],
@@ -3275,7 +3275,7 @@
},
"input-param": false,
"dictionary-name": "unprotected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
@@ -3299,7 +3299,7 @@
},
"input-param": false,
"dictionary-name": "protected_private_net_cidr",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
],
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
index 7d850f200..6d771cd68 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
@@ -28,6 +28,14 @@
"required": true,
"type": "string"
},
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "vnf-id": {
+ "required": true,
+ "type": "string"
+ },
"action-name": {
"required": true,
"type": "string"
@@ -39,6 +47,10 @@
"hostname": {
"required": true,
"type": "string"
+ },
+ "vnf_name": {
+ "required": true,
+ "type": "string"
}
},
"derived_from": "tosca.datatypes.Dynamic"
diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json
new file mode 100644
index 000000000..cf19ac615
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json
@@ -0,0 +1,8 @@
+{
+ "description": "Kotlin Script file",
+ "version": "1.0.0",
+ "file_ext": [
+ "kts"
+ ],
+ "derived_from": "tosca.artifacts.Implementation"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
index 241b69953..e4eb90e7b 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
@@ -5,10 +5,11 @@
"type": {
"required": true,
"type": "string",
- "default": "JAVA-COMPONENT",
+ "default": "KOTLIN-COMPONENT",
"constraints": [
{
"valid_values": [
+ "KOTLIN-COMPONENT",
"JAVA-COMPONENT",
"JYTHON-COMPONENT"
]
diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json
new file mode 100644
index 000000000..381ed59e2
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json
@@ -0,0 +1,5 @@
+{
+ "description": "This is Kotlin Component",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json
index 819c7e602..6da5ea22f 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json
index b82791877..4e1ba2b0a 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json
index cee060153..42765ee94 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json
index de46524ce..26e62e85d 100755..100644
--- a/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json
@@ -1,5 +1,5 @@
{
- "name": "db-source",
+ "name": "primary-db-source",
"property" :{
"description": "name of the ",
"type": "string"
@@ -7,8 +7,8 @@
"updated-by": "brindasanth@onap.com",
"tags": "bundle-id, brindasanth@onap.com",
"sources": {
- "db": {
- "type": "source-db",
+ "primary-db": {
+ "type": "source-primary-db",
"properties": {
"query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
"input-key-mapping": {
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json
index 5dea3e316..0685401d3 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json
index fb572741c..f6120f3fd 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"protected\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json
index 261920feb..bb477dcb6 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"protected\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json
index 90775aee0..656841f2e 100644
--- a/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json
@@ -5,10 +5,10 @@
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "db-source, brindasanth@onap.com",
+ "tags": "primary-db-source, brindasanth@onap.com",
"sources": {
- "db": {
- "type": "source-db",
+ "primary-db": {
+ "type": "source-primary-db",
"properties": {
"query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
"input-key-mapping": {
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json
index 3cb732056..c1fc541bd 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"unprotected\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json
index d2a339e7c..604875500 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"unprotected\"",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json
index ac5e21a6a..faa7ea49e 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json
index 147425c33..dbd51bbd9 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json
index f68cc3746..70792f86f 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json
index 1865d47ff..a21982c0c 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json
index 463f8480b..9f3e7cf17 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json
index 0204c64bb..9744316c0 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select VFC_MODEL.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json
index c894fb531..3d89d9dd2 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select VFC_MODEL.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json
index 45eb07f79..d7fb50169 100755
--- a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select VFC_MODEL.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
index 1c49aed33..8ecb2c1a2 100644
--- a/components/parent/pom.xml
+++ b/components/parent/pom.xml
@@ -16,12 +16,13 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps</groupId>
<artifactId>components</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.4.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.ccsdk.apps.components</groupId>
<artifactId>parent</artifactId>
@@ -30,17 +31,17 @@
<properties>
<spring.boot.version>2.1.1.RELEASE</spring.boot.version>
<spring.version>5.1.3.RELEASE</spring.version>
- <kotlin.version>1.3.10</kotlin.version>
- <kotlin.maven.version>1.3.10</kotlin.maven.version>
- <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
- <grpc.version>1.16.1</grpc.version>
+ <kotlin.version>1.3.11</kotlin.version>
+ <kotlin.maven.version>1.3.11</kotlin.maven.version>
+ <kotlin.couroutines.version>1.1.0</kotlin.couroutines.version>
+ <grpc.version>1.17.1</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
- <guava.version>26.0-jre</guava.version>
+ <guava.version>27.0.1-jre</guava.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<h2database.version>1.4.197</h2database.version>
<onap.logger.slf4j>1.2.2</onap.logger.slf4j>
- <powermock.version>1.7.4</powermock.version>
+ <mockk.version>1.9</mockk.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -76,6 +77,7 @@
<version>${springfox.swagger2.version}</version>
</dependency>
+ <!-- Common Utils Dependencies -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -114,6 +116,26 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-scripting-jvm-host</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler-embeddable</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-runtime</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>${kotlin.couroutines.version}</version>
@@ -189,9 +211,9 @@
<!-- Testing Dependencies -->
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <version>${powermock.version}</version>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <version>${mockk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -201,6 +223,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <version>${kotlin.couroutines.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<version>${grpc.version}</version>
@@ -256,6 +284,10 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
@@ -270,6 +302,10 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-scripting-jvm-host</artifactId>
+ </dependency>
<!-- GRPC Dependencies -->
<dependency>
<groupId>io.grpc</groupId>
diff --git a/components/pom.xml b/components/pom.xml
index 6310c588e..5b8768cea 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.onap.ccsdk.apps</groupId>
<artifactId>ccsdk-apps</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.4.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>components</artifactId>
diff --git a/components/resource-dict/load/model_type/node_type/source-db.json b/components/resource-dict/load/model_type/node_type/source-primary-db.json
index 661a9503b..661a9503b 100644
--- a/components/resource-dict/load/model_type/node_type/source-db.json
+++ b/components/resource-dict/load/model_type/node_type/source-primary-db.json
diff --git a/components/resource-dict/load/resource_dictionary/nf-role.json b/components/resource-dict/load/resource_dictionary/nf-role.json
index 0e108c5cb..df6b5df4d 100644
--- a/components/resource-dict/load/resource_dictionary/nf-role.json
+++ b/components/resource-dict/load/resource_dictionary/nf-role.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid",
diff --git a/components/resource-dict/load/resource_dictionary/nfc-naming-code.json b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json
index f0f2b7f0f..7c521a7c0 100644
--- a/components/resource-dict/load/resource_dictionary/nfc-naming-code.json
+++ b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json
index 07c5cbc18..f2067a19c 100644
--- a/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json
+++ b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = private",
diff --git a/components/resource-dict/load/resource_dictionary/db-source.json b/components/resource-dict/load/resource_dictionary/primary-db-source.json
index b96dc63f7..dfac66aee 100644
--- a/components/resource-dict/load/resource_dictionary/db-source.json
+++ b/components/resource-dict/load/resource_dictionary/primary-db-source.json
@@ -1,5 +1,5 @@
{
- "name": "db-source",
+ "name": "primary-db-source",
"property" :{
"description": "name of the ",
"type": "string"
@@ -7,8 +7,8 @@
"updated-by": "brindasanth@onap.com",
"tags": "bundle-id, brindasanth@onap.com",
"sources": {
- "db": {
- "type": "source-db",
+ "primary-db": {
+ "type": "source-primary-db",
"properties": {
"query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
"input-key-mapping": {
diff --git a/components/resource-dict/load/resource_dictionary/private-prefix-id.json b/components/resource-dict/load/resource_dictionary/private-prefix-id.json
index a95bae308..309647d79 100644
--- a/components/resource-dict/load/resource_dictionary/private-prefix-id.json
+++ b/components/resource-dict/load/resource_dictionary/private-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = private",
diff --git a/components/resource-dict/load/resource_dictionary/protected-prefix-id.json b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json
index 56b0d6d21..816405b4e 100644
--- a/components/resource-dict/load/resource_dictionary/protected-prefix-id.json
+++ b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = protected",
diff --git a/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json
index db0a43dc5..bf46fb3a6 100644
--- a/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json
+++ b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = protected",
diff --git a/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json
index a0d966a2c..8a09b1498 100644
--- a/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json
+++ b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = unprotected",
diff --git a/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json
index 8f9385d87..241147c3f 100644
--- a/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json
+++ b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = unprotected",
diff --git a/components/resource-dict/load/resource_dictionary/vf-module-label.json b/components/resource-dict/load/resource_dictionary/vf-module-label.json
index a9543722c..01355c201 100644
--- a/components/resource-dict/load/resource_dictionary/vf-module-label.json
+++ b/components/resource-dict/load/resource_dictionary/vf-module-label.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid",
diff --git a/components/resource-dict/load/resource_dictionary/vf-module-type.json b/components/resource-dict/load/resource_dictionary/vf-module-type.json
index 805d834b5..ead69d46a 100644
--- a/components/resource-dict/load/resource_dictionary/vf-module-type.json
+++ b/components/resource-dict/load/resource_dictionary/vf-module-type.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid",
diff --git a/components/resource-dict/load/resource_dictionary/vf-naming-policy.json b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json
index ceed3186c..cde861f8a 100644
--- a/components/resource-dict/load/resource_dictionary/vf-naming-policy.json
+++ b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid",
diff --git a/components/resource-dict/load/resource_dictionary/vf-nf-code.json b/components/resource-dict/load/resource_dictionary/vf-nf-code.json
index 0d25d0e94..adbd22af8 100644
--- a/components/resource-dict/load/resource_dictionary/vf-nf-code.json
+++ b/components/resource-dict/load/resource_dictionary/vf-nf-code.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid",
diff --git a/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json
index a34a9a783..b3485791a 100644
--- a/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json
+++ b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid",
diff --git a/components/resource-dict/load/resource_dictionary/vm-type.json b/components/resource-dict/load/resource_dictionary/vm-type.json
index 7bb5ef1cc..e559f9b55 100644
--- a/components/resource-dict/load/resource_dictionary/vm-type.json
+++ b/components/resource-dict/load/resource_dictionary/vm-type.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select vfc_model.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json
index b2ccd45da..9eb94cffc 100644
--- a/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json
+++ b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select vfc_model.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-version.json b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json
index fb59eea7f..e4e662291 100644
--- a/components/resource-dict/load/resource_dictionary/vnfc-model-version.json
+++ b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json
@@ -7,8 +7,8 @@
"type" : "string"
},
"sources" : {
- "db" : {
- "type" : "source-db",
+ "primary-db" : {
+ "type" : "source-primary-db",
"properties" : {
"type" : "SQL",
"query" : "select vfc_model.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid",
diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml
index 0fd2cc504..a3602ac99 100644
--- a/components/resource-dict/pom.xml
+++ b/components/resource-dict/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.onap.ccsdk.apps.components</groupId>
<artifactId>parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <version>0.4.1-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
index a39139edc..e4219c139 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
@@ -23,7 +23,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict
object ResourceDictionaryConstants {
const val SOURCE_INPUT = "input"
const val SOURCE_DEFAULT = "default"
- const val SOURCE_DB = "db"
+ const val SOURCE_DB = "primary-db"
const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary"
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt
new file mode 100644
index 000000000..a234a89ee
--- /dev/null
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+
+import java.util.Date
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+
+class ResourceAssignmentUtils {
+ companion object {
+
+ private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) {
+
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
+ checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
+
+ if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+ resourceAssignment.dictionaryName = resourceAssignment.name
+ logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
+ }
+
+ try {
+ if (checkNotEmpty(resourceProp.type)) {
+ val convertedValue = convertResourceValue(resourceProp.type, value)
+ logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
+ resourceProp.value = convertedValue
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS
+ }
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Failed in setting value for template key (%s) and " +
+ "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e)
+ }
+ }
+
+ private fun convertResourceValue(type: String, value: Any?): JsonNode? {
+ var convertedValue: JsonNode?
+
+ if (value == null || value is NullNode) {
+ logger.info("Returning {} value from convertResourceValue", value)
+ return null
+ } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) {
+ convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value)
+ } else {
+ // Case where Resource is non-primitive type
+ if (value is String) {
+ convertedValue = JacksonUtils.jsonNode(value)
+ } else {
+ convertedValue = JacksonUtils.getJsonNode(value)
+ }
+ }
+ return convertedValue
+ }
+
+ @Synchronized
+ fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
+ if (checkNotEmpty(resourceAssignment.name)) {
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_FAILURE
+ resourceAssignment.message = message
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
+ if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) {
+ logger.error("failed to populate mandatory resource mapping ($resourceAssignment)")
+ throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)")
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
+ var result = "{}"
+ try {
+ val mapper = ObjectMapper()
+ val root = mapper.readTree(result)
+
+ assignments.forEach {
+ if (checkNotEmpty(it.name) && it.property != null) {
+
+ val type = it.property?.type
+ val value = it.property?.value
+ logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type,
+ value)
+ if (value == null) {
+ (root as ObjectNode).set(it.name, null)
+ } else if (value is JsonNode) {
+ (root as ObjectNode).put(it.name, value as JsonNode)
+ } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as String)
+ } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Boolean)
+ } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Int)
+ } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Float)
+ } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as String)
+ } else {
+ val jsonNode = JacksonUtils.getJsonNode(value)
+ if (jsonNode != null) {
+ (root as ObjectNode).put(it.name, jsonNode)
+ } else {
+ (root as ObjectNode).set(it.name, null)
+ }
+ }
+ }
+ }
+ result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
+ logger.info("Generated Resource Param Data ({})", result)
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("kapil is failing with $e.message", e)
+ }
+
+ return result
+ }
+
+ fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
+ val content = JacksonUtils.getJson(properties)
+ return JacksonUtils.readValue(content, classType)
+ ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
+ }
+
+ }
+} \ No newline at end of file
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
index fde800057..1ed306e21 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
@@ -31,7 +31,7 @@ public class ResourceDefinitionTest {
public void testDictionaryDefinitionInputSource(){
String fileName = basePath + "/input-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);
}
@@ -39,22 +39,22 @@ public class ResourceDefinitionTest {
public void testDictionaryDefinitionDefaultSource(){
String fileName = basePath + "/default-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionDBSource(){
- String fileName = basePath + "/db-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
+ String fileName = basePath + "/primary-db-source.json";
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionMDSALSource(){
String fileName = basePath + "/mdsal-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);
}
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java
index b67aa7998..3f5aef43d 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java
@@ -25,13 +25,13 @@ public class ResourceSourceMappingFactoryTest {
@Test
public void testRegisterResourceMapping() {
- ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db");
ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
- String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("db");
- Assert.notNull(nodeTypeName, "Failed to get db mapping");
+ String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db");
+ Assert.notNull(nodeTypeName, "Failed to get primary-db mapping");
ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping");
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
index 2b68585fa..7f040b2e2 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
@@ -30,10 +30,10 @@ public class ResourceDefinitionValidationServiceTest {
@Test
public void testValidateSource() throws Exception {
- String inputFileName = dictionaryPath + "/db-source.json";
+ String inputFileName = dictionaryPath + "/input-source.json";
testValidate(inputFileName);
- String dbFileName = dictionaryPath + "/db-source.json";
+ String dbFileName = dictionaryPath + "/primary-db-source.json";
testValidate(dbFileName);
String defaultFileName = dictionaryPath + "/default-source.json";
@@ -45,7 +45,7 @@ public class ResourceDefinitionValidationServiceTest {
private void testValidate(String fileName) throws Exception {
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition);
ResourceDefinitionValidationService resourceDictionaryValidationService =
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
index c7444dbae..a2c2310be 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
@@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest {
@Test
public void testProcess(){
- List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
+ List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);
BulkResourceSequencingUtils.process(assignments);
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
index 13bf8195e..fa2413805 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
@@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest {
@Test
public void testAssignInputs() {
- JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
+ JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
Map<String, Object> context = new HashMap<>();
ResourceDictionaryUtils.assignInputs(data, context);
String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt
index bebe27d8c..50e5c3290 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt
+++ b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt
@@ -22,7 +22,7 @@ object ResourceDictionaryTestUtils {
@JvmStatic
fun setUpResourceSourceMapping() {
- ResourceSourceMappingFactory.registerSourceMapping("db", "source-db")
+ ResourceSourceMappingFactory.registerSourceMapping("primary-db", "source-primary-db")
ResourceSourceMappingFactory.registerSourceMapping("input", "source-input")
ResourceSourceMappingFactory.registerSourceMapping("default", "source-default")
ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest")
diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json
index d837dc5d8..7e6472f5a 100644
--- a/components/resource-dict/src/test/resources/validation/cyclic.json
+++ b/components/resource-dict/src/test/resources/validation/cyclic.json
@@ -102,7 +102,7 @@
"type": "string"
},
"dictionary-name": "loopback-ip",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"bundle-mac",
"managed-ip1"
diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json
index 330324cda..28ab71fca 100644
--- a/components/resource-dict/src/test/resources/validation/duplicate.json
+++ b/components/resource-dict/src/test/resources/validation/duplicate.json
@@ -102,7 +102,7 @@
"type": "string"
},
"dictionary-name": "loopback-ip",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"bundle-mac"
]
diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json
index 3215d06d7..5d0e89805 100644
--- a/components/resource-dict/src/test/resources/validation/success.json
+++ b/components/resource-dict/src/test/resources/validation/success.json
@@ -102,7 +102,7 @@
"type": "string"
},
"dictionary-name": "loopback-ip",
- "dictionary-source": "db",
+ "dictionary-source": "primary-db",
"dependencies": [
"bundle-mac"
]