On Tue, Aug 08, 2006 at 04:59:53PM +0100, John Levon wrote:

> On Tue, Aug 08, 2006 at 10:34:25AM -0500, Hollis Blanchard wrote:
> > Rather than having these inline tests everywhere ("if os.uname()[4] in
> > ('ia64', 'ppc64'):"), would it make more sense to have some sort of
> > "architecture" object, and do things like:
> It'd be good if it were slightly more general and covered other system
> stuff too (namely OS). On Solaris some of the Xen binaries/scripts live
> in different locations in order to meet our file system requirements.
> > I'm not sure how/where to instantiate the arch object though.
> Presumably you could do the instance() singleton trick?

This being Python, you don't actually need singletons -- the containing module
is a singleton in its own right.  You can just write


import os

if os.uname()[4] in ('ia64', 'ppc64'):
    def init_reservation(mem_kb):
        return something_else(mem_kb)

    def init_reservation(mem_kb):
        return mem_kb

and then

import Platform

will do the right thing.


Xen-ppc-devel mailing list

Reply via email to