Writing Python framework for declarative checks?

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Mar 19 06:28:16 EDT 2013


----- Original Message -----
> 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.


Using a continuous integration software like Jenkins, have it schedule checks upon whatever trigger you need.
In jenkins you can add shell or python batchs from which you can call your python scripts.

A Jenkins python batch would look like this :

-- Job A --

*Python batch*

import checkers

for tag, value in [
  ('xmlTag', 'value'),
  ('xmlTag2', 'value2'),
  ...
]:
  checkers.checkXmlTag(tag, value)  


JM




-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list