Exemple #1
0
ci = ConnectionInformation()
ci.connection = 'local'

for i in range(NUM_TASKS):
    #for j in range(NUM_HOSTS):
    for h in hosts:
        debug("queuing %s %d" % (h, i))
        #h = Host(name="host%06d" % j)
        t = Task().load(
            dict(name="task %d" % (i, ),
                 debug="msg='hello from %s, %d'" % (h, i)))
        #t = Task().load(dict(name="task %d" % (i,), ping=""))
        #task_vars = var_manager.get_vars(loader=loader, host=h, task=t)
        task_vars = dict()
        new_t = t.copy()
        new_t.post_validate(task_vars)
        send_data((h, t, task_vars, ci))
        debug("done queuing %s %d" % (h, i))
        _process_pending_results()
    debug("waiting for the results to drain...")
    _wait_on_pending_results()

res_q.close()
res_p.terminate()

for (w_p, main_q, wrkr_q) in workers:
    main_q.close()
    wrkr_q.close()
    w_p.terminate()
Exemple #2
0
hosts = inventory.get_hosts()[:]
debug("done loading inventory")

play_context = PlayContext()
play_context.connection = 'local'

for i in range(NUM_TASKS):
   #for j in range(NUM_HOSTS):
   for h in hosts:
      debug("queuing %s %d" % (h, i))
      #h = Host(name="host%06d" % j)
      t = Task().load(dict(name="task %d" % (i,), debug="msg='hello from %s, %d'" % (h,i)))
      #t = Task().load(dict(name="task %d" % (i,), ping=""))
      #task_vars = var_manager.get_vars(loader=loader, host=h, task=t)
      task_vars = dict()
      new_t = t.copy()
      new_t.post_validate(task_vars)
      send_data((h, t, task_vars, play_context))
      debug("done queuing %s %d" % (h, i))
      _process_pending_results()
   debug("waiting for the results to drain...")
   _wait_on_pending_results()

res_q.close()
res_p.terminate()

for (w_p, main_q, wrkr_q) in workers:
   main_q.close()
   wrkr_q.close()
   w_p.terminate()