aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-02-18 08:08:24 -0500
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-02-18 17:31:41 -0500
commit48b1bea8c1a636169cb5fecd3d0091064e02145b (patch)
treefd9d267b6cfbd9ca0f3042aaa787f67560c0327e
parent01eff6bc81499a9e41395f6b384a5e893b366505 (diff)
Simplify NetconfRpcService
Change-Id: I6daac25c272ab6b437c07602167a76a2d61816db Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json8
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json (renamed from components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json)0
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json287
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json34
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py16
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json30
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json24
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json16
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json2
-rwxr-xr-xcomponents/model-catalog/resource-dictionary/starter-dictionary/hostname.json14
-rw-r--r--components/scripts/python/ccsdk_netconf/netconfclient.py54
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt1
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt5
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt81
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt192
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt6
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt12
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt10
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt9
22 files changed, 403 insertions, 415 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 162411f8..c21f4c9d 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
@@ -218,11 +218,9 @@
"primary": "component-script"
},
"inputs": {
+ "script-type": "jython",
+ "script-class-reference": "Scripts/python/NetconfRpcExample.py",
"instance-dependencies": [
-
- ],
- "artifact-prefix-names": [
- "hostname"
]
},
"outputs": {
@@ -247,7 +245,7 @@
},
"hostname-mapping": {
"type": "artifact-mapping-resource",
- "file": "Templates/hostname-mapping.json"
+ "file": "Definitions/hostname-mapping.json"
},
"component-script": {
"type": "artifact-script-jython",
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json
index 1e02d690..1e02d690 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json
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 d3093d9c..3912a472 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
@@ -1,48 +1,44 @@
{
"node_types": {
- "dg-generic": {
- "description": "This is Generic Directed Graph Type",
+ "component-jython-executor": {
+ "description": "This is Jython Execution Component.",
"version": "1.0.0",
- "properties": {
- "content": {
- "required": true,
- "type": "string"
- },
- "dependency-node-templates": {
- "required": true,
- "description": "Dependent Step Components",
- "type": "list",
- "entry_schema": {
- "type": "string"
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "interfaces": {
+ "ComponentJythonExecutor": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "instance-dependencies": {
+ "description": "Instance Names to Inject to Jython Script.",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "outputs": {
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
}
}
},
- "derived_from": "tosca.nodes.DG"
- },
- "tosca.nodes.Component": {
- "description": "This is Resource Assignment Component API",
- "version": "1.0.0",
- "derived_from": "tosca.nodes.Root"
- },
- "tosca.nodes.DG": {
- "description": "This is Directed Graph Node Type",
- "version": "1.0.0",
- "derived_from": "tosca.nodes.Root"
- },
- "tosca.nodes.ResourceSource" : {
- "description" : "TOSCA base type for Resource Sources",
- "version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
- },
- "tosca.nodes.Vnf" : {
- "description" : "This is VNF Node Type",
- "version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
- },
- "tosca.nodes.component.Jython": {
- "description": "This is Resource Assignment Jython Component API",
- "version": "1.0.0",
- "derived_from": "tosca.nodes.Root"
+ "derived_from": "tosca.nodes.component.Jython"
},
"component-netconf-executor": {
"description": "This is Netconf Transaction Configuration Component API",
@@ -64,17 +60,29 @@
"operations": {
"process": {
"inputs": {
- "instance-dependencies": {
- "description": "Instance Names to Inject to Jython Script.",
+ "script-type": {
+ "description": "Script type, kotlin type is supported",
"required": true,
- "type": "list",
- "entry_schema": {
- "type": "string"
- }
+ "type": "string",
+ "constraints": [
+ {
+ "valid_values": [
+ "kotlin",
+ "jython",
+ "internal"
+ ]
+ }
+ ],
+ "default": "internal"
},
- "artifact-prefix-names": {
- "required": false,
- "description": "Template , Resource Assignment Artifact Prefix names",
+ "script-class-reference": {
+ "description": "Kotlin Script class name or jython script name.",
+ "required": true,
+ "type": "string"
+ },
+ "instance-dependencies": {
+ "description": "Instance names to inject to Jython or Kotlin Script.",
+ "required": true,
"type": "list",
"entry_schema": {
"type": "string"
@@ -108,37 +116,43 @@
"type": "string"
}
},
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
"interfaces": {
"ResourceResolutionComponent": {
"operations": {
"process": {
"inputs": {
- "action-name": {
- "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- },
"resource-type": {
+ "description": "Request type.",
"required": false,
"type": "string"
},
+ "artifact-prefix-names": {
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"request-id": {
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",
+ "description": "Request Id, Unique Id for the request.",
"required": true,
"type": "string"
},
"resource-id": {
- "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",
- "required": true,
+ "description": "Resource Id.",
+ "required": false,
"type": "string"
},
- "artifact-prefix-names": {
+ "action-name": {
+ "description": "Action Name of the process",
"required": false,
- "description": "Template , Resource Assignment Artifact Prefix names",
- "type": "list",
- "entry_schema": {
- "type": "string"
- }
+ "type": "string"
}
},
"outputs": {
@@ -157,45 +171,128 @@
},
"derived_from": "tosca.nodes.Component"
},
- "component-jython-executor": {
- "description": "This is Jython Execution Component.",
+ "dg-generic": {
+ "description": "This is Generic Directed Graph Type",
"version": "1.0.0",
- "capabilities": {
- "component-node": {
- "type": "tosca.capabilities.Node"
+ "properties": {
+ "content": {
+ "required": true,
+ "type": "string"
+ },
+ "dependency-node-templates": {
+ "description": "Dependent Step Components NodeTemplate name.",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
- "interfaces": {
- "ComponentJythonExecutor": {
- "operations": {
- "process": {
- "inputs": {
- "instance-dependencies": {
- "required": true,
- "description": "Instance Names to Inject to Jython Script.",
- "type": "list",
- "entry_schema": {
- "type": "string"
- }
- }
- },
- "outputs": {
- "response-data": {
- "description": "Execution Response Data in JSON format.",
- "required": false,
- "type": "string"
- },
- "status": {
- "description": "Status of the Component Execution ( success or failure )",
- "required": true,
- "type": "string"
- }
- }
+ "derived_from": "tosca.nodes.DG"
+ },
+ "source-input": {
+ "description": "This is Input Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "key": {
+ "required": false,
+ "type": "string"
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+ },
+ "source-rest": {
+ "description": "This is Rest Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "constraints": [
+ {
+ "valid_values": [
+ "JSON"
+ ]
+ }
+ ],
+ "default": "JSON"
+ },
+ "url-path": {
+ "required": true,
+ "type": "string"
+ },
+ "path": {
+ "required": true,
+ "type": "string"
+ },
+ "expression-type": {
+ "required": false,
+ "type": "string",
+ "constraints": [
+ {
+ "valid_values": [
+ "JSON_PATH",
+ "JSON_POINTER"
+ ]
}
+ ],
+ "default": "JSON_PATH"
+ },
+ "input-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
}
}
},
- "derived_from": "tosca.nodes.component.Jython"
+ "derived_from": "tosca.nodes.ResourceSource"
+ },
+ "tosca.nodes.Component": {
+ "description": "This is default Component Node",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+ },
+ "tosca.nodes.DG": {
+ "description": "This is Directed Graph Node Type",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+ },
+ "tosca.nodes.ResourceSource": {
+ "description": "TOSCA base type for Resource Sources",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+ },
+ "tosca.nodes.Vnf": {
+ "description": "This is VNF Node Type",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+ },
+ "tosca.nodes.component.Jython": {
+ "description": "This is Jython Component",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
},
"vnf-netconf-device": {
"description": "This is VNF Device with Netconf Capability",
@@ -215,7 +312,7 @@
"default": "sdnc-tacacs"
},
"source": {
- "required": true,
+ "required": false,
"type": "string",
"default": "npm"
},
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
index d2d32e81..ace1a942 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
@@ -1,35 +1,41 @@
{
+ "hostname": {
+ "tags": "hostname",
+ "name": "hostname",
+ "property": {
+ "description": "hostname",
+ "type": "string"
+ },
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "sources": {
+ "input": {
+ "type": "source-input"
+ }
+ }
+ },
"service-instance-id": {
- "name": "service-instance-id",
"tags": "service-instance-id, tosca.datatypes.Root, data_type",
- "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "name": "service-instance-id",
"property": {
"description": "To be provided",
"type": "string"
},
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
"sources": {
"input": {
"type": "source-input",
"properties": {}
- },
- "capability": {
- "type": "source-capability",
- "properties": {
- "type": "JYTHON-COMPONENT",
- "instance-name": "SampleRAProcessor",
- "instance-dependencies": []
- }
}
}
},
"vnf-id": {
- "name": "vnf-id",
"tags": "vnf-id",
- "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "name": "vnf-id",
"property": {
"description": "vnf-id",
"type": "string"
},
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
"sources": {
"input": {
"type": "source-input",
@@ -38,13 +44,13 @@
}
},
"vnf_name": {
- "name": "vnf_name",
"tags": "vnf_name",
- "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "name": "vnf_name",
"property": {
"description": "vnf_name",
"type": "string"
},
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
"sources": {
"primary-config-data": {
"type": "source-rest",
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 26c66b66..94cd72a4 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
@@ -15,6 +15,7 @@
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
@@ -31,17 +32,16 @@ class NetconfRpcExample(NetconfComponentFunction):
payload = rr.resolve_and_generate_message_from_template_prefix("hostname")
nc.connect()
- response = nc.lock(message_id="lock-123")
+ response = nc.lock()
if not response.isSuccess():
log.error(response.errorMessage)
- 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.edit_config(message_content=payload, edit_default_peration="none")
+ nc.validate()
+ nc.discard_change()
+ nc.validate()
+ nc.commit()
+ nc.unlock()
nc.disconnect()
except JavaException, err:
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 b59a7384..85b69b09 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
@@ -18,17 +18,29 @@
"operations": {
"process": {
"inputs": {
- "instance-dependencies": {
+ "script-type": {
+ "description": "Script type, kotlin type is supported",
"required": true,
- "description": "Instance Names to Inject to Jython Script.",
- "type": "list",
- "entry_schema": {
- "type": "string"
- }
+ "type": "string",
+ "default": "internal",
+ "constraints": [
+ {
+ "valid_values": [
+ "kotlin",
+ "jython",
+ "internal"
+ ]
+ }
+ ]
},
- "artifact-prefix-names": {
- "required": false,
- "description": "Template , Resource Assignment Artifact Prefix names",
+ "script-class-reference": {
+ "description": "Kotlin Script class name or jython script name.",
+ "required": true,
+ "type": "string"
+ },
+ "instance-dependencies": {
+ "required": true,
+ "description": "Instance names to inject to Jython or Kotlin Script.",
"type": "list",
"entry_schema": {
"type": "string"
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
index d01660ef..7e3065ae 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json
@@ -17,31 +17,13 @@
"operations": {
"process": {
"inputs": {
- "template-name": {
- "description": "Service Template Name.",
- "required": true,
- "type": "string"
- },
- "template-version": {
- "description": "Service Template Version.",
- "required": true,
- "type": "string"
- },
"resource-type": {
"description": "Request type.",
- "required": true,
+ "required": false,
"type": "string"
},
- "template-names": {
- "description": "Name of the artifact Node Templates, to get the template Content.",
- "required": true,
- "type": "list",
- "entry_schema": {
- "type": "string"
- }
- },
"artifact-prefix-names": {
- "required": false,
+ "required": true,
"description": "Template , Resource Assignment Artifact Prefix names",
"type": "list",
"entry_schema": {
@@ -50,7 +32,7 @@
},
"request-id": {
"description": "Request Id, Unique Id for the request.",
- "required": false,
+ "required": true,
"type": "string"
},
"resource-id": {
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 2bdd7d57..4d9488cb 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
@@ -29,22 +29,6 @@
"type": "string"
}
},
- "input-key-mapping": {
- "description": "Context name to input parameters name mapping.",
- "required": false,
- "type": "map",
- "entry_schema": {
- "type": "string"
- }
- },
- "output-key-mapping": {
- "description": "Context name to output parameters name mapping.",
- "required": false,
- "type": "map",
- "entry_schema": {
- "type": "string"
- }
- },
"key-dependencies": {
"description": "Resource Resolution dependency dictionary names.",
"required": true,
diff --git a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
index c6f512df..dcc47b36 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
@@ -16,7 +16,7 @@
"default": "sdnc-tacacs"
},
"source": {
- "required": true,
+ "required": false,
"type": "string",
"default": "npm"
},
diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json b/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json
new file mode 100755
index 00000000..f60751ed
--- /dev/null
+++ b/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json
@@ -0,0 +1,14 @@
+{
+ "name": "hostname",
+ "tags": "hostname",
+ "updated-by" : "Singal, Kapil <ks220y@att.com>",
+ "property": {
+ "description" : "hostname",
+ "type": "string"
+ },
+ "sources": {
+ "input": {
+ "type": "source-input"
+ }
+ }
+}
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
index 341aae73..dd7d2dc2 100644
--- a/components/scripts/python/ccsdk_netconf/netconfclient.py
+++ b/components/scripts/python/ccsdk_netconf/netconfclient.py
@@ -1,6 +1,7 @@
from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
CONFIG_DEFAULT_OPERATION_REPLACE
+
class NetconfClient:
def __init__(self, log, component_function, requirement_name):
@@ -19,54 +20,33 @@ class NetconfClient:
self.netconf_session.connect()
return
- def lock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE,
- message_timeout=30):
- device_response = self.netconf_rpc_client.lock(message_id, config_target,
- message_timeout)
+ def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.lock(config_target)
return device_response
- def get_config(self, message_id, filter="",
- config_target=CONFIG_TARGET_RUNNING, message_timeout=30):
- device_response = self.netconf_rpc_client.getConfig(message_id, filter,
- config_target,
- message_timeout)
+ def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
+ device_response = self.netconf_rpc_client.getConfig(filter, config_target)
return device_response
- def edit_config(self, message_id, message_content, lock=False,
- config_target=CONFIG_TARGET_CANDIDATE,
- edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE,
- deleteConfig=False, validate=False, commit=False, discard_change=False,
- unlock=False, message_timeout=30):
- device_response = self.netconf_rpc_client.editConfig(message_id,
- message_content, lock,
+ def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE,
+ edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE):
+ device_response = self.netconf_rpc_client.editConfig(message_content,
config_target,
- edit_default_peration,
- deleteConfig, validate,
- commit, discard_change,
- unlock,
- message_timeout)
+ edit_default_peration)
return device_response
- def commit(self, message_id, discard_change=True,
- message_timeout=30):
- device_response = self.netconf_rpc_client.commit(message_id, discard_change,
- message_timeout)
+ def commit(self):
+ device_response = self.netconf_rpc_client.commit()
return device_response
- def unlock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE,
- message_timeout=30):
- device_response = self.netconf_rpc_client.unLock(message_id, config_target,
- message_timeout)
+ def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.unLock(config_target)
return device_response
- def validate(self, message_id, config_target=CONFIG_TARGET_CANDIDATE,
- message_timeout=30):
- device_response = self.netconf_rpc_client.validate(message_id,
- config_target,
- message_timeout)
+ def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.validate(config_target)
return device_response
- def discard_change(self, message_id, message_timeout=30):
- device_response = self.netconf_rpc_client.discardConfig(message_id,
- message_timeout)
+ def discard_change(self):
+ device_response = self.netconf_rpc_client.discardConfig()
return device_response
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 ecf90a28..06c9b7b2 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
@@ -42,6 +42,7 @@ open class ComponentNetconfExecutor(private val blueprintJythonService: Blueprin
scriptComponent = blueprintJythonService.jythonComponentInstance(this) as NetconfComponentFunction
checkNotNull(scriptComponent) { "failed to get netconf script component" }
+ // FIXME("Populate the reference in Abstract Script Instance Injection map")
scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
scriptComponent.resourceResolutionService = resourceResolutionService
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
index 54776621..1c07c5e6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
@@ -20,12 +20,11 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.Ne
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfRpcServiceImpl
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
-class NetconfDevice(deviceInfo: DeviceInfo) {
- val netconfRpcService: NetconfRpcServiceImpl
+data class NetconfDevice(val deviceInfo: DeviceInfo) {
+ val netconfRpcService = NetconfRpcServiceImpl(deviceInfo)
val netconfSession: NetconfSession
init {
- netconfRpcService = NetconfRpcServiceImpl(deviceInfo)
netconfSession = NetconfSessionImpl(deviceInfo, netconfRpcService)
netconfRpcService.setNetconfSession(netconfSession)
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index 554368c7..e2c9bf90 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -15,107 +15,90 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.ModifyAction
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDatastore
+
interface NetconfRpcService {
/**
* Lock
- * @param messageId message id of the request.
- * @param configTarget datastore ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun lock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun lock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Get-config
- * @param messageId message id of the request.
- * @param filter filter content.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param filter filter content, default empty
+ * @param configTarget running or candidate, default running
* @return Device response
*/
- fun getConfig(messageId: String, filter: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun getConfig(filter: String = "", configTarget: String = NetconfDatastore.RUNNING.datastore): DeviceResponse
/**
- * Delete config from datastore
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ * Delete config
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun deleteConfig(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun deleteConfig(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Edit-config
- * @param messageId message id of the request.
+ *
* @param messageContent edit config content.
- * @param lock lock the device before performing edit.
- * @param configTarget config target ( running or candidate)
- * @param editDefaultOperation edit default operation (merge | replace | create | delete | remove or
- * delete)
- * @param clearCandidate commit after edit config
- * @param commit clear candiate store before edit
- * @param discardChanges Rollback on failure
- * @param validate validate the config before commit
- * @param unlock unlock device after edit
- * @param messageTimeout message timeout of the request.
+ * @param configTarget running or candidate, default candidate
+ * @param editDefaultOperation, default set to none. Valid values: merge, replace, create, delete, none
* @return Device response
*/
- fun editConfig(messageId: String, messageContent: String, lock: Boolean, configTarget: String,
- editDefaultOperation: String, deleteConfig: Boolean, validate: Boolean, commit: Boolean,
- discardChanges: Boolean, unlock: Boolean, messageTimeout: Int): DeviceResponse
+ fun editConfig(messageContent: String, configTarget: String = NetconfDatastore.CANDIDATE.datastore,
+ editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
/**
* Validate
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun validate(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun validate(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Commit
- * @param messageId message id of the request.
- * @param discardChanges Rollback on failure
- * @param messageTimeout message timeout of the request.
+ *
* @return Device response
*/
- fun commit(messageId: String, discardChanges: Boolean, messageTimeout: Int): DeviceResponse
+ fun commit(): DeviceResponse
/**
* Unlock
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun unLock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun unLock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Discard config
- * @param messageId message id of the request.
- * @param messageTimeout message timeout of the request.
+ *
* @return Device response
*/
- fun discardConfig(messageId: String, messageTimeout: Int): DeviceResponse
+ fun discardConfig(): DeviceResponse
/**
* Close session
- * @param messageId message id of the request.
+ *
* @param force force closeSession
- * @param messageTimeout message timeout of the request.
* @return Device response
*/
- fun closeSession(messageId: String, force: Boolean, messageTimeout: Int): DeviceResponse
+ fun closeSession(force: Boolean): DeviceResponse
/**
* Executes an RPC request to the netconf server.
*
* @param request the XML containing the RPC request for the server.
- * @param messageId message id of the request.
- * @param messageTimeout message timeout of the request.
* @return Device response
*/
- fun asyncRpc(request: String, messageId: String, messageTimeout: Int): DeviceResponse
+ fun asyncRpc(request: String, messageId: String): DeviceResponse
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 5c633a5b..be835557 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -21,29 +21,33 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.De
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfException
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfRpcService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfSession
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDatastore
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfMessageUtils
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
import org.slf4j.LoggerFactory
import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicInteger
-class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcService {
+class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcService {
private val log = LoggerFactory.getLogger(NetconfRpcService::class.java)
+ private var responseTimeout: Int = deviceInfo.replyTimeout
+
private lateinit var netconfSession: NetconfSession
+ private val messageIdInteger = AtomicInteger(1)
+
fun setNetconfSession(netconfSession: NetconfSession) {
this.netconfSession = netconfSession
}
- override fun getConfig(messageId: String, filter: String, configTarget: String,
- messageTimeout: Int): DeviceResponse {
+ override fun getConfig(filter: String, configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: getConfig: messageId($messageId)")
try {
val message = NetconfMessageUtils.getConfig(messageId, configTarget, filter)
- output = asyncRpc(message, messageId, messageTimeout)
+ output = asyncRpc(message, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in get-config command $e.message"
@@ -51,13 +55,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun deleteConfig(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun deleteConfig(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: deleteConfig: messageId($messageId)")
try {
val deleteConfigMessage = NetconfMessageUtils.deleteConfig(messageId, configTarget)
output.requestMessage = deleteConfigMessage
- output = asyncRpc(deleteConfigMessage, messageId, messageTimeout)
+ output = asyncRpc(deleteConfigMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in delete config command $e.message"
@@ -65,13 +70,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun lock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun lock(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: lock: messageId($messageId)")
try {
val lockMessage = NetconfMessageUtils.lock(messageId, configTarget)
output.requestMessage = lockMessage
- output = asyncRpc(lockMessage, messageId, messageTimeout)
+ output = asyncRpc(lockMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in lock command $e.message"
@@ -80,13 +86,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun unLock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun unLock(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: unLock: messageId($messageId)")
try {
val unlockMessage = NetconfMessageUtils.unlock(messageId, configTarget)
output.requestMessage = unlockMessage
- output = asyncRpc(unlockMessage, messageId, messageTimeout)
+ output = asyncRpc(unlockMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in lock command $e.message"
@@ -94,33 +101,28 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun commit(messageId: String, discardChanges: Boolean, messageTimeout: Int): DeviceResponse {
+ override fun commit(): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: commit: messageId($messageId)")
try {
val messageContent = NetconfMessageUtils.commit(messageId)
- output = asyncRpc(messageContent, messageId, messageTimeout)
+ output = asyncRpc(messageContent, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in commit command $e.message"
-
- // If commit failed apply discard changes
- if (discardChanges) {
- val discardChangesConfigMessageId = "$messageId-discard-changes"
- val discardOutput = discardConfig(discardChangesConfigMessageId, deviceInfo.replyTimeout)
- output.addSubDeviceResponse(discardChangesConfigMessageId, discardOutput)
- }
}
return output
}
- override fun discardConfig(messageId: String, messageTimeout: Int): DeviceResponse {
+ override fun discardConfig(): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: discard: messageId($messageId)")
try {
val discardChangesMessage = NetconfMessageUtils.discardChanges(messageId)
output.requestMessage = discardChangesMessage
- output = asyncRpc(discardChangesMessage, messageId, messageTimeout)
+ output = asyncRpc(discardChangesMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in discard changes command " + e.message
@@ -128,12 +130,44 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun closeSession(messageId: String, force: Boolean, messageTimeout: Int): DeviceResponse {
+ override fun editConfig(messageContent: String, configTarget: String,
+ editDefaultOperation: String): DeviceResponse {
+ var response = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: editConfig: messageId($messageId)")
+ try {
+ val editMessage =
+ NetconfMessageUtils.editConfig(messageId, configTarget, editDefaultOperation, messageContent)
+ response.requestMessage = editMessage
+ response = asyncRpc(editMessage, messageId)
+ } catch (e: Exception) {
+ response.status = RpcStatus.FAILURE
+ response.errorMessage = e.message
+ }
+ return response
+ }
+
+ override fun validate(configTarget: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ try {
+ val validateMessage = NetconfMessageUtils.validate(messageId, configTarget)
+ output.requestMessage = validateMessage
+ output = asyncRpc(validateMessage, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in validate command " + e.message
+ }
+ return output
+ }
+
+ override fun closeSession(force: Boolean): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: closeSession: messageId($messageId)")
try {
val messageContent = NetconfMessageUtils.closeSession(messageId, force)
- output = asyncRpc(messageContent, messageId, messageTimeout)
+ output = asyncRpc(messageContent, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in closeSession command " + e.message
@@ -142,12 +176,12 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
}
@Throws(NetconfException::class)
- override fun asyncRpc(request: String, messageId: String, messageTimeout: Int): DeviceResponse {
+ override fun asyncRpc(request: String, messageId: String): DeviceResponse {
val response = DeviceResponse()
log.info("$deviceInfo: send asyncRpc with messageId($messageId)")
response.requestMessage = request
- val rpcResponse = netconfSession.asyncRpc(request, messageId).get(messageTimeout.toLong(), TimeUnit.SECONDS)
+ val rpcResponse = netconfSession.asyncRpc(request, messageId).get(responseTimeout.toLong(), TimeUnit.SECONDS)
if (!NetconfMessageUtils.checkReply(rpcResponse)) {
throw NetconfException(rpcResponse)
}
@@ -156,110 +190,4 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
response.errorMessage = null
return response
}
-
- override fun editConfig(messageId: String, messageContent: String, lock: Boolean, configTarget: String,
- editDefaultOperation: String, deleteConfig: Boolean, validate: Boolean, commit: Boolean,
- discardChanges: Boolean, unlock: Boolean, messageTimeout: Int): DeviceResponse {
- var editConfigDeviceResponse =
- DeviceResponse()
-
- try {
- val editMessage =
- NetconfMessageUtils.editConfig(messageId, configTarget, editDefaultOperation, messageContent)
- editConfigDeviceResponse.requestMessage = editMessage
-
- if (lock) {
- val lockMessageId = "$messageId-lock"
- val lockDeviceResponse = lock(lockMessageId, configTarget, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(lockMessageId, lockDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(lockDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- lockDeviceResponse.errorMessage!!)
- }
- }
-
- if (deleteConfig) {
- val deleteConfigMessageId = "$messageId-delete"
- val deleteConfigDeviceResponse = deleteConfig(deleteConfigMessageId,
- NetconfDatastore.CANDIDATE, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(deleteConfigMessageId, deleteConfigDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(deleteConfigDeviceResponse.status,
- ignoreCase = true)) {
- throw NetconfException(
- deleteConfigDeviceResponse.errorMessage!!)
- }
- }
-
- if (discardChanges) {
- val discardConfigMessageId = "$messageId-discard"
- val discardConfigDeviceResponse = discardConfig(discardConfigMessageId, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(discardConfigMessageId, discardConfigDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(discardConfigDeviceResponse.status,
- ignoreCase = true)) {
- throw NetconfException(
- discardConfigDeviceResponse.errorMessage!!)
- }
- }
-
- editConfigDeviceResponse = asyncRpc(editMessage, messageId, messageTimeout)
- if (!RpcStatus.SUCCESS.equals(editConfigDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- editConfigDeviceResponse.errorMessage!!)
- }
-
- if (validate) {
- val validateMessageId = "$messageId-validate"
- val validateDeviceResponse = validate(validateMessageId,
- NetconfDatastore.CANDIDATE, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(validateMessageId, validateDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(validateDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- validateDeviceResponse.errorMessage!!)
- }
- }
-
- /**
- * If Commit is enable, the commit response is treated as Edit config response, If commit failed, we
- * need not to throw an exception, until we unlock the device.
- */
- if (commit) {
- val commitMessageId = "$messageId-commit"
- val commitDeviceResponse =
- commit(commitMessageId, discardChanges, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(commitMessageId, commitDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(commitDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- commitDeviceResponse.errorMessage!!)
- }
- }
-
- } catch (e: Exception) {
- editConfigDeviceResponse.status = RpcStatus.FAILURE
- editConfigDeviceResponse.errorMessage = e.message
- } finally {
- if (unlock) {
- val unlockMessageId = "$messageId-unlock"
- val unlockDeviceResponse = unLock(unlockMessageId, configTarget, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(unlockMessageId, unlockDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(unlockDeviceResponse.status, ignoreCase = true)) {
- editConfigDeviceResponse.status = RpcStatus.FAILURE
- editConfigDeviceResponse.errorMessage = unlockDeviceResponse.errorMessage
- }
- }
- }
- return editConfigDeviceResponse
- }
-
- override fun validate(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
- var output = DeviceResponse()
- try {
- val validateMessage = NetconfMessageUtils.validate(messageId, configTarget)
- output.requestMessage = validateMessage
- output = asyncRpc(validateMessage, messageId, messageTimeout)
- } catch (e: Exception) {
- output.status = RpcStatus.FAILURE
- output.errorMessage = "$deviceInfo: failed in validate command " + e.message
- }
- return output
- }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
index 21570a23..cf11cfdd 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -40,7 +40,6 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
-import java.util.concurrent.atomic.AtomicInteger
class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcService: NetconfRpcService) :
NetconfSession {
@@ -61,7 +60,6 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
private lateinit var channel: ClientChannel
private lateinit var streamHandler: NetconfDeviceCommunicator
- private val messageIdInteger = AtomicInteger(1)
private var capabilities =
ImmutableList.of(RpcMessageUtils.NETCONF_10_CAPABILITY, RpcMessageUtils.NETCONF_11_CAPABILITY)
@@ -78,9 +76,9 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
}
override fun disconnect() {
- if (rpcService.closeSession(messageIdInteger.incrementAndGet().toString(), false, replyTimeout).status.equals(
+ if (rpcService.closeSession(false).status.equals(
RpcStatus.FAILURE, true)) {
- rpcService.closeSession(messageIdInteger.incrementAndGet().toString(), true, replyTimeout)
+ rpcService.closeSession(true)
}
session.close()
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
index e0cbde53..3b3b0c02 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
@@ -15,9 +15,15 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils
-object NetconfDatastore {
- const val RUNNING = "running"
- const val CANDIDATE = "candidate"
+enum class NetconfDatastore(val datastore: String) {
+ RUNNING("running"),
+ CANDIDATE("candidate");
+}
+
+enum class ModifyAction(val action: String) {
+ MERGE("merge"),
+ REPLACE("replace"),
+ NONE("none")
}
object RpcStatus {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index b0310d78..7e48912d 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -139,9 +139,9 @@ class NetconfMessageUtils {
}
@Throws(NetconfException::class)
- fun deleteConfig(messageId: String, netconfTargetConfig: String): String {
- if (netconfTargetConfig == NetconfDatastore.RUNNING) {
- log.warn("Target configuration for delete operation can't be \"running\" {}", netconfTargetConfig)
+ fun deleteConfig(messageId: String, configType: String): String {
+ if (configType == NetconfDatastore.RUNNING.datastore) {
+ log.warn("Target configuration for delete operation can't be \"running\" {}", configType)
throw NetconfException("Target configuration for delete operation can't be running")
}
@@ -149,7 +149,7 @@ class NetconfMessageUtils {
request.append("<delete-config>").append(NEW_LINE)
request.append(RpcMessageUtils.TARGET_OPEN).append(NEW_LINE)
- request.append(RpcMessageUtils.OPEN).append(netconfTargetConfig)
+ request.append(RpcMessageUtils.OPEN).append(configType)
.append(RpcMessageUtils.TAG_CLOSE)
.append(NEW_LINE)
request.append(RpcMessageUtils.TARGET_CLOSE).append(NEW_LINE)
@@ -304,8 +304,6 @@ class NetconfMessageUtils {
}
if (!message.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
// chunk encode message
- //message = (RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.getBytes(UTF_8).size + RpcMessageUtils.NEW_LINE + message +RpcMessageUtils. NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH
- // + RpcMessageUtils.NEW_LINE)
message =
(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH
+ RpcMessageUtils.NEW_LINE)
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
index 20b04fb5..2cd2d109 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
@@ -29,7 +29,7 @@ class RpcMessageUtilsTest {
+ "</get-config></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
@@ -48,7 +48,7 @@ class RpcMessageUtilsTest {
+ "</get-config></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
@@ -64,7 +64,7 @@ class RpcMessageUtilsTest {
+ "<validate><source><candidate/></source></validate></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.validate(messageId, configType).replace("[\n\r\t]".toRegex(), "")
@@ -94,7 +94,7 @@ class RpcMessageUtilsTest {
+ "<unlock><target><candidate/></target></unlock></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.unlock(messageId, configType).replace("[\n\r\t]".toRegex(), "")
@@ -109,7 +109,7 @@ class RpcMessageUtilsTest {
+ "<delete-config><target><candidate/></target></delete-config></rpc>")
val messageId = "Test-Message-ID"
- val netconfTargetConfig = "candidate"
+ val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.deleteConfig(messageId, netconfTargetConfig).replace("[\n\r\t]".toRegex(), "")
@@ -138,7 +138,7 @@ class RpcMessageUtilsTest {
+ "<lock><target><candidate/></target></lock></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.lock(messageId, configType).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
index 9bcc23b6..bd055953 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
@@ -68,6 +68,7 @@ open class ComponentRestconfExecutor(private var applicationContext: Application
scriptComponent.nodeTemplateName = nodeTemplateName
scriptComponent.operationInputs = operationInputs
+ // FIXME("Populate the reference in Abstract Script Instance Injection map")
// Set the Rest Lib Property Service
scriptComponent.bluePrintRestLibPropertyService = bluePrintRestLibPropertyService
scriptComponent.resourceResolutionService = resourceResolutionService
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index d4e4a24c..63171de6 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -67,14 +67,14 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
}
} catch (e: Exception) {
- log.error("failed in blueprint enhancement", e)
+ throw e
}
return blueprintRuntimeService.bluePrintContext()
}
private fun enhanceResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>) {
-
+ log.info("##### Enhancing blueprint Resource Definitions")
resourceDefinitionEnhancerService.enhance(blueprintRuntimeService)
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
index ab5ca74c..43eb019e 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -75,7 +76,7 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
artifactDefinitionMap.value.file
}
- }?.single { it.isNotEmpty() }?.distinct()
+ }?.flatten()?.distinct()
}
// Convert file content to ResourceAssignments asynchronously
@@ -103,12 +104,12 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
// Read the Resource Definitions from the Database and write to type file.
private fun generateResourceDictionaryFile(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>) {
- val resourcekeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct()
- log.info("distinct resource keys ($resourcekeys)")
+ val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted()
+ log.info("distinct resource keys ($resourceKeys)")
//TODO("Optimise DB single Query to multiple Query")
// Collect the Resource Definition from database and convert to map to save in file
- val resourceDefinitionMap = resourcekeys.map { resourceKey ->
+ val resourceDefinitionMap = resourceKeys.map { resourceKey ->
getResourceDefinition(resourceKey)
}.map { it.name to it }.toMap()