Add grains lookup to the salt-call command

This commit is contained in:
Thomas S Hatch 2011-04-29 16:53:59 -06:00
parent a09fc4584e
commit 444714d161
2 changed files with 15 additions and 5 deletions

View File

@ -383,12 +383,12 @@ class SaltCall(object):
'''
parser = optparse.OptionParser()
parser.add_option('-s',
'--stats',
dest='stats',
parser.add_option('-g',
'--grains',
dest='grains',
default=False,
action='store_true',
help='Return all of the basic salt call data')
help='Return the information generated by the salt grains')
parser.add_option('-m',
'--module-dirs',
dest='module_dirs',
@ -407,7 +407,7 @@ class SaltCall(object):
opts = {}
opts['stats'] = options.stats
opts['grains'] = options.grains
opts['module_dirs'] = options.module_dirs.split(',')
opts['doc'] = options.doc
if len(args) >= 1:

View File

@ -45,12 +45,22 @@ class Caller(object):
print docs[name]
print ''
def print_grains(self):
'''
Print out the grains
'''
grains = salt.loader.grains()
for grain in sorted(grains):
print grain + ': ' + grains[grain]
def run(self):
'''
Execute the salt call logic
'''
if self.opts['doc']:
self.print_docs()
elif self.opts['grains']:
self.print_grains()
else:
print self.call()