[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Re: multiple disk images, how to?



Molle Bestefich wrote:
> I don't know Python.
> Is it easy to do something like this (bash code):
>
> disk_entries=`grep -E ^disk < $config_file | wc -l`
> if [ $disk_entries -gt 1 ]; then
>   echo Uh-oh...
> fi
>   
Not really, no. See, the config file could look like this:

if 'foo' in locals():
    disk = ['/dev/foo/bar%(foo)s' % foo]
else:
    disk = ['/dev/foo/baz']

...in which case you'd have two disk entries, but only one of them would
ever be executed. Or you could have some fancy dynamic code that looks
at hotplugged USB devices, or who-knows-what, all inside your config
file. Trying to parse the config file any way *other* than with the
Python interpreter would thus be brittle when folks try to take
advantage of the power of having their configuration language be a real
scripting language.


Think of it as if you were sourcing a file to get your config settings
in bash. Someone could have logic like this:

if [ -n "$foo" ] ; then
    DISK="/dev/foo/bar${foo}"
else
    DISK="/dev/foo/baz"
fi

...and that would be valid, so you wouldn't want to call the config file
invalid if it had more than one line matching ^[[:space:]]*DISK=

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.