summaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model
diff options
context:
space:
mode:
Diffstat (limited to 'components/model-catalog/blueprint-model')
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/pom.xml45
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/META-INF/maven/archetype-metadata.xml61
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Definitions/test-kotlin.json85
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Scripts/kotlin/ConfigDeploy.kt49
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/TOSCA-Metadata/TOSCA.meta8
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ConfigDeployTest.kt88
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/pom.xml41
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/test/resources/projects/basic/archetype.properties4
-rw-r--r--components/model-catalog/blueprint-model/pom.xml1
9 files changed, 382 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/pom.xml b/components/model-catalog/blueprint-model/archetype-blueprint/pom.xml
new file mode 100644
index 000000000..a75c03f0a
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2021 Bell Canada
+ ~
+ ~ 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 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>
+
+ <groupId>org.onap.ccsdk.cds.components.cba</groupId>
+ <artifactId>archetype-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>Components Model Catalog - Blueprints Model - Archetype Blueprints</name>
+ <description>CDS Micro-services Archetype CBA</description>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>3.2.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>3.2.0</version>
+ </extension>
+ </extensions>
+ </build>
+</project>
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/META-INF/maven/archetype-metadata.xml b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 000000000..dd756775f
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2021 Bell Canada
+ ~
+ ~ 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.
+ -->
+<archetype-descriptor xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0 http://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd" name="archetype-blueprint"
+ xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet encoding="UTF-8">
+ <directory>Tests/kotlin</directory>
+ <includes>
+ <include>**/*.kt</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>Definitions</directory>
+ <includes>
+ <include>**/*.json</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>TOSCA-Metadata</directory>
+ <includes>
+ <include>**/*.meta</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>Scripts/kotlin</directory>
+ <includes>
+ <include>**/*.kt</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <requiredProperties>
+ <requiredProperty key="cdsUsername">
+ <defaultValue>ccsdkapps</defaultValue>
+ </requiredProperty>
+ <requiredProperty key="cdsPassword">
+ <defaultValue>ccsdkapps</defaultValue>
+ </requiredProperty>
+ <requiredProperty key="groupId">
+ <defaultValue>org.onap.ccsdk.cds.components.cba</defaultValue>
+ </requiredProperty>
+ <requiredProperty key="artifactId">
+ <defaultValue>test-cba</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+
+</archetype-descriptor> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Definitions/test-kotlin.json b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Definitions/test-kotlin.json
new file mode 100644
index 000000000..38b3e554f
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Definitions/test-kotlin.json
@@ -0,0 +1,85 @@
+{
+ "metadata": {
+ "template_author": "Selffish",
+ "author-email": "test@bell.ca",
+ "template_name": "RT-test-kotlin",
+ "template_version": "1.0.0",
+ "template_tags": "ONAP, CDS, CBA, test"
+ },
+ "topology_template": {
+ "workflows": {
+ "netconf-kotlin": {
+ "steps": {
+ "netconf-kotlin": {
+ "description": "deploy config",
+ "target": "execute-kotlin-netconf"
+ }
+ },
+ "inputs": {
+ "netconf-host": {
+ "required": true,
+ "type": "string"
+ },
+ "netconf-timeout": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "outputs": {
+ "response-data": {
+ "type": "string",
+ "value": {
+ "get_attribute": [
+ "execute-kotlin-netconf",
+ "response-data"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "node_templates": {
+ "execute-kotlin-netconf" : {
+ "type" : "component-netconf-executor",
+ "requirements" : {
+ "netconf-connection" : {
+ "capability" : "netconf",
+ "node" : "netconf-device",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "ComponentNetconfExecutor" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "script-type" : "kotlin",
+ "script-class-reference" : "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.ConfigDeploy",
+ "instance-dependencies" : [ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "netconf-device": {
+ "type": "vnf-netconf-device",
+ "capabilities": {
+ "netconf": {
+ "properties": {
+ "login-key": "password",
+ "login-account": "admin",
+ "target-ip-address": {
+ "get_input": "netconf-host"
+ },
+ "port-number" : 17830,
+ "connection-time-out" : {
+ "get_input": "netconf-timeout"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Scripts/kotlin/ConfigDeploy.kt b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Scripts/kotlin/ConfigDeploy.kt
new file mode 100644
index 000000000..f6a2bdc46
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Scripts/kotlin/ConfigDeploy.kt
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
+
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.slf4j.LoggerFactory
+
+open class ConfigDeploy : AbstractScriptComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!!
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ val netconfDevice = netconfDevice("netconf-connection")
+ val netconfRpcService = netconfDevice.netconfRpcService
+ val session = netconfDevice.netconfSession
+
+ val payload = storedContentFromResolvedArtifactNB("my-resolution-key", "create")
+
+ session.connect()
+ netconfRpcService.lock()
+ netconfRpcService.editConfig(payload)
+ netconfRpcService.commit()
+ netconfRpcService.unLock()
+ session.disconnect()
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Executing Recovery")
+ }
+}
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/TOSCA-Metadata/TOSCA.meta
new file mode 100644
index 000000000..19ca83bb1
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/TOSCA-Metadata/TOSCA.meta
@@ -0,0 +1,8 @@
+TOSCA-Meta-File-Version: 1.0.0
+CSAR-Version: 1.0
+Created-By: Selffish
+Entry-Definitions: Definitions/test-kotlin.json
+Template-Tags: test, regression
+Template-Name: RT-test-kotlin
+Template-Version: 1.0.0
+Template-Type: DEFAULT
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ConfigDeployTest.kt b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ConfigDeployTest.kt
new file mode 100644
index 000000000..f98514b56
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ConfigDeployTest.kt
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
+
+import io.mockk.coEvery
+import io.mockk.coVerify
+import io.mockk.every
+import io.mockk.mockk
+import io.mockk.mockkStatic
+import io.mockk.verifySequence
+import kotlinx.coroutines.runBlocking
+import org.junit.Before
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfSession
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core.NetconfRpcServiceImpl
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
+
+class ConfigDeployTest {
+
+ private lateinit var unitUnderTest: ConfigDeploy
+ private lateinit var netconfSession: NetconfSession
+ private lateinit var netconfRpcService: NetconfRpcServiceImpl
+
+ private val payload = """
+ <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos">
+ <system xmlns="http://yang.juniper.net/junos-qfx/conf/system">
+ <host-name operation="create">Test-Script</host-name>
+ </system>
+ </configuration>
+ """.trimIndent()
+
+ @Before
+ fun setup() {
+ // This will stub the extension functions
+ mockkStatic("org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionExtensionsKt")
+ mockkStatic("org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.NetconfExecutorExtensionsKt")
+
+ unitUnderTest = ConfigDeploy()
+
+ // Mock return values
+ coEvery {
+ unitUnderTest.storedContentFromResolvedArtifactNB("my-resolution-key", "create")
+ }.returns(payload)
+
+ mockk<NetconfDevice>().let {
+ netconfSession = mockk(relaxed = true)
+ netconfRpcService = mockk(relaxed = true)
+ every { it.netconfSession }.returns(netconfSession)
+ every { it.netconfRpcService }.returns(netconfRpcService)
+ every { unitUnderTest.netconfDevice("netconf-connection") }.returns(it)
+ }
+ }
+
+ @Test
+ fun `should retrieve stored payload then connect and send to device`() {
+ runBlocking { unitUnderTest.processNB(ExecutionServiceInput()) }
+
+ coVerify {
+ unitUnderTest.storedContentFromResolvedArtifactNB("my-resolution-key", "create")
+ }
+ verifySequence {
+ netconfSession.connect()
+ netconfRpcService.lock()
+ netconfRpcService.editConfig(payload)
+ netconfRpcService.commit()
+ netconfRpcService.unLock()
+ netconfSession.disconnect()
+ }
+ }
+}
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/pom.xml b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 000000000..76cf640d0
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2021 Bell Canada
+ ~
+ ~ 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 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.cds.components.cba</groupId>
+ <artifactId>test-blueprint-kotlin-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>pom</packaging>
+
+ <properties>
+ <!-- Properties for -Pdeploy-cba, these can be overridden if needed -->
+ <cds.username>${cdsUsername}</cds.username>
+ <cds.password>${cdsPassword}</cds.password>
+ <!--cds.protocol>http</cds.protocol>
+ <cds.host>localhost</cds.host>
+ <cds.port>8081</cds.port>
+ <cds.enrich.endpoint>api/v1/blueprint-model/enrich</cds.enrich.endpoint>
+ <cds.publish.endpoint>api/v1/blueprint-model/publish</cds.publish.endpoint>
+ -->
+ </properties>
+</project>
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/test/resources/projects/basic/archetype.properties b/components/model-catalog/blueprint-model/archetype-blueprint/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 000000000..95b76b4ba
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,4 @@
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
diff --git a/components/model-catalog/blueprint-model/pom.xml b/components/model-catalog/blueprint-model/pom.xml
index 3b139b965..7e277c618 100644
--- a/components/model-catalog/blueprint-model/pom.xml
+++ b/components/model-catalog/blueprint-model/pom.xml
@@ -32,6 +32,7 @@
<name>Components Model Catalog - Blueprints Model</name>
<modules>
+ <module>archetype-blueprint</module>
<module>test-blueprint</module>
<module>cba-assembly-descriptor</module>
<module>test-blueprint-kotlin-parent</module>