def wheel(self, clear_load):
        '''
        Send a master control function back to the wheel system
        '''
        # All wheel ops pass through eauth
        auth_type, err_name, key, sensitive_load_keys = self._prep_auth_info(clear_load)

        # Authenticate
        auth_check = self.loadauth.check_authentication(clear_load, auth_type, key=key)
        error = auth_check.get('error')

        if error:
            # Authentication error occurred: do not continue.
            return {'error': error}

        # Authorize
        username = auth_check.get('username')
        if auth_type != 'user':
            wheel_check = self.ckminions.wheel_check(
                auth_check.get('auth_list', []),
                clear_load['fun'],
                clear_load.get('kwarg', {})
            )
            if not wheel_check:
                return {'error': {'name': err_name,
                                  'message': 'Authentication failure of type "{0}" occurred for '
                                             'user {1}.'.format(auth_type, username)}}
            elif isinstance(wheel_check, dict) and 'error' in wheel_check:
                # A dictionary with an error name/message was handled by ckminions.wheel_check
                return wheel_check

            # No error occurred, consume sensitive settings from the clear_load if passed.
            for item in sensitive_load_keys:
                clear_load.pop(item, None)
        else:
            if 'user' in clear_load:
                username = clear_load['user']
                if salt.auth.AuthUser(username).is_sudo():
                    username = self.opts.get('user', 'root')
            else:
                username = salt.utils.user.get_user()

        # Authorized. Do the job!
        try:
            jid = salt.utils.jid.gen_jid(self.opts)
            fun = clear_load.pop('fun')
            tag = tagify(jid, prefix='wheel')
            data = {'fun': "wheel.{0}".format(fun),
                    'jid': jid,
                    'tag': tag,
                    'user': username}

            self.event.fire_event(data, tagify([jid, 'new'], 'wheel'))
            ret = self.wheel_.call_func(fun, full_return=True, **clear_load)
            data['return'] = ret['return']
            data['success'] = ret['success']
            self.event.fire_event(data, tagify([jid, 'ret'], 'wheel'))
            return {'tag': tag,
                    'data': data}
        except Exception as exc:
            log.error('Exception occurred while introspecting %s: %s', fun, exc)
            data['return'] = 'Exception occurred in wheel {0}: {1}: {2}'.format(
                             fun,
                             exc.__class__.__name__,
                             exc,
            )
            data['success'] = False
            self.event.fire_event(data, tagify([jid, 'ret'], 'wheel'))
            return {'tag': tag,
                    'data': data}
def wheel ( self , clear_load ) : auth_type , err_name , key , sensitive_load_keys = self . _prep_auth_info ( clear_load ) auth_check = self . loadauth . check_authentication ( clear_load , auth_type , key = key ) error = auth_check . get ( 'error' ) if error : return { 'error' : error } username = auth_check . get ( 'username' ) if auth_type != 'user' : wheel_check = self . ckminions . wheel_check ( auth_check . get ( 'auth_list' , [ ] ) , clear_load [ 'fun' ] , clear_load . get ( 'kwarg' , { } ) ) if not wheel_check : return { 'error' : { 'name' : err_name , 'message' : 'Authentication failure of type "{0}" occurred for ' 'user {1}.' . format ( auth_type , username ) } } elif isinstance ( wheel_check , dict ) and 'error' in wheel_check : return wheel_check for item in sensitive_load_keys : clear_load . pop ( item , None ) else : if 'user' in clear_load : username = clear_load [ 'user' ] if salt . auth . AuthUser ( username ) . is_sudo ( ) : username = self . opts . get ( 'user' , 'root' ) else : username = salt . utils . user . get_user ( ) try : jid = salt . utils . jid . gen_jid ( self . opts ) fun = clear_load . pop ( 'fun' ) tag = tagify ( jid , prefix = 'wheel' ) data = { 'fun' : "wheel.{0}" . format ( fun ) , 'jid' : jid , 'tag' : tag , 'user' : username } self . event . fire_event ( data , tagify ( [ jid , 'new' ] , 'wheel' ) ) ret = self . wheel_ . call_func ( fun , full_return = True , ** clear_load ) data [ 'return' ] = ret [ 'return' ] data [ 'success' ] = ret [ 'success' ] self . event . fire_event ( data , tagify ( [ jid , 'ret' ] , 'wheel' ) ) return { 'tag' : tag , 'data' : data } except Exception as exc : log . error ( 'Exception occurred while introspecting %s: %s' , fun , exc ) data [ 'return' ] = 'Exception occurred in wheel {0}: {1}: {2}' . format ( fun , exc . __class__ . __name__ , exc , ) data [ 'success' ] = False self . event . fire_event ( data , tagify ( [ jid , 'ret' ] , 'wheel' ) ) return { 'tag' : tag , 'data' : data }
Send a master control function back to the wheel system