Question

I am learning Python and playing around with the Fabric library. I learned that if you use fab --list command, it shows you the list of available commands.

from fabric.api import *
from ConfigParser import SafeConfigParser
import os

def install_nova():
    ...

def deploy_vms():
    ...

where ... represents the code to be executed for the given command. When I do fab --list it should be only showing me the options install_nova and deploy_vms. However, I am getting this -

Available commands:

    SafeConfigParser
    deploy_vms
    install_nova

I have following questions -

  • Why is SafeConfigParser appearing as an available commands?
  • How can I get rid of SafeConfigParser from the available commands option?

Fabric version is :

Fabric 1.8.0

Paramiko 1.11.2

And python version is :

Python 2.7.5
Was it helpful?

Solution

You have to apply @task decorator to all you functions:

@task
def install_nova():
    ...
@task
def deploy_vms():
    ...

If you don't use @task, fabric will treats all functions as commands.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top