开发者

How to catch auth errors in Fabric and retry?

开发者 https://www.devze.com 2023-02-20 12:30 出处:网络
I have two userna开发者_如何学JAVAmes and corresponding passwords that I use to admin my servers, is there a way to have my fab scripts/modules, use one and then the second if the first one failed, wi

I have two userna开发者_如何学JAVAmes and corresponding passwords that I use to admin my servers, is there a way to have my fab scripts/modules, use one and then the second if the first one failed, with out having to maintain a full list of credentials for each host or even group of them.

I see no way in the docs to doa try/except around run() or similar...


run and other commands raise SystemExit

from fabric.api import run,cd,put,sudo,settings

def do_stuff():
    run('ls derp')

try:
    with(settings(host_string='%s@localhost' % first_user,password = first_password)):
        do_stuff()
except SystemExit:
    with(settings(host_string='%s@localhost' % second_user,password = second_password)):
        do_stuff()
0

精彩评论

暂无评论...
验证码 换一张
取 消