The interactive shell¶
It’s very easy to create an interactive command line shell from a node tree.
Suppose that you have a
MyRootNode, then you can create a shell by making an executable file like
#!/usr/bin/env python from deployer.client import start from deployer.node import Node class MyRootNode(Node): ... if __name__ == '__main__': start(MyRootNode)
If you save this as
client.py and call it by typing
--help, the following help text will be shown:
Usage: ./client.py run [-s | --single-threaded | --socket SOCKET] [--path PATH] [--non-interactive] [--log LOGFILE] [--scp] [--] [ACTION PARAMETER...] ./client.py listen [--log LOGFILE] [--non-interactive] [--socket SOCKET] ./client.py connect (--socket SOCKET) [--path PATH] [--scp] [--] [ACTION PARAMETER...] ./client.py telnet-server [--port PORT] [--log LOGFILE] [--non-interactive] ./client.py list-sessions ./client.py scp ./client.py -h | --help ./client.py --version Options: -h, --help : Display this help text. -s, --single-threaded : Single threaded mode. --path PATH : Start the shell at the node with this location. --scp : Open a secure copy shell. --non-interactive : If possible, run script with as few interactions as possible. This will always choose the default options when asked for questions. --log LOGFILE : Write logging info to this file. (For debugging.) --socket SOCKET : The path of the unix socket. --version : Show version information.
There are several options to start such a shell. It can be multi or single
threaded, or you can run it as a telnet-server. Assuming you made the file also
chmod +x client.py, you just type the following to get the
Running node actions¶
In order to execute an action of the current node, just type the name of the action and press enter. Follow the action name by a space and a value if you want to pass that value as parameter.
Sandboxed execution is possible by preceding the action name by the word
sandbox. e.g. type:
sandbox do_something param. This will run the
action, like usual, but it won’t execute the actual commands on the hosts,
instead it will execute a syntax-checking command instead.
Some special commands, starting with double dash:
Show information about the current node.
This displays the file where the node has been defined, the hosts that are bound to this node and the list of actions child nodes that it contains.
||Display the source code of the current node.|
||Open an interactive (bash) shell on a host of this node. It will ask which host to connect if there are several hosts in this node.|
||Show version information.|
||Open an SCP shell.|
||Run a shell command on all hosts in the current node.|
--connect, it’s possible to pass
the name or path of another node as parameter. E.g.:
The SCP (secure copy) shell¶
--scp in the main shell will open a subshell in which you can run
SCP commands. This is useful for manually downloading and uploading files to
||Go to another directory at the server.|
||Print working directory at the server.|
||Print information about file or directory on the server.|
||Open this file in an editor (vim) on the server.|
||Open interactive (bash) shell at the at the server.|
||Go locally to another directory.|
||Print local working directory.|
||Print information about a local file or directory.|
||Open this local file in an editor|
||Open local interactive (bash) shell at this directory.|
||Upload this local file to the server.|
||Download remote file from the server.|
||Return to the main shell.|