saltstack/salt — pull request #17106 by mgwilliams (2014-11-03 13:52:02+00:00)
Title: add function to loader for loading utility modules (_utils)

This allows for generic shared code to be loaded on both master and minion. Like salt.utils, but third party. It also makes it possible to access util functions by key.

Example usage in a runner:

```python
# Import salt libs
import salt.loader

# cache the utility modules
UTILS = None

def _utils():
'''
Load the utility modules exactly once.
'''
global UTILS

if UTILS is None:
UTILS = salt.loader.utils(__opts__)

return UTILS

def page(*args, pager='pagerduty'):
utils = _utils()
utils['{0}.page'.format(pager)](*args)
```