toscaparser: Support deriving from capability types of no property
[parser.git] / tosca2heat / tosca-parser / toscaparser / unsupportedtype.py
1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
2 #    not use this file except in compliance with the License. You may obtain
3 #    a copy of the License at
4 #
5 #         http://www.apache.org/licenses/LICENSE-2.0
6 #
7 #    Unless required by applicable law or agreed to in writing, software
8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 #    License for the specific language governing permissions and limitations
11 #    under the License.
12 import logging
13
14 from toscaparser.common.exception import ExceptionCollector
15 from toscaparser.common.exception import UnsupportedTypeError
16 from toscaparser.utils.gettextutils import _
17
18 log = logging.getLogger('tosca')
19
20
21 class UnsupportedType(object):
22
23     """Note: TOSCA spec version related
24
25     The tosca.nodes.Storage.ObjectStorage and tosca.nodes.Storage.BlockStorage
26     used here as un_supported_types are part of the name changes in TOSCA spec
27     version 1.1. The original name as specified in version 1.0 are,
28     tosca.nodes.BlockStorage and tosca.nodes.ObjectStorage which are supported
29     by the tosca-parser. Since there are little overlapping in version support
30     currently in the tosca-parser, the names tosca.nodes.Storage.ObjectStorage
31     and tosca.nodes.Storage.BlockStorage are used here to demonstrate the usage
32     of un_supported_types. As tosca-parser move to provide support for version
33     1.1 and higher, they will be removed.
34     """
35     un_supported_types = ['tosca.test.invalidtype',
36                           'tosca.nodes.Storage.ObjectStorage',
37                           'tosca.nodes.Storage.BlockStorage']
38
39     def __init__(self):
40         pass
41
42     @staticmethod
43     def validate_type(entitytype):
44         if entitytype in UnsupportedType.un_supported_types:
45             ExceptionCollector.appendException(UnsupportedTypeError(
46                                                what=_('%s')
47                                                % entitytype))
48             return True
49         else:
50             return False