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
5 # http://www.apache.org/licenses/LICENSE-2.0
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
13 from toscaparser.common.exception import ExceptionCollector
14 from toscaparser.common.exception import UnknownFieldError
15 from toscaparser.entity_template import EntityTemplate
16 from toscaparser.utils import validateutils
18 SECTIONS = (TYPE, METADATA, DESCRIPTION, PROPERTIES, MEMBERS, INTERFACES) = \
19 ('type', 'metadata', 'description',
20 'properties', 'members', 'interfaces')
23 class Group(EntityTemplate):
25 def __init__(self, name, group_templates, member_nodes, custom_defs=None):
26 super(Group, self).__init__(name,
31 self.tpl = group_templates
33 if self.METADATA in self.tpl:
34 self.meta_data = self.tpl.get(self.METADATA)
35 validateutils.validate_map(self.meta_data)
36 self.member_nodes = member_nodes
41 return self.entity_tpl.get('members')
44 def description(self):
45 return self.entity_tpl.get('description')
47 def get_member_nodes(self):
48 return self.member_nodes
50 def _validate_keys(self):
51 for key in self.entity_tpl.keys():
52 if key not in SECTIONS:
53 ExceptionCollector.appendException(
54 UnknownFieldError(what='Groups "%s"' % self.name,