def update(clear=False, mine_functions=None):
    '''
    Execute the configured functions and send the data back up to the master.
    The functions to be executed are merged from the master config, pillar and
    minion config under the option `mine_functions`:

    .. code-block:: yaml

        mine_functions:
          network.ip_addrs:
            - eth0
          disk.usage: []

    This function accepts the following arguments:

    clear: False
        Boolean flag specifying whether updating will clear the existing
        mines, or will update. Default: `False` (update).

    mine_functions
        Update the mine data on certain functions only.
        This feature can be used when updating the mine for functions
        that require refresh at different intervals than the rest of
        the functions specified under `mine_functions` in the
        minion/master config or pillar.
        A potential use would be together with the `scheduler`, for example:

        .. code-block:: yaml

            schedule:
              lldp_mine_update:
                function: mine.update
                kwargs:
                    mine_functions:
                      net.lldp: []
                hours: 12

        In the example above, the mine for `net.lldp` would be refreshed
        every 12 hours, while  `network.ip_addrs` would continue to be updated
        as specified in `mine_interval`.

    The function cache will be populated with information from executing these
    functions

    CLI Example:

    .. code-block:: bash

        salt '*' mine.update
    '''
    m_data = {}
    if not mine_functions:
        m_data = __salt__['config.merge']('mine_functions', {})
        # If we don't have any mine functions configured, then we should just bail out
        if not m_data:
            return
    elif mine_functions and isinstance(mine_functions, list):
        m_data = dict((fun, {}) for fun in mine_functions)
    elif mine_functions and isinstance(mine_functions, dict):
        m_data = mine_functions
    else:
        return

    data = {}
    for func in m_data:
        try:
            if m_data[func] and isinstance(m_data[func], dict):
                mine_func = m_data[func].pop('mine_function', func)
                if not _mine_function_available(mine_func):
                    continue
                data[func] = __salt__[mine_func](**m_data[func])
            elif m_data[func] and isinstance(m_data[func], list):
                mine_func = func
                if isinstance(m_data[func][0], dict) and 'mine_function' in m_data[func][0]:
                    mine_func = m_data[func][0]['mine_function']
                    m_data[func].pop(0)

                if not _mine_function_available(mine_func):
                    continue
                data[func] = __salt__[mine_func](*m_data[func])
            else:
                if not _mine_function_available(func):
                    continue
                data[func] = __salt__[func]()
        except Exception:
            trace = traceback.format_exc()
            log.error('Function %s in mine_functions failed to execute', func)
            log.debug('Error: %s', trace)
            continue
    if __opts__['file_client'] == 'local':
        if not clear:
            old = __salt__['data.get']('mine_cache')
            if isinstance(old, dict):
                old.update(data)
                data = old
        return __salt__['data.update']('mine_cache', data)
    load = {
            'cmd': '_mine',
            'data': data,
            'id': __opts__['id'],
            'clear': clear,
    }
    return _mine_send(load, __opts__)
def update ( clear = False , mine_functions = None ) : m_data = { } if not mine_functions : m_data = __salt__ [ 'config.merge' ] ( 'mine_functions' , { } ) if not m_data : return elif mine_functions and isinstance ( mine_functions , list ) : m_data = dict ( ( fun , { } ) for fun in mine_functions ) elif mine_functions and isinstance ( mine_functions , dict ) : m_data = mine_functions else : return data = { } for func in m_data : try : if m_data [ func ] and isinstance ( m_data [ func ] , dict ) : mine_func = m_data [ func ] . pop ( 'mine_function' , func ) if not _mine_function_available ( mine_func ) : continue data [ func ] = __salt__ [ mine_func ] ( ** m_data [ func ] ) elif m_data [ func ] and isinstance ( m_data [ func ] , list ) : mine_func = func if isinstance ( m_data [ func ] [ 0 ] , dict ) and 'mine_function' in m_data [ func ] [ 0 ] : mine_func = m_data [ func ] [ 0 ] [ 'mine_function' ] m_data [ func ] . pop ( 0 ) if not _mine_function_available ( mine_func ) : continue data [ func ] = __salt__ [ mine_func ] ( * m_data [ func ] ) else : if not _mine_function_available ( func ) : continue data [ func ] = __salt__ [ func ] ( ) except Exception : trace = traceback . format_exc ( ) log . error ( 'Function %s in mine_functions failed to execute' , func ) log . debug ( 'Error: %s' , trace ) continue if __opts__ [ 'file_client' ] == 'local' : if not clear : old = __salt__ [ 'data.get' ] ( 'mine_cache' ) if isinstance ( old , dict ) : old . update ( data ) data = old return __salt__ [ 'data.update' ] ( 'mine_cache' , data ) load = { 'cmd' : '_mine' , 'data' : data , 'id' : __opts__ [ 'id' ] , 'clear' : clear , } return _mine_send ( load , __opts__ )
Execute the configured functions and send the data back up to the master.
    The functions to be executed are merged from the master config, pillar and
    minion config under the option `mine_functions`:

    .. code-block:: yaml

        mine_functions:
          network.ip_addrs:
            - eth0
          disk.usage: []

    This function accepts the following arguments:

    clear: False
        Boolean flag specifying whether updating will clear the existing
        mines, or will update. Default: `False` (update).

    mine_functions
        Update the mine data on certain functions only.
        This feature can be used when updating the mine for functions
        that require refresh at different intervals than the rest of
        the functions specified under `mine_functions` in the
        minion/master config or pillar.
        A potential use would be together with the `scheduler`, for example:

        .. code-block:: yaml

            schedule:
              lldp_mine_update:
                function: mine.update
                kwargs:
                    mine_functions:
                      net.lldp: []
                hours: 12

        In the example above, the mine for `net.lldp` would be refreshed
        every 12 hours, while  `network.ip_addrs` would continue to be updated
        as specified in `mine_interval`.

    The function cache will be populated with information from executing these
    functions

    CLI Example:

    .. code-block:: bash

        salt '*' mine.update