[xen-tools-discuss] Re: Python script for hooks/roles

Damien Churchill damoxc at gmail.com
Tue Jun 3 16:42:44 CEST 2008


2008/6/3 Steve Kemp <steve at steve.org.uk>:
> On Tue Jun 03, 2008 at 15:21:30 +0100, Damien Churchill wrote:
>
> > I've ported the /usr/lib/xen-tools/common.sh script over to python to
> ease
> > creating role scripts.
> > Just wondered if anyone was interested in it.
>
>   I don't know - its kinda neat to be able to do roles that way,
>  but the hook scripts that exist are all in shell, so I'm not
>  sure if there is a whole lot of point in having the mixture.
>
>  (Partly because I know shell/perl and not python.)


Well, I figured that some of the role/hook scripts would be bespoke, written
by the person creating the images (at least I know that's what I'm doing)
and since I like python it made sense to convert the common functions for
shell over to python.

Just allows whoever is doing the administering a wider choice.


>
> > The chmod helper function I know is extremely poor, just wanted to throw
> > something together quickly instead of having to call chmod (I figure
> where
> > possible avoid having to load a whole program into the memory)
>
>   I guess that is such a small optimisation that it would make almost
>  zero difference - given the high number of shell scripts/steps already
>  involved.
>
>  If you post it to the list, or better yet place it online and share
>  a link to it I'd be happy to take a look.  I guess unless, or until,
>  somebody publically users it then it won't be used.
>
>  (I'm not 100% sure what problem you're trying to solve ..?)
>
> Steve
> --
> http://www.steve.org.uk/
>

Recreating chmod was more just for my own amusement than anything else,
since pythons os.chmod function only takes a number (and not even 644 style,
to allow for cross compatibility) I wanted to improve it a little, for
potential reuse elsewhere, so now it takes a number in 644 style and '+x'.

I did attach the script in my first mail but incase that got lost then it's
available at:
http://damoxc.net/scripts/xen_tools.py






More information about the xen-tools-discuss mailing list