Use python functions instead of shell pipes
Merge pull request #18750 from rallytime/core_grains

Use python functions instead of shell pipes