Writing Python framework for declarative checks?
rustompmody at gmail.com
Tue Mar 19 11:38:15 CET 2013
On Mar 19, 1:38 am, Victor Hooi <victorh... at gmail.com> wrote:
> We currently use a collection of custom Python scripts to validate various things in our production environment/configuration.
> Many of these are simple XML checks (i.e. validate that the value of this XML tag here equals the value in that file over there). Others might be to check that a host is up, or that this application's crontab start time is within 20 minutes of X, or that a logfile on a server contains a certain line.
> The checks are executed automatically before every production push.
> The scripts are written imperatively. E.g.:
> SSH into a server
> Open up a file
> Parse the XML
> Search for a XML tag
> Store the value in a variable
> Compare it to another value somewhere else.
> I'd like to look at writing a framework to do these validation in a slightly more declarative way - i.e. instead of defining how the server should check something, we should just be able to say <tag>value</tag> should equal foobar - and let the framework handle the how.
> I was thinking we could then schedule the checks and shove the jobs onto a queue like Celery.
> To stop me from re-inventing the wheel - are there any existing projects that do something like this already?
> Or has anybody here done something similar, or would be able to offer any advice?
> (I aware of things like Puppet or Chef - or even Salt Stack - however, these are for managing deployments, or actually pushing out configurations. These validation scripts are more to ensure that the configuration changes done by hand are sane, or don't violate certain basic rules).
There is fabric
Basically does the two jobs
1. allowing python functions to be called from the command line
2. Giving ssh a more pythonic feel
You could use the framework to build your own DSL.
[And/or maybe ask the fabric guys what they think of your idea(s) ]
[Disclaimer: Ive not used fabric myself]
More information about the Python-list