def __init__(self): """ MultiJob constructor """ self._jobs = {} self.client = APIClient(opts=MASTER_OPTIONS) self.handler = Handler()
def runner_manage_present_async(self): ''' Make a call to runner.manage.present and test against returned SSE data ''' self.app.post_json('/run', dict(client='master', fun='runner.manage.present', kwarg={}), headers=self.headers) keep_looping = True client = APIClient() sse = None while keep_looping: sse = client.get_event(wait=5, tag='salt/', full=True) keep_looping = False self.assertNotEqual(sse, None)
def runner_manage_present_datastructure(self): ''' Make a call to runner.manage.present and test data structure integrity ''' resp = self.app.post_json('/run', dict(client='master', fun='runner.manage.present', kwarg={}), headers=self.headers) tag = resp.json_body['return'][0]['tag'] client = APIClient() data = None while not data: sse = client.get_event(wait=0.01, tag='salt/', full=True) if sse['tag'] == '%s/ret' % tag: data = sse['data']['return'] self.assertNotEqual(data, None)
from salt.client.api import APIClient client = APIClient() mine_args = ('roles:ambari', 'host', 'grain') resp = client.localClient.cmd('roles:ambari-server', 'mine.get', arg=mine_args, expr_form='grain') hosts = resp.values()[0].values() for host in hosts: print host