fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Calling Fabric from Python


From: Xavier Ordoquy
Subject: Re: [Fab-user] Calling Fabric from Python
Date: Sat, 18 Sep 2010 16:50:55 +0200

Hi Philipp,

I must say I'm using Fabric for much more than just a ssh abstraction.
I'm using it to deploy projects and I'd like to skip the command line part and fully automate it. I'm also using the template engine.
However, I'm not willing to do an external call to a system command since I'm in a virtual env which would make things too tricky.

Regards,
Xavier.

Le 18 sept. 2010 à 16:18, Philipp Keller a écrit :

Hi Xavier

I tried the same thing, that's what I came up with:

env.host_string = servername
run('cat /proc/loadavg | cut -d' ' -f1')

I asked that on stackoverflow if there is a better way for that:

I didn't get any answers - I probably should have asked here.
From looking at the code it looks as if fabric isn't designed as "ssh abstraction" - but should be primarily used from the command line.
e.g. run() is closely coupled to the rest of fabrics infrastructure (such as env, or writing to stdout, or asking for password).

I personally hoped I was finding an "ssh abstraction" because paramiko is too low level, but fabric doesn't seem to allow me to just use run or sudo without using also the rest of the environment - is that correct, Jeff?

I am somehow puzzled because on fabrics homepage I read:

In addition to use via the fab fool, Fabric’s components may be imported into other Python code, providing a Pythonic interface to the SSH protocol suite at a higher level than that provided by e.g. Paramiko (which Fabric itself leverages.)

Greets
Philipp


On Sat, Sep 18, 2010 at 3:26 PM, Xavier Ordoquy <address@hidden> wrote:
Hi,

Unfortunately, I have already read the documentation but might have missed or didn't understood something.

Currently, my biggest issue is:

>>> from fabric.api import env, run
>>> env.user = 'root'
>>> env.hosts = ['whatever',]
>>> env.host = 'whatever'
>>> def test():
...     run('uname -a')
...
>>> test()
No hosts found. Please specify (single) host string for connection:

If I put that in a fabfile.py and run a fab test it will work.

Regards,
Xavier.

Le 18 sept. 2010 à 14:58, Jeff Forcier a écrit :

> Hi Xavier,
>
> Make sure you read the documentation[1]; it does need more work
> regarding library use, but you can still get very far just by reading
> the usage docs, especially the one on execution.
>
> Best,
> Jeff
>
> [1] http://docs.fabfile.org/
>
>
> On Sat, Sep 18, 2010 at 7:20 AM, Xavier Ordoquy <address@hidden> wrote:
>> Hi,
>>
>> I have been using Fabric for some time now and I am very happy with the help it provides for system administration.
>> However, I'd like to go one step furtherand couple fabric together with a python script - ie calling fabric from my own scripts.
>> I'm getting a real hard time understanding how I can start tasks from my python script, esp settings things such as hosts, users and so on.
>>
>> I didn't manage to find something on the net about using fabric from within python.
>> Maybe someone has a link, a blog entry or whatever to help me getting started ?
>>
>> Regards,
>> Xavier.
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>
>
>
>
> --
> Jeff Forcier
> Unix sysadmin; Python/Ruby developer
> http://bitprophet.org


_______________________________________________
Fab-user mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/fab-user

_______________________________________________
Fab-user mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/fab-user


reply via email to

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