fce7c3249e474c33d153f0954eb2a68a305b2252
[ccsdk/apps.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         try:
23             # get dependencies result
24             value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type")
25             
26             # logic based on dependency outcome
27             result = ""
28             if value == "vfw":
29                 result = "This is the Virtual Firewall entity"
30             elif value == "vsn":
31                 result = "This is the Virtual Sink entity"
32             elif value == "vpg":
33                 result = "This is the Virtual Packet Generator"
34
35             # set value for resource getting currently resolved
36             self.set_resource_data_value(resource_assignment, result)
37
38         except JavaException, err:
39           log.error("Java Exception in the script {}", err)
40         except Exception, err:
41           log.error("Python Exception in the script {}", err)
42         return None
43
44     def recover(self, runtime_exception, resource_assignment):
45         print "NoOp"
46         return None