fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] simple test loop.


From: Jeff Forcier
Subject: Re: [Fab-user] simple test loop.
Date: Tue, 19 Oct 2010 11:01:56 -0400

There's actually a built-in reboot function in Fabric which does the
right things regarding the connection objects,
fabric.operations.reboot (it's part of fabric.api, as usual). You
might want to look into using that.

If you need to tweak how it works or just use it for a reference,
here's the code:

    http://github.com/bitprophet/fabric/blob/0.9/fabric/operations.py#L620

-Jeff

On Tue, Oct 19, 2010 at 10:54 AM, Jeff Honey <address@hidden> wrote:
> In an effort to do a rudimentary test before moving onto the next host, I've 
> nested one function inside another. I put a file on the host, reboot it, and 
> then test if I can pull it back down. When I can, move to the next host in 
> the loop.
>
> ...in fabfile.py:
> <snip>
> def is_ready():
>  with settings(warn_only=True):
>  get('/tmp/ready.txt','~/')
>
> def reboot():
>  for host in env.roledefs['test']:
>  with settings(host_string=host):
>   put('ready.txt','/tmp/')
>   run('shutdown -r now')
>   while not is_ready():
>    time.sleep(60)
>   return True
> </snip>
>
> ...the resultant error:
> <snip>
> Traceback (most recent call last):
>  File "c:\python26\lib\site-packages\fabric\main.py", line 537, in main 
> commands[name](*args, **kwargs)
>  File "C:\Users\foo\Desktop\fabfile.py", line 41, in reboot while not 
> is_ready():
>  File "C:\Users\foo\Desktop\fabfile.py", line 30, in is_ready 
> get('/tmp/ready.txt','~/')
>  File "C:\Python26\lib\contextlib.py", line 34, in __exit__ 
> self.gen.throw(type, value, traceback)
>  File "C:\Python26\lib\contextlib.py", line 113, in nested yield vars
>  File "C:\Users\foo\Desktop\fabfile.py", line 30, in is_ready 
> get('/tmp/ready.txt','~/')
>  File "c:\python26\lib\site-packages\fabric\network.py", line 391, in 
> host_prompting_wrapper return func(*args, **kwargs)
>  File "c:\python26\lib\site-packages\fabric\operations.py", line 372, in get 
> _handle_failure(message=msg % remote_path, exception=e)
>  File "C:\Python26\lib\contextlib.py", line 153, in __exit__ 
> self.thing.close()
> AttributeError: 'NoneType' object has no attribute 'close'
> Disconnecting from host... done.
> </snip>
>
> Am I even on the right track?
> --
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> ¤ kyoboku kazeoshi ¤
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]