|
From: | Abhijeet Rastogi |
Subject: | Re: [Fab-user] How to gracefully/elegantly collect data about failed hosts when using fabric.api.execute? (v1) |
Date: | Thu, 17 May 2018 22:38:11 +0530 |
You need to have your worker function catch any exceptions (https://github.com/fabric/fabric/blob/1.14/fabric/exceptions.py) and evaluate success/failure, then return a value useful to you in determining if your task was successful. Returning "None" for failure modes is something I've done before.On Thu, May 17, 2018 at 11:15 AM Abhijeet Rastogi <address@hidden> wrote:Anyone? I was hoping if someone can help me with this.On Wed, May 16, 2018 at 9:03 PM Abhijeet Rastogi <address@hidden> wrote:Hi everyone,Let's suppose I have a simple code like this.from fabric.api import run, env, execute from fabric import state env.use_ssh_config = True env.parallel = True hosts = ['success.host', 'failure.host'] def get_uptime(): output = run("uptime") return output collected_output = execute(get_uptime, hosts=hosts) for host, output in collected_output.iteritems(): if output is not None: print("{0}:\n{1}".format(host, output))
How do I continue my execution of code beyond execute method invocation to print successful hosts output and also give a summary of failed hosts?I don't want to fabric library to show warnings or exit code when that happens. I read about envenv.abort_exception but I'm not sure how to use that to do both things, capture output of successful tasks and show failed hosts as that exception doesn't have any arguments.Any help is appreciated--Cheers,
Abhijeet Rastogi (shadyabhi)--Cheers,_______________________________________________
Abhijeet Rastogi (shadyabhi)
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user
[Prev in Thread] | Current Thread | [Next in Thread] |