Add the correct logic to execute queries from the command line

This commit is contained in:
Thomas S Hatch 2011-03-11 13:23:01 -07:00
parent a8ec3697c7
commit ad19593d12

View File

@ -46,12 +46,6 @@ class SaltCMD(object):
help='Execute a salt command query, this can be used to find'\
+ ' previous function calls, of to look up a call that'\
+ ' occured at a specific time.')
parser.add_option('-c',
'--cmd',
dest='cmd',
default='',
help='Used with the Query option, pass in the command to get'\
+ ' results from.')
options, args = parser.parse_args()
@ -61,7 +55,12 @@ class SaltCMD(object):
opts['pcre'] = options.pcre
if options.query:
opts['query'] = options.query
opts['cmd'] = options.cmd
if len(args) < 1:
err = 'Please pass in a command to query the old salt calls'\
+ ' for.'
sys.stderr.write(err, + '\n')
sys.exit('2')
opts['cmd'] = args[0]
else:
opts['tgt'] = args[0]
opts['fun'] = args[1]
@ -73,9 +72,10 @@ class SaltCMD(object):
'''
Execute the salt command line
'''
if opts['query']:
cli =
local = salt.client.LocalClient()
if self.opts['query']:
print local.find_cmd(self.opts['cmd'])
else:
args = [self.opts['tgt'],
self.opts['fun'],
self.opts['arg'],