def validate(self): '''Validate the template. Validates the top-level sections of the template as well as syntax inside select sections. Some sections are not checked here but in code parts that are responsible for working with the respective sections (e.g. parameters are check by parameters schema class). ''' # check top-level sections for k in self.t.keys(): if k not in self.SECTIONS: raise exception.InvalidTemplateSection(section=k) # check resources tmpl_resources = self[self.RESOURCES] if not tmpl_resources: logger.warn(_('Template does not contain any resources, so ' 'the template would not really do anything when ' 'being instantiated.')) for res in tmpl_resources.values(): try: if not res.get('Type'): message = _('Every Resource object must ' 'contain a Type member.') raise exception.StackValidationFailed(message=message) except AttributeError: type_res = type(res) if isinstance(res, unicode): type_res = "string" message = _('Resources must contain Resource. ' 'Found a [%s] instead') % type_res raise exception.StackValidationFailed(message=message)
def validate(self): '''Validate the template. Validates the top-level sections of the template as well as syntax inside select sections. Some sections are not checked here but in code parts that are responsible for working with the respective sections (e.g. parameters are check by parameters schema class). ''' # check top-level sections for k in self.t.keys(): if k not in self.SECTIONS: raise exception.InvalidTemplateSection(section=k) # check resources for res in self[self.RESOURCES].values(): try: if not res or not res.get('Type'): message = _('Each Resource must contain ' 'a Type key.') raise exception.StackValidationFailed(message=message) except AttributeError: message = _('Resources must contain Resource. ' 'Found a [%s] instead') % type(res) raise exception.StackValidationFailed(message=message)
def validate(self): '''Validate the template. Only validates the top-level sections of the template. Syntax inside sections is not checked here but in code parts that are responsible for working with the respective sections. ''' for k in self.t.keys(): if k not in self.SECTIONS: raise exception.InvalidTemplateSection(section=k)
def validate(self): """Validate the template. Validates the top-level sections of the template as well as syntax inside select sections. Some sections are not checked here but in code parts that are responsible for working with the respective sections (e.g. parameters are check by parameters schema class). """ t_digest = hashlib.sha256( six.text_type(self.t).encode('utf-8')).hexdigest() # TODO(kanagaraj-manickam) currently t_digest is stored in self. which # is used to check whether already template is validated or not. # But it needs to be loaded from dogpile cache backend once its # available in heat (http://specs.openstack.org/openstack/heat-specs/ # specs/liberty/constraint-validation-cache.html). This is required # as multiple heat-engines may process the same template at least # in case of instance_group. And it fixes partially bug 1444316 if t_digest == self.t_digest: return # check top-level sections for k in six.iterkeys(self.t): if k not in self.SECTIONS: raise exception.InvalidTemplateSection(section=k) # check resources for res in six.itervalues(self[self.RESOURCES]): try: if not res or not res.get('Type'): message = _('Each Resource must contain ' 'a Type key.') raise exception.StackValidationFailed(message=message) except AttributeError: message = _('Resources must contain Resource. ' 'Found a [%s] instead') % type(res) raise exception.StackValidationFailed(message=message) self.t_digest = t_digest