mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add grains lookup to the salt-call command
This commit is contained in:
parent
a09fc4584e
commit
444714d161
@ -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:
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user