Add salt.utils.master with class MasterPillarUtil. Change salt.runners.c...

"Add salt.utils.master with class MasterPillarUtil. Change salt.runners.cache to use salt.utils.master.MasterPillarUtil"

This is my first contribution to salt and I am opening this pull request in the hopes of getting feedback for code improvement as well as advice on how to write tests to cover this new salt.util module. I'm a python and salt novice, so I can use all the help I can get!

When I first started writing my salt formulas to manage my infrastructure, I ran into an issue where I needed to make a decision based on pillar data from multiple minions without each minion having access to the others data. The seemingly obvious solution was to write a custom runner module on my salt master...

Unfortunately I learned that there was no easy way to get a minion's pillar data other than asking the minion for that data using the "pillar" execution module. This did not seem like a wise choice for a runner module to trust a minion when the runner may be making important decisions based on that data (paranoia is good, right?). I was also not able to take advantage of any cached minion data that may already be on the master (after all, I already have minion_data_cache: True).

I decided to create salt.utils.master as a place that can contain master-only helper utilities that can be used in any code that runs on the master - hopefully this is the proper/preferred location for my code. In salt.utils.master, there is a class called MasterPillarUtil that provides an easy way to get grain and pillar data for targeted minions when run on the master. I also rewrote the salt.runners.cache functions to illustrate how MasterPillarUtil can be used within a runner - in this case, only getting the cached minion data without falling back to fetching the grains/pillar on demand if they are not cached. The salt.runners.cache functions maintain backward compatibility with the previous code.

I am unsure on how I can write tests for the MasterPillarUtil - I would appreciate any pointers on how to get started here.

David Anderson (dave_den on #salt)