python-ocfra

03 Jul 2011

python-ocfra is a python library intended to make writing OCF Resource Agents in python easier.

This project was written at work, and as such is Copyright IP Systems, but they agreed to release it under an Open Source license.

You can get a copy of the code from Launchpad, and Ubuntu users can add the apt repository ppa:therealmik/ocfra.

Sample Resource Agent

#!/usr/bin/env python

from ocf import resourceagent

agent = resourceagent.ResourceAgent("PythonTest", "1.0")
agent.add_action("start", {"timeout": "10s"}, do_start)
agent.add_action("stop", {"timeout": "10s"}, do_stop)
agent.add_action("monitor", {"timeout": "10s"}, do_monitor)

agent.add_parameter("someparam",
        longdesc="A really long description of some parameter",
        shortdesc="Some Parameter",
        datatype=resourceagent.STRING,
        default="something",
        validate=is_valid)

if __name__ == "__main__":
        import sys
        agent.run(sys.argv)