Hi everyone,

What's the equivalent of fabric.tasks.execute in the new API? One
convenience of that function is, you can create a task assuming that you're
working on only one host at a time and then seamlessly execute it across a
list of hosts. For ex,

from fabric.api import runfrom fabric.tasks import execute

def do_something():
    uptime_result = run("uptime").stdout
    # Do more with uptime_result later in code. if __name__ == "__main__":
    execute(do_something, hosts=["username@host"])

When working on multiple hosts, I know we've a
fabric.group.ThreadingGroup which
has a run method
<http://docs.fabfile.org/en/2.0/api/group.html?highlight=ThreadingGroup#fabric.group.Group.run>
but this forces us handle fabric.group.GroupResult which means handling
outputs of all hosts in one place which is added complexity. For ex,

try:
    results = connections_array.run('pidof foobar', hide="both")except
GroupException as e:
    results = e.result
pids = []for _, result in results.items():
    # do what I want. capture outputs of various connections in above array.

# Reusing of previous outputs in series of operations gets hard. # Do
second operations by capturing previous output.



Any suggestions on how to make the new API friendly to use when using
multiple hosts?

-- 
Cheers,
Abhijeet Rastogi (shadyabhi)
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to