Writing Python framework for declarative checks?

V

Victor Hooi

HI,

NB: I've posted this question on Reddit as well (but didn't get many responses from Pythonistas) - hope it's ok if I post here as well.

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).

Cheers,
Victor
 
R

rusi

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 thisXML tag here equals the value in that file over there). Others might be tocheck 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 equalfoobar - 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 anyadvice?

(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
http://docs.fabfile.org/en/1.6/
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top