Esempio n. 1
0
    def check_immutable_params(cls, ref, keys=None):
        """Raise exception when disallowed parameter is stored in the keys

        Check whether the ref dictionary representing a request has only
        mutable parameters included. If not, raise an exception. This method
        checks only root-level keys from a ref dictionary.

        :param ref: a dictionary representing deserialized request to be
                    stored
        :param keys: a set with mutable parameters. If None, use default class
                     attribute - _mutable_parameters
        :raises exception.ImmutableAttributeError

        """
        if keys is None:
            keys = cls._mutable_parameters

        ref_keys = set(ref.keys())
        blocked_keys = ref_keys.difference(keys)

        if not blocked_keys:
            #No immutable parameters changed
            return

        exception_args = {'target': cls.__name__,
                          'attribute': blocked_keys.pop()}
        raise exception.ImmutableAttributeError(**exception_args)
Esempio n. 2
0
    def check_immutable_params(cls, ref):
        """Raise exception when disallowed parameter is in ref.

        Check whether the ref dictionary representing a request has only
        mutable parameters included. If not, raise an exception. This method
        checks only root-level keys from a ref dictionary.

        :param ref: a dictionary representing deserialized request to be
                    stored
        :raises: :class:`keystone.exception.ImmutableAttributeError`

        """
        ref_keys = set(ref.keys())
        blocked_keys = ref_keys.difference(cls._mutable_parameters)

        if not blocked_keys:
            # No immutable parameters changed
            return

        exception_args = {'target': cls.__name__,
                          'attributes': ', '.join(blocked_keys)}
        raise exception.ImmutableAttributeError(**exception_args)