1""" 2A runner to access data from the salt mine 3""" 4 5import logging 6 7import salt.daemons.masterapi 8 9log = logging.getLevelName(__name__) 10 11 12def get(tgt, fun, tgt_type="glob"): 13 """ 14 Gathers the data from the specified minions' mine, pass in the target, 15 function to look up and the target type 16 17 CLI Example: 18 19 .. code-block:: bash 20 21 salt-run mine.get '*' network.interfaces 22 """ 23 masterapi = salt.daemons.masterapi.RemoteFuncs(__opts__) 24 load = { 25 "id": __opts__["id"], 26 "fun": fun, 27 "tgt": tgt, 28 "tgt_type": tgt_type, 29 } 30 ret = masterapi._mine_get(load) 31 return ret 32 33 34def update(tgt, tgt_type="glob", clear=False, mine_functions=None): 35 """ 36 .. versionadded:: 2017.7.0 37 38 Update the mine data on a certain group of minions. 39 40 tgt 41 Which minions to target for the execution. 42 43 tgt_type: ``glob`` 44 The type of ``tgt``. 45 46 clear: ``False`` 47 Boolean flag specifying whether updating will clear the existing 48 mines, or will update. Default: ``False`` (update). 49 50 mine_functions 51 Update the mine data on certain functions only. 52 This feature can be used when updating the mine for functions 53 that require refresh at different intervals than the rest of 54 the functions specified under ``mine_functions`` in the 55 minion/master config or pillar. 56 57 CLI Example: 58 59 .. code-block:: bash 60 61 salt-run mine.update '*' 62 salt-run mine.update 'juniper-edges' tgt_type='nodegroup' 63 """ 64 ret = __salt__["salt.execute"]( 65 tgt, 66 "mine.update", 67 tgt_type=tgt_type, 68 clear=clear, 69 mine_functions=mine_functions, 70 ) 71 return ret 72