Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41459 > unrolled thread

Writing Python framework for declarative checks?

Started byVictor Hooi <victorhooi@gmail.com>
First post2013-03-18 13:38 -0700
Last post2013-03-19 03:38 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Writing Python framework for declarative checks? Victor Hooi <victorhooi@gmail.com> - 2013-03-18 13:38 -0700
    Re: Writing Python framework for declarative checks? rusi <rustompmody@gmail.com> - 2013-03-19 03:38 -0700

#41459 — Writing Python framework for declarative checks?

FromVictor Hooi <victorhooi@gmail.com>
Date2013-03-18 13:38 -0700
SubjectWriting Python framework for declarative checks?
Message-ID<856820af-23a0-40d8-bd5d-1dd666be7df8@googlegroups.com>
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

[toc] | [next] | [standalone]


#41484

Fromrusi <rustompmody@gmail.com>
Date2013-03-19 03:38 -0700
Message-ID<6701e6d4-815e-4907-8176-909c8bf470d5@o9g2000pbt.googlegroups.com>
In reply to#41459
On Mar 19, 1:38 am, Victor Hooi <victorh...@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
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]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web