Shapeshifter is a tool for interacting with remote servers. It
consists of a controller script (ssc
) and a set of modules which run
on the servers with which we want to interact. There is a small
set of core, bootstrap modules. All modules (including the bootstrap
ones) can be uploaded and replaced at run time. Use cases include:
- automatic deployment of applications built in a continuous integration environment
- monitoring and management of processes running on servers via a web interface
- Make sure you have Python 2.7 installed
- Clone
git://github.com/mmakowski/shapeshifter.git
- Copy the
bootstrap
directory to some temporary place on your computer and runwebserver.py
in there. - In the root of your clone run:
ssc.py localhost PUT /ssmodule/hello module=file:modules/hello.py
ssc.py localhost POST /hello/World
You can play around with modifying modules/hello.py
and then
running the two ssc
command above to update and execute it.
Let's see what happens in the demo above:
webserver.py
starts a process which listens for HTTP connections on port 5457.ssc.py
sends aPUT
request to the listening process with URI/ssmodule/hello
and body of typemultipart/form-data
containing the contents ofmodules/hello.py
file.- The listener receives the request; it takes the first part of the
URI,
ssmodule
, loads a module with this name and calls aPUT()
function (corresponding to the HTTP method used) in it, passing in the remainder of the URI ("hello"
) as an argument. ssmodule.PUT()
creates a filehello.py
writing to it the content retrieved from the request body.- the second invocation of
ssc
sends a POST request with URI/hello/World
. - The listener processes the requst by invoking
hello.POST()
function (defined in the module created in response to the previous request) and passing to it"World"
. hello.POST()
prints the greeting on the standard output.
ssc.py <targets> <method> <URI> [<data>]
<targets>
: a comma-separated list of machines to which requests are to be sent.<method>
: HTTP method; currently supported methods areDELETE
,GET
,POST
andPUT
.<URI>
: the URI to be requested. The first element of it (up to the first/
) determines the module which will be invoked.<data>
: a set of key-value pairs to be sent as form data in the format:<key_1>=<value_1>,...,<key_n>=<value_n>
. If a value is of the formatfile:<path>
then the contents of file denoted by<path>
will be sent.