Synchronise the openstack bugs
[parser.git] / tosca2heat / heat-translator / translator / hot / translate_outputs.py
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
12 # under the License.
13
14 import logging
15
16 from toscaparser.utils.gettextutils import _
17 from translator.hot.syntax.hot_output import HotOutput
18
19 log = logging.getLogger('heat-translator')
20
21
22 class TranslateOutputs(object):
23     '''Translate TOSCA Outputs to Heat Outputs.'''
24
25     def __init__(self, outputs, node_translator):
26         log.debug(_('Translating TOSCA outputs to HOT outputs.'))
27         self.outputs = outputs
28         self.nodes = node_translator
29
30     def translate(self):
31         return self._translate_outputs()
32
33     def _translate_outputs(self):
34         hot_outputs = []
35         for output in self.outputs:
36             hot_value = self.nodes.translate_param_value(output.value, None)
37             if hot_value is not None:
38                 hot_outputs.append(HotOutput(output.name, hot_value,
39                                              output.description))
40         return hot_outputs