ModiPy QuickStart Guide

You want to just dive in and try out ModiPy, right? Of course you do. No problem. Here's how.

Grab ModiPy

First off you'll need ModiPy. It's a Python program, so you'll need to have Python installed. The easiest way to grab ModiPy is via the Python Package Index, PyPI, so you'll need setuptools installed, too.

Use your package manager to install them, like this:

sudo apt-get install python setuptools

Then, grab ModiPy like this:

sudo easy_install ModiPy

Done!

Setting Up a Change

We'll set up a simple change that just talks to the server that ModiPy is installed on, and runs echo "Hello, World!"

You can do this with a single text file. Open up a file in your favourite text editor:

$ vi hello-change.xml

Everything is wrapped in a single <config/> element, like this:

<config>
</config>

Add Devices

We need to tell ModiPy what devices to apply changes to. Add one for the localhost, like this:

<config>
  <device name='localhost'/>
</config>

See you the device is inside the <config/> element?

Add Provisioners

Next we need to tell ModiPy how we plan to communicate with our devices. This is done using Provisioners. We're going to use a simple Provisioner called a CommandProvisioner, like this:

<config>
  <device name='localhost'/>

  <provisioner name='MyFirstProvisioner'
               module='modipy.provisioner_command'
               type='MultiConnectingProvisioner'>
    <command>"%(command.send)s"</command>
  </provisioner>

</config>

All this Provisioner does is to run a command.

Add Changes

Now we need to define the change we want to happen. For the example, we'll use a CommandChange to run echo "Hello, World! like this:

<config>
  <device name='localhost'/>

  <provisioner name='MyFirstProvisioner'
               module='modipy.provisioner_command'
               type='MultiConnectingProvisioner'>
    <command>%(command.send)s</command>
  </provisioner>

  <change name='my_first_change'
     module='modipy.change_command'
     type='CommandChange'>

    <target name='localhost'/>

    <impl>
      <command>
        <send>echo "Hello, World!"</send>
      </command>
    </impl>

  </change>

</config>

This change has a target of localhost, which is the Device we defined at the beginning.

It also has a simple implementation command, which is to send echo "Hello, World! to localhost. ModiPy knows to use the CommandProvisioner for this CommandChange.

Save the file, and you're ready to run ModiPy.

Run ModiPy

Execute this change like this:

$ modipy -c hello-change.xml

This tells ModiPy to use your hello-change.xml file for its configuration.

The output should look like this:

2009-01-07 09:23:41    INFO: Doing pre-apply check for change 'my_first_change' on device 'localhost'
2009-01-07 09:23:41    INFO: Pre-apply check passed for change 'my_first_change' on device 'localhost'
2009-01-07 09:23:41    INFO: Applying change 'my_first_change' to device 'localhost'
2009-01-07 09:23:41    INFO: Change 'my_first_change' was a success!
2009-01-07 09:23:41    INFO: --- Final results ---
2009-01-07 09:23:41    INFO: 1 ok, 0 failed (100% success rate)
2009-01-07 09:23:41    INFO: Successful changes: my_first_change

Congratulations. You just automated your first change with ModiPy!