Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Updated runner to use the new RunnerClient
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteinge committed Oct 9, 2012
1 parent 84640ee commit f7b270a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions saltapi/netapi/rest_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import salt.client
import salt.runner
import saltapi.loader
import salt.utils

def __virtual__():
'''
Expand All @@ -28,8 +28,8 @@ class SaltAPI(MethodView):
'''
def __init__(self, app, *args, **kwargs):
self.app = app
self.runners = saltapi.loader.runner(__opts__)
self.local = salt.client.LocalClient(__opts__['conf_file'])
self.runner = salt.runner.RunnerClient(__opts__)

class JobsView(SaltAPI):
'''
Expand All @@ -39,14 +39,14 @@ def get_job_by_jid(self, jid):
'''
Return information on a previously run job
'''
ret = self.runners['jobs.lookup_jid'](jid)
ret = self.runner.cmd('jobs.lookup_jid', [jid])
return jsonify(ret)

def get_jobs_list(self):
'''
Return a previously run jobs
'''
ret = self.runners['jobs.list_jobs']()
ret = self.runner.cmd('jobs.list_jobs', [])
return jsonify(ret)

def get(self, jid=None):
Expand Down Expand Up @@ -97,18 +97,17 @@ def get(self):
'''
Return all available runners
'''
return jsonify({'runners': self.runners.keys()})
return jsonify({'runners': self.runner.functions.keys()})

def post(self):
'''
Execute runner commands
'''
cmd = request.form['cmd']
fun = request.form.get('fun')
arg = request.form.get('arg')

if not cmd in self.runners:
raise exceptions.BadRequest("Runner '{0}' not found".format(cmd))

ret = self.runners[cmd]()
# pylint: disable-msg=W0142
ret = self.runner.cmd(fun, arg)
return jsonify({'return': ret})

def build_app():
Expand Down

0 comments on commit f7b270a

Please sign in to comment.