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
17 from org.openecomp.sdc.toscaparser.jython import JyGroup
19 SECTIONS = (TYPE, METADATA, DESCRIPTION, PROPERTIES, MEMBERS, INTERFACES) = \
20 ('type', 'metadata', 'description',
21 'properties', 'members', 'interfaces')
24 class Group(EntityTemplate, JyGroup):
26 def __init__(self, name, group_templates, member_nodes, custom_defs=None):
27 super(Group, self).__init__(name,
32 self.tpl = group_templates
34 if self.METADATA in self.tpl:
35 self.meta_data = self.tpl.get(self.METADATA)
36 validateutils.validate_map(self.meta_data)
37 self.member_nodes = member_nodes
40 def getJyMembers(self):
43 def getJyMetadata(self):
48 return self.entity_tpl.get('members')
51 def description(self):
52 return self.entity_tpl.get('description')
54 def get_member_nodes(self):
55 return self.member_nodes
57 def _validate_keys(self):
58 for key in self.entity_tpl.keys():
59 if key not in SECTIONS:
60 ExceptionCollector.appendException(
61 UnknownFieldError(what='Groups "%s"' % self.name,