The inspection module contains a set of utilities for introspection of the deployment tree. This can be either from inside an action, or externally to reflect on a given tree.

Suppose that we already have the following node instantiated:

from deployer.node import Node

class Setup(Node):
    def say_hello(self):'echo "Hello world"')

setup = Setup()

Now we can ask for the list of actions that this node has:

from deployer.inspection import Inspector

insp = Inspector(setup)
print insp.get_actions()
print insp.get_childnodes()

Some usecases:

  • Suppose that you have a huge deployment tree, covering dozens of projects, each having both a staging and production set-up, and all of them are doing a git checkout. Now you want to list all the current checkouts of all the repositories on all your machines. This is easy by traversing the nodes, filtering on the type gitnode and calling git show in there.
  • Suppose you have an nginx node, which generates the configuration according to the childnodes in there. One childnode could for instance define a back-end, another one could define the location of static files, etc... By using this inspection module, you cat find the childnodes that contain a configuration section and combine these.
  • Internally, the whole interactive shell is also using quite a lot of reflection.


Reflexion/introspection on a deployer.node.Node

class deployer.inspection.inspector.PathType

Types for displaying the Node address in a tree. It’s an options for Inspector.get_path()


A list of names.


A list of (Node, name) tuples.


A list of nodes.

class deployer.inspection.inspector.Inspector(node)

Introspection of a Node instance.


Return the Action with this name or raise AttributeError.


Return a list of Action instances for the actions in this node.

Parameters:include_private (bool) – Include actions starting with an underscore.

Return the childnode with this name or raise AttributeError.

get_childnodes(include_private=True, verify_parent=True)

Return a list of childnodes.

  • include_private (bool) – ignore names starting with underscore.
  • verify_parent (bool) – check that the parent matches the current node.

Return the deployer.groups.Group to which this node belongs.


Return the name of this node.

Note: when a node is nested in a parent node, the name becomes the attribute name of this node in the parent.


Return the parent Node or raise AttributeError.


Return a (name1, name2, ...) tuple, defining the path from the root until here.

Parameters:path_type (PathType) – Path formatting.

Return the attributes that are properties.

This are the members of this node that were wrapped in @property :returns: A list of Action instances.


Returns the property with this name or raise AttributeError. :returns: Action instance.


Return the attributes that are deployer.query.Query instances.


Returns the Action object that wraps the Query with this name or raise AttributeError.

Returns:An Action instance.

Return the root Node of the tree.


Returns True when this node has an action called name.


Returns True when this node has a childnode called name.


Returns True when the attribute name is a @property.


Returns True when the attribute name of this node is a Query.


Return True when this node implements __call__.


True when deployer.node.suppress_action_result() has been applied to this action.


Recursively walk (topdown) through the nodes and yield them.

It does not split SimpleNodes nodes in several isolations.

Parameters:filter – A filters.Filter instance.
Returns:A NodeIterator instance.

Filters for NodeIterator

NodeIterator is the iterator that Inspector.walk() returns. It supports filtering to limit the yielded nodes according to certain conditions.

A filter is a Filter instance or an AND or OR operation of several filters. For instance:

from deployer.inspection.filters import HasAction, PublicOnly
Inspector(node).walk(HasAction('my_action') & PublicOnly & ~ InGroup(Staging))
class deployer.inspection.filters.Filter

Base class for Inspector.walk filters.

deployer.inspection.filters.PublicOnly = PublicOnly

Filter on public nodes.

deployer.inspection.filters.PrivateOnly = PrivateOnly

Filter on private nodes.

class deployer.inspection.filters.IsInstance(node_class)

Filter on the nodes which are an instance of this Node class.

Parameters:node_class – A deployer.node.Node subclass.
class deployer.inspection.filters.HasAction(action_name)

Filter on the nodes which implement this action.

class deployer.inspection.filters.InGroup(group)

Filter nodes that are in this group.

Parameters:group – A deployer.groups.Group subclass.