def test_validate_dict(self): snippet = {'foo': 'bar', 'blarg': self.func} function.validate(snippet) self.func = TestFunction(None, 'foo', ['bar']) snippet = {'foo': 'bar', 'blarg': self.func} ex = self.assertRaises(Exception, function.validate, snippet) self.assertEqual('Need more arguments', str(ex))
def test_validate_list(self): snippet = ['foo', 'bar', 'baz', 'blarg', self.func] function.validate(snippet) self.func = TestFunction(None, 'foo', ['bar']) snippet = {'foo': 'bar', 'blarg': self.func} ex = self.assertRaises(Exception, function.validate, snippet) self.assertEqual('Need more arguments', six.text_type(ex))
def test_validate_all(self): snippet = ['foo', {'bar': ['baz', {'blarg': self.func}]}] function.validate(snippet) self.func = TestFunction(None, 'foo', ['bar']) snippet = {'foo': 'bar', 'blarg': self.func} ex = self.assertRaises(TypeError, function.validate, snippet) self.assertEqual('Need more arguments', six.text_type(ex))
def test_validate_all(self): snippet = ['foo', {'bar': ['baz', {'blarg': self.func}]}] function.validate(snippet) self.func = TestFunction(None, 'foo', ['bar']) snippet = {'foo': 'bar', 'blarg': self.func} self.assertRaisesRegex(exception.StackValidationFailed, 'blarg.foo: Need more arguments', function.validate, snippet)
def test_validate_all(self): snippet = ['foo', {'bar': ['baz', {'blarg': self.func}]}] function.validate(snippet) self.func = TestFunction(None, 'foo', ['bar']) snippet = {'foo': 'bar', 'blarg': self.func} self.assertRaisesRegex(exception.StackValidationFailed, '.blarg.foo: Need more arguments', function.validate, snippet)
def validate(self): ''' Validates the template. ''' # TODO(sdake) Should return line number of invalid reference # validate overall template (top-level structure) self.t.validate() # Validate parameters self.parameters.validate(context=self.context, validate_value=self.strict_validate) # Validate Parameter Groups parameter_groups = param_groups.ParameterGroups(self.t) parameter_groups.validate() # Check duplicate names between parameters and resources dup_names = set(self.parameters.keys()) & set(self.keys()) if dup_names: LOG.debug("Duplicate names %s" % dup_names) raise exception.StackValidationFailed( message=_("Duplicate names %s") % dup_names) for res in self.dependencies: try: result = res.validate() except exception.HeatException as ex: LOG.info(ex) raise ex except Exception as ex: LOG.exception(ex) raise exception.StackValidationFailed( message=encodeutils.safe_decode(six.text_type(ex))) if result: raise exception.StackValidationFailed(message=result) for val in self.outputs.values(): try: if not val or not val.get('Value'): message = _('Each Output must contain ' 'a Value key.') raise exception.StackValidationFailed(message=message) function.validate(val.get('Value')) except AttributeError: message = _('Output validation error: ' 'Outputs must contain Output. ' 'Found a [%s] instead') % type(val) raise exception.StackValidationFailed(message=message) except Exception as ex: reason = _('Output validation error: ' '%s') % six.text_type(ex) raise exception.StackValidationFailed(message=reason)
def validate(self): ''' Validates the template. ''' # TODO(sdake) Should return line number of invalid reference # validate overall template (top-level structure) self.t.validate() # Validate parameters self.parameters.validate(context=self.context) # Validate Parameter Groups parameter_groups = param_groups.ParameterGroups(self.t) parameter_groups.validate() # Check duplicate names between parameters and resources dup_names = set(self.parameters.keys()) & set(self.keys()) if dup_names: LOG.debug("Duplicate names %s" % dup_names) raise exception.StackValidationFailed( message=_("Duplicate names %s") % dup_names) for res in self.dependencies: try: result = res.validate() except exception.HeatException as ex: LOG.info(ex) raise ex except Exception as ex: LOG.exception(ex) raise exception.StackValidationFailed( message=encodeutils.safe_decode(six.text_type(ex))) if result: raise exception.StackValidationFailed(message=result) for val in self.outputs.values(): try: if not val or not val.get('Value'): message = _('Each Output must contain ' 'a Value key.') raise exception.StackValidationFailed(message=message) function.validate(val.get('Value')) except AttributeError: message = _('Output validation error: ' 'Outputs must contain Output. ' 'Found a [%s] instead') % type(val) raise exception.StackValidationFailed(message=message) except Exception as ex: reason = _('Output validation error: ' '%s') % six.text_type(ex) raise exception.StackValidationFailed(message=reason)
def validate(self): ''' Validates the template. ''' # TODO(sdake) Should return line number of invalid reference # validate overall template (top-level structure) self.t.validate() # Validate parameters self.parameters.validate(context=self.context) # Validate Parameter Groups parameter_groups = ParameterGroups(self.t) parameter_groups.validate() # Check duplicate names between parameters and resources dup_names = set(self.parameters.keys()) & set(self.keys()) if dup_names: LOG.debug("Duplicate names %s" % dup_names) raise StackValidationFailed(message=_("Duplicate names %s") % dup_names) for res in self.dependencies: try: result = res.validate() except exception.HeatException as ex: LOG.info(ex) raise ex except Exception as ex: LOG.exception(ex) raise StackValidationFailed(message=encodeutils.safe_decode( six.text_type(ex))) if result: raise StackValidationFailed(message=result) for val in self.outputs.values(): try: if isinstance(val, six.string_types): message = _('"Outputs" must contain ' 'a map of output maps, ' 'find a string "%s".') % val raise StackValidationFailed(message=message) if not val or not val.get('Value', ''): msg = _('Every Output object must ' 'contain a Value member.') raise StackValidationFailed(message=msg) function.validate(val.get('Value', '')) except Exception as ex: reason = 'Output validation error: %s' % six.text_type(ex) raise StackValidationFailed(message=reason)
def validate(self): LOG.info(_LI('Validating %s'), six.text_type(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) try: validate = self.properties.validate( with_value=self.stack.strict_validate) except exception.StackValidationFailed as ex: path = [self.stack.t.RESOURCES, ex.path[0], self.stack.t.get_section_name(ex.path[1])] path.extend(ex.path[2:]) raise exception.StackValidationFailed( error=ex.error, path=path, message=ex.error_message) return validate
def validate(self): LOG.info(_LI('Validating %s'), six.text_type(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) try: validate = self.properties.validate( with_value=self.stack.strict_validate) except exception.StackValidationFailed as ex: path = [ self.stack.t.RESOURCES, ex.path[0], self.stack.t.get_section_name(ex.path[1]) ] path.extend(ex.path[2:]) raise exception.StackValidationFailed(error=ex.error, path=path, message=ex.error_message) return validate
def validate(self): ''' Validates the template. ''' # TODO(sdake) Should return line number of invalid reference # validate overall template (top-level structure) self.t.validate() # Validate parameters self.parameters.validate(context=self.context) # Validate Parameter Groups parameter_groups = ParameterGroups(self.t) parameter_groups.validate() # Check duplicate names between parameters and resources dup_names = set(self.parameters.keys()) & set(self.keys()) if dup_names: LOG.debug("Duplicate names %s" % dup_names) raise StackValidationFailed(message=_("Duplicate names %s") % dup_names) for res in self.dependencies: try: result = res.validate() except exception.HeatException as ex: LOG.info(ex) raise ex except Exception as ex: LOG.exception(ex) raise StackValidationFailed(message=encodeutils.safe_decode( six.text_type(ex))) if result: raise StackValidationFailed(message=result) for val in self.outputs.values(): snippet = val.get('Value', '') try: function.validate(snippet) except Exception as ex: reason = 'Output validation error: %s' % six.text_type(ex) raise StackValidationFailed(message=reason)
def validate(self): ''' Validates the template. ''' # TODO(sdake) Should return line number of invalid reference # validate overall template (top-level structure) self.t.validate() # Validate parameters self.parameters.validate(context=self.context) # Validate Parameter Groups parameter_groups = ParameterGroups(self.t) parameter_groups.validate() # Check duplicate names between parameters and resources dup_names = set(self.parameters.keys()) & set(self.keys()) if dup_names: LOG.debug("Duplicate names %s" % dup_names) raise StackValidationFailed(message=_("Duplicate names %s") % dup_names) for res in self.dependencies: try: result = res.validate() except exception.HeatException as ex: LOG.info(ex) raise ex except Exception as ex: LOG.exception(ex) raise StackValidationFailed( message=encodeutils.safe_decode(six.text_type(ex))) if result: raise StackValidationFailed(message=result) for val in self.outputs.values(): snippet = val.get('Value', '') try: function.validate(snippet) except Exception as ex: reason = 'Output validation error: %s' % six.text_type(ex) raise StackValidationFailed(message=reason)
def validate(self): """Validate the output value without resolving it.""" function.validate(self._value, VALUE)
def test_validate_func(self): self.assertIsNone(function.validate(self.func)) self.func = TestFunction(None, 'foo', ['bar']) self.assertRaisesRegex(exception.StackValidationFailed, '.foo: Need more arguments', function.validate, self.func)
def test_validate_func(self): self.assertIsNone(function.validate(self.func)) self.func = TestFunction(None, 'foo', ['bar']) ex = self.assertRaises(Exception, function.validate, self.func) self.assertEqual('Need more arguments', str(ex))
def validate(self): LOG.info(_('Validating %s') % str(self)) function.validate(self.t) self.validate_deletion_policy(self.t) return self.properties.validate()
def test_validate_func(self): self.assertIsNone(function.validate(self.func)) self.func = TestFunction(None, 'foo', ['bar']) ex = self.assertRaises(TypeError, function.validate, self.func) self.assertEqual('Need more arguments', six.text_type(ex))
def validate(self): for name, cond in six.iteritems(self._conditions): self._check_condition_type(name, cond) function.validate(cond)
def test_validate_func(self): self.assertIsNone(function.validate(self.func)) self.func = TestFunction(None, 'foo', ['bar']) self.assertRaisesRegex(exception.StackValidationFailed, 'foo: Need more arguments', function.validate, self.func)
def validate(self, path=''): """Validate the output value without resolving it.""" function.validate(self._value, path)
def validate(self): """Validate intrinsic functions that appear in the definition.""" function.validate(self._properties, PROPERTIES) function.validate(self._metadata, METADATA) function.validate(self._depends, DEPENDS_ON) function.validate(self._deletion_policy, DELETION_POLICY) function.validate(self._update_policy, UPDATE_POLICY) function.validate(self._external_id, EXTERNAL_ID)
def validate(self): LOG.info(_LI('Validating %s'), six.text_type(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) return self.properties.validate()
def validate(self): for name, cond in self._conditions.items(): self._check_condition_type(name, cond) function.validate(cond)
def validate(self): LOG.info(_('Validating %s') % str(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) return self.properties.validate()
def validate(self): LOG.info(_LI('Validating %s'), six.text_type(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) return self.properties.validate(with_value=self.stack.strict_validate)