8482a89d3b8709e5cea16a513162ef89ded11dde
[ccsdk/cds.git] / components / model-catalog / blueprint-model / test-blueprint / golden / Scripts / python / DescriptionExample.py
1 #  Copyright (c) 2019 Bell Canada.
2 #
3 #  Licensed under the Apache License, Version 2.0 (the "License");
4 #  you may not use this file except in compliance with the License.
5 #  You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #  Unless required by applicable law or agreed to in writing, software
10 #  distributed under the License is distributed on an "AS IS" BASIS,
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 from abstract_ra_processor import AbstractRAProcessor
16 from blueprint_constants import *
17 from java.lang import Exception as JavaException
18
19 class DescriptionExample(AbstractRAProcessor):
20
21     def process(self, resource_assignment):
22         # get dependencies result
23         value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type")
24         
25         # logic based on dependency outcome
26         result = ""
27         if value == "vfw":
28             result = "This is the Virtual Firewall entity"
29         elif value == "vsn":
30             result = "This is the Virtual Sink entity"
31         elif value == "vpg":
32             result = "This is the Virtual Packet Generator"
33
34         # set value for resource getting currently resolved
35         self.set_resource_data_value(resource_assignment, result)
36
37         return None
38
39     def recover(self, runtime_exception, resource_assignment):
40         log.error("Exception in the script {}", runtime_exception)
41         print self.addError(runtime_exception.cause.message)
42         return None