fab-user
[Top][All Lists]
Advanced

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

[Fab-user] with_settings decorator generating RuntimeError (generator di


From: Felix Almeida
Subject: [Fab-user] with_settings decorator generating RuntimeError (generator didn't yield)
Date: Wed, 11 Mar 2015 23:53:09 +0000

Hi all,

 

  I need to validate if a certain UNIX account is able to log in to a series of servers of mixed flavors (HP-UX, Solaris, RHEL and AIX) so I’m trying to do it with fabric.

 

  I wanted to apply hide("status") to an entire internal function, but I keep getting the following error:

 

elxin009: ~/fabric # fab main

[bsnbk001] out: SunOS

[bsnbk001] out:

[bsnbk001] OS is SunOS

Disconnecting from bsnbk001... done.

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/site-packages/fabric/main.py", line 743, in main

    *args, **kwargs

  File "/usr/local/lib/python2.7/site-packages/fabric/tasks.py", line 424, in execute

    results['<local-only>'] = task.run(*args, **new_kwargs)

  File "/usr/local/lib/python2.7/site-packages/fabric/tasks.py", line 174, in run

    return self.wrapped(*args, **kwargs)

  File "/home/felix/fabric/fabfile.py", line 24, in main

    execute(_my_function, hosts=host_list)

  File "/usr/local/lib/python2.7/site-packages/fabric/tasks.py", line 384, in execute

    multiprocessing

  File "/usr/local/lib/python2.7/site-packages/fabric/tasks.py", line 274, in _execute

    return task.run(*args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/fabric/tasks.py", line 174, in run

    return self.wrapped(*args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/fabric/decorators.py", line 215, in inner

    with settings(*arg_settings, **kw_settings):

  File "/usr/local/lib/python2.7/contextlib.py", line 17, in __enter__

    return self.gen.next()

  File "/usr/local/lib/python2.7/contextlib.py", line 112, in nested

    vars.append(enter())

  File "/usr/local/lib/python2.7/contextlib.py", line 19, in __enter__

    raise RuntimeError("generator didn't yield")

RuntimeError: generator didn't yield

 

  This is a very simplified version of my original code that I’m using for troubleshooting since it generates the same error:

 

from fabric.api import task, hide, execute, env, puts, run, with_settings

 

env.use_shell = False

env.disable_known_hosts = True

env.warn_only = True

env.abort_on_prompts = True

env.skip_bad_hosts = True

env.command_timeout = 3

env.eagerly_disconnect = True

env.always_use_pty = False

 

@with_settings(hide("status"))

def _my_function():

    try:

        out = run("uname")

        puts("OS is " + out)

    except SystemExit:

        puts("can't get the OS")

 

@task

def main():

    host_list = [line.rstrip("\n") for line in open("hosts.txt")]

    with hide("running"):

        execute(_my_function, hosts=host_list)

 

  The hosts.txt file is just a text file with one hostname per line. This was the content of the file when I captured the output above (just two servers):

 

bsnbk001

slxap003

 

  In fact, none of the env settings makes any difference, but if I comment out the @with_settings line it works as expected. If the hosts.txt file contains only one hostname then it also works without any errors.

 

  Please, any ideas of what I am doing wrong? I’m still learning Python so forgive me if I’m doing something silly.

 

 

Thank you,

Felix

 

PS: I’m running Fabric 1.10.1 and Paramiko 1.15.2 on RHEL.

 






This communication is confidential. We only send and receive email on the basis of the terms set out at www.rogers.com/web/content/emailnotice



Ce message est confidentiel. Notre transmission et réception de courriels se fait strictement suivant les modalités énoncées dans l’avis publié à www.rogers.com/aviscourriel

reply via email to

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