[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] Passing host IP addresses to Fabric tasks from other Pyth
From: |
Samuli Seppänen |
Subject: |
Re: [Fab-user] Passing host IP addresses to Fabric tasks from other Python classes |
Date: |
Wed, 28 Sep 2011 10:17:51 +0300 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 |
Hi Jeff,
>> However, I've been so far unable to dynamically pass on a host's
>> IP-address from an external Python class to the class/file containing
>> the actual Fabric tasks.
> Can you elaborate on this? For one thing, if you weren't aware, Fabric
> (0.9.2+) has callable roledefs that let you defer generation of host
> lists to runtime:
>
> http://docs.fabfile.org/en/1.2.2/usage/execution.html#roles (last
> para in section)
>
> If callable roles doesn't suffice, you can use Fabric as a library and
> skip a lot of its own setup mechanisms/assumptions. Library use is
> deceptively simple:
>
> http://docs.fabfile.org/en/1.2.2/usage/library.html
>
> So taking your "external" list of IPs and transforming them into some
> form of "set env.host_string, call functions that use API commands"
> *should* be pretty workable unless there's mitigating circumstances.
The idea is that a "launcher" threads launches a number of VMs and then
starts polling for VMs that have booted up. When it finds one, it puts
it to a queue. Simultaneously a number of s.c. "configurer" threads
monitor the same queue. When a new VM is added, one configurer thread
pulls it from the queue and launches Fabric for that host/IP.
I tried the "Using Fabric as a library" approach, but it failed. Either
I messed something up, or 0.9.3 has some issues. I'll upgrade and see
what happens.
> Re: threading: Fabric 1.3 should be out this week and contains a new
> parallel execution mode leveraging multiprocessing. It might be worth
> looking at in case you can find a way to shoehorn your needs into that
> execution model. (FWIW, it's heavily task-based and 'fab'-based right
> now, but even so.)
I take it the 1.3 code is in "master" branch in Git? Fabric-vise my
needs are simple, so it should work just fine.
> Hope that helps,
> Jeff
>
It did, thanks!
Samuli