aboutsummaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-12 16:49:54 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-13 09:31:17 -0400
commit1746f00c7134f0bba8cfd2b4a00030b07f231ed1 (patch)
treece12b643444f15fc8fc16d8c68dbc240d5b1330f /components/model-catalog/blueprint-model/test-blueprint/golden/Scripts
parent1a19d33abd1c6afda3b064da022bb77ddf13d5cf (diff)
Add intial test CBA
Change-Id: If7c18e8ad472cebc3e36858fcb0cdf4c7ef6d52d Issue-ID: CCSDK-1149 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'components/model-catalog/blueprint-model/test-blueprint/golden/Scripts')
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py46
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py61
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py47
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py0
4 files changed, 154 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py
new file mode 100644
index 000000000..fce7c3249
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py
@@ -0,0 +1,46 @@
+# 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.
+
+from abstract_ra_processor import AbstractRAProcessor
+from blueprint_constants import *
+from java.lang import Exception as JavaException
+
+class DescriptionExample(AbstractRAProcessor):
+
+ def process(self, resource_assignment):
+ try:
+ # get dependencies result
+ value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type")
+
+ # logic based on dependency outcome
+ result = ""
+ if value == "vfw":
+ result = "This is the Virtual Firewall entity"
+ elif value == "vsn":
+ result = "This is the Virtual Sink entity"
+ elif value == "vpg":
+ result = "This is the Virtual Packet Generator"
+
+ # set value for resource getting currently resolved
+ self.set_resource_data_value(resource_assignment, result)
+
+ except JavaException, err:
+ log.error("Java Exception in the script {}", err)
+ except Exception, err:
+ log.error("Python Exception in the script {}", err)
+ return None
+
+ def recover(self, runtime_exception, resource_assignment):
+ print "NoOp"
+ return None
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py
new file mode 100644
index 000000000..ed22989fb
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py
@@ -0,0 +1,61 @@
+# 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.
+
+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
+
+
+class NetconfRpcExample(NetconfComponentFunction):
+
+ def process(self, execution_request):
+ try:
+ log = globals()[netconf_constant.SERVICE_LOG]
+ print(globals())
+
+ nc = NetconfClient(log, self, "netconf-connection")
+ rr = ResolutionHelper(self)
+
+ # Get meshed template from DB
+ resolution_key = self.getDynamicProperties("resolution-key").asText()
+ artifact_name = "hostname"
+ payloadHostname = rr.retrieve_resolved_template_from_database(resolution_key, artifact_name)
+
+ # resolve param and mesh template
+ payloadInterface = rr.resolve_and_generate_message_from_template_prefix("vfw-interface")
+
+ nc.connect()
+ nc.lock()
+ #if not response.isSuccess():
+ # og.error(response.errorMessage)
+ nc.discard_change()
+ nc.edit_config(message_content=payloadInterface, edit_default_peration="none")
+ nc.edit_config(message_content=payloadHostname, edit_default_peration="none")
+ nc.validate()
+ nc.commit()
+ #nc.commit(confirmed = True, confirm_timeout=15)
+ nc.unlock()
+ nc.disconnect()
+
+ except JavaException, err:
+ log.error("Java Exception in the script {}", err)
+ except Exception, err:
+ log.error("Python Exception in the script {}", err)
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py
new file mode 100644
index 000000000..73419d716
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py
@@ -0,0 +1,47 @@
+# 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.
+
+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
+
+
+class Rollback(NetconfComponentFunction):
+
+ def process(self, execution_request):
+ try:
+ log = globals()[netconf_constant.SERVICE_LOG]
+ print(globals())
+
+ nc = NetconfClient(log, self, "netconf-connection")
+ rr = ResolutionHelper(self)
+
+ # rollback config on device
+ nc.connect()
+ payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix("junos-rollback-RPC")
+ nc.invoke_rpc(payloadHostnameRollback)
+ nc.commit()
+ nc.disconnect()
+
+ except JavaException, err:
+ log.error("Java Exception in the script {}", err)
+ except Exception, err:
+ log.error("Python Exception in the script {}", err)
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py