aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json13
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json8
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py18
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json13
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl7
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json10
-rw-r--r--components/scripts/python/ccsdk_netconf/common.py23
-rw-r--r--components/scripts/python/ccsdk_netconf/netconfclient.py2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/pom.xml20
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt17
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt4
12 files changed, 109 insertions, 32 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index 07c988b1..162411f8 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -219,7 +219,10 @@
},
"inputs": {
"instance-dependencies": [
- "json-parser-service"
+
+ ],
+ "artifact-prefix-names": [
+ "hostname"
]
},
"outputs": {
@@ -238,6 +241,14 @@
}
},
"artifacts": {
+ "hostname-template": {
+ "type": "artifact-template-velocity",
+ "file": "Templates/hostname-template.vtl"
+ },
+ "hostname-mapping": {
+ "type": "artifact-mapping-resource",
+ "file": "Templates/hostname-mapping.json"
+ },
"component-script": {
"type": "artifact-script-jython",
"file": "Scripts/python/NetconfRpcExample.py"
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json
index 65271838..d3093d9c 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json
@@ -71,6 +71,14 @@
"entry_schema": {
"type": "string"
}
+ },
+ "artifact-prefix-names": {
+ "required": false,
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
"outputs": {
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
index acdb94aa..26c66b66 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
@@ -13,8 +13,8 @@
# limitations under the License.
import netconf_constant
+from common import ResolutionHelper
from java.lang import Exception as JavaException
-from netconfclient import NetconfClient
from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \
NetconfComponentFunction
@@ -26,21 +26,23 @@ class NetconfRpcExample(NetconfComponentFunction):
log = globals()[netconf_constant.SERVICE_LOG]
print(globals())
nc = NetconfClient(log, self, "netconf-connection")
- nc.connect()
+ rr = ResolutionHelper(self)
- 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=\"delete\"/><host-name operation=\"create\">DEMO</host-name></system></configuration>"
+ payload = rr.resolve_and_generate_message_from_template_prefix("hostname")
+ nc.connect()
response = nc.lock(message_id="lock-123")
if not response.isSuccess():
log.error(response.errorMessage)
- # nc.edit_config(message_id="edit-config-1", message_content=payload,edit_default_peration="none")
+ nc.edit_config(message_id="edit-config-1", message_content=payload,
+ edit_default_peration="none")
# nc.validate(message_id="validate-123")
# nc.discard_change(message_id="discard-123")
- # nc.validate(message_id="validate-123")
- # nc.commit(message_id="commit-123")
- # nc.unlock(message_id="unlock-123")
- # nc.disconnect()
+ nc.validate(message_id="validate-123")
+ nc.commit(message_id="commit-123")
+ nc.unlock(message_id="unlock-123")
+ nc.disconnect()
except JavaException, err:
log.error("Java Exception in the script {}", err)
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json
new file mode 100644
index 00000000..1e02d690
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json
@@ -0,0 +1,13 @@
+[
+ {
+ "name": "hostname",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "hostname",
+ "dictionary-source": "input",
+ "dependencies": [
+ ]
+ }
+]
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl
new file mode 100644
index 00000000..1e80b6d1
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos">
+ <system xmlns="http://yang.juniper.net/junos-qfx/conf/system">
+ <host-name operation="delete" />
+ <host-name operation="create">$hostname</host-name>
+ </system>
+</configuration>
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
index 0bbcba97..b59a7384 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
@@ -25,6 +25,14 @@
"entry_schema": {
"type": "string"
}
+ },
+ "artifact-prefix-names": {
+ "required": false,
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
"outputs": {
@@ -43,5 +51,5 @@
}
}
},
- "derived_from": "tosca.nodes.Component"
+ "derived_from": "tosca.nodes.Component"
} \ No newline at end of file
diff --git a/components/scripts/python/ccsdk_netconf/common.py b/components/scripts/python/ccsdk_netconf/common.py
index 139597f9..25244b13 100644
--- a/components/scripts/python/ccsdk_netconf/common.py
+++ b/components/scripts/python/ccsdk_netconf/common.py
@@ -1,2 +1,25 @@
+# Copyright (c) 2019 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.
+class ResolutionHelper:
+ def __init__(self, component_function):
+ self.component_function = component_function
+
+ def resolve_and_generate_message_from_template_prefix(self, artifact_prefix):
+ return self.component_function.resolveAndGenerateMessage(artifact_prefix)
+
+ def resolve_and_generate_message(self, artifact_mapping, artifact_template):
+ return self.component_function.resolveAndGenerateMessage(artifact_mapping,
+ artifact_template)
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
index cdaf8409..341aae73 100644
--- a/components/scripts/python/ccsdk_netconf/netconfclient.py
+++ b/components/scripts/python/ccsdk_netconf/netconfclient.py
@@ -1,7 +1,6 @@
from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
CONFIG_DEFAULT_OPERATION_REPLACE
-
class NetconfClient:
def __init__(self, log, component_function, requirement_name):
@@ -28,7 +27,6 @@ class NetconfClient:
def get_config(self, message_id, filter="",
config_target=CONFIG_TARGET_RUNNING, message_timeout=30):
- self.log.info("in the ncclient getConfig {}", message_id)
device_response = self.netconf_rpc_client.getConfig(message_id, filter,
config_target,
message_timeout)
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
index 51c62502..df566de4 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
@@ -29,7 +29,7 @@
<dependencies>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
- <artifactId>python-executor</artifactId>
+ <artifactId>resource-resolution</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
@@ -42,18 +42,10 @@
<artifactId>sshd-core</artifactId>
<version>1.7.0</version>
</dependency>
- <!-- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- <version>${bouncycastle.version}</version>
- </dependency> -->
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- <version>0.1.54</version>
- </dependency>
-
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.54</version>
+ </dependency>
</dependencies>
-
-
</project>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
index c32aa9d5..ecf90a28 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -28,7 +29,8 @@ import org.springframework.stereotype.Component
@Component("component-netconf-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService)
+open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService,
+ private var resourceResolutionService: ResourceResolutionService)
: AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentNetconfExecutor::class.java)
@@ -41,6 +43,8 @@ open class ComponentNetconfExecutor(private val blueprintJythonService: Blueprin
checkNotNull(scriptComponent) { "failed to get netconf script component" }
scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
+ scriptComponent.resourceResolutionService = resourceResolutionService
+
scriptComponent.processId = processId
scriptComponent.workflowName = workflowName
scriptComponent.stepName = stepName
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
index c98009fe..e1160acf 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -18,23 +18,32 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
abstract class NetconfComponentFunction : AbstractComponentFunction() {
+ lateinit var resourceResolutionService: ResourceResolutionService
+
// Called from python script
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
val deviceInfo = deviceProperties(requirementName)
return NetconfDevice(deviceInfo)
}
- fun generateMessage(): String {
- TODO()
+ fun generateMessage(artifactName: String): String {
+ return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
+ }
+
+ fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
+ return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ artifactMapping, artifactTemplate)
}
- fun resolveAndGenerateMesssage(): String {
- TODO()
+ fun resolveAndGenerateMessage(artifactPrefix: String): String {
+ return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ artifactPrefix)
}
private fun deviceProperties(requirementName: String): DeviceInfo {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
index 7b31610c..5b7b14ad 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
@@ -24,6 +24,7 @@ import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
@@ -35,7 +36,8 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class, ComponentNetconfExecutor::class, JsonParserService::class])
+@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
+ ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"])