コード例 #1
0
    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))
コード例 #2
0
    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))
コード例 #3
0
ファイル: test_function.py プロジェクト: COSHPC/heat
    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))
コード例 #4
0
    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))
コード例 #5
0
    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))
コード例 #6
0
ファイル: test_function.py プロジェクト: ilivessevili/heat
    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))
コード例 #7
0
ファイル: test_function.py プロジェクト: aaratn/heat
    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)
コード例 #8
0
    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)
コード例 #9
0
ファイル: stack.py プロジェクト: BeenzSyed/heat
    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)
コード例 #10
0
ファイル: stack.py プロジェクト: andersonvom/heat
    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)
コード例 #11
0
ファイル: stack.py プロジェクト: devdattakulkarni/heat
    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)
コード例 #12
0
ファイル: resource.py プロジェクト: aawm/heat
    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
コード例 #13
0
    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
コード例 #14
0
ファイル: stack.py プロジェクト: andrew2king/heat
    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)
コード例 #15
0
    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)
コード例 #16
0
ファイル: output.py プロジェクト: okozachenko1203/heat
 def validate(self):
     """Validate the output value without resolving it."""
     function.validate(self._value, VALUE)
コード例 #17
0
 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)
コード例 #18
0
 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))
コード例 #19
0
ファイル: output.py プロジェクト: aaratn/heat
 def validate(self):
     """Validate the output value without resolving it."""
     function.validate(self._value, VALUE)
コード例 #20
0
ファイル: resource.py プロジェクト: HuaiJiang/heat
    def validate(self):
        LOG.info(_('Validating %s') % str(self))

        function.validate(self.t)
        self.validate_deletion_policy(self.t)
        return self.properties.validate()
コード例 #21
0
 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))
コード例 #22
0
ファイル: conditions.py プロジェクト: aaratn/heat
 def validate(self):
     for name, cond in six.iteritems(self._conditions):
         self._check_condition_type(name, cond)
         function.validate(cond)
コード例 #23
0
ファイル: test_function.py プロジェクト: aaratn/heat
 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)
コード例 #24
0
 def validate(self, path=''):
     """Validate the output value without resolving it."""
     function.validate(self._value, path)
コード例 #25
0
ファイル: rsrc_defn.py プロジェクト: wxy8961230/heat
 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)
コード例 #26
0
 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))
コード例 #27
0
    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()
コード例 #28
0
ファイル: output.py プロジェクト: sdake/heat
 def validate(self, path=''):
     """Validate the output value without resolving it."""
     function.validate(self._value, path)
コード例 #29
0
 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))
コード例 #30
0
 def validate(self):
     for name, cond in self._conditions.items():
         self._check_condition_type(name, cond)
         function.validate(cond)
コード例 #31
0
ファイル: resource.py プロジェクト: sirushtim/heat
    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()
コード例 #32
0
ファイル: resource.py プロジェクト: zzxwill/heat
    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)