def _set_function(self, function):
        '''
        Based on the configuration, set to execute an old or a new function.
        :return:
        '''
        full_name = "{m_name}.{f_name}".format(
            m_name=self._globals.get(self.MODULE_NAME, '') or self._globals['__name__'].split('.')[-1],
            f_name=function.__name__)
        if full_name.startswith("."):
            self._raise_later = CommandExecutionError('Module not found for function "{f_name}"'.format(
                f_name=function.__name__))

        opts = self._globals.get('__opts__', '{}')
        pillar = self._globals.get('__pillar__', '{}')

        use_deprecated = (full_name in opts.get(self.CFG_USE_DEPRECATED, list()) or
                          full_name in pillar.get(self.CFG_USE_DEPRECATED, list()))

        use_superseded = (full_name in opts.get(self.CFG_USE_SUPERSEDED, list()) or
                          full_name in pillar.get(self.CFG_USE_SUPERSEDED, list()))

        if use_deprecated and use_superseded:
            raise SaltConfigurationError("Function '{0}' is mentioned both in deprecated "
                                         "and superseded sections. Please remove any of that.".format(full_name))
        old_function = self._globals.get(self._with_name or "_{0}".format(function.__name__))
        if self._policy == self.OPT_IN:
            self._function = function if use_superseded else old_function
        else:
            self._function = old_function if use_deprecated else function