Use factory to get the image classes

This commit is contained in:
Martin Gracik 2011-03-15 11:37:44 +01:00
parent c922ae64a9
commit 5878db3e81
2 changed files with 20 additions and 6 deletions

View File

@ -367,12 +367,8 @@ class Lorax(BaseLoraxClass):
self.variant, self.basearch) self.variant, self.basearch)
# get the image class # get the image class
if self.basearch == "ppc": factory = images.Factory()
imgclass = images.PPC imgclass = factory.get_class(self.basearch)
elif self.basearch in ("i386", "x86_64"):
imgclass = images.X86
else:
raise Exception("not supported arch '{0}'".format(self.basearch))
i = imgclass(kernellist=self.outputtree.kernels, i = imgclass(kernellist=self.outputtree.kernels,
installtree=self.installtree, installtree=self.installtree,

View File

@ -667,3 +667,21 @@ class S390(object):
def create_boot(self, efiboot=None): def create_boot(self, efiboot=None):
pass pass
class Factory(object):
DISPATCH_MAP = {"ppc": PPC,
"i386": X86,
"x86_64": X86,
"s390": S390,
"s390x": S390}
def __init__(self):
pass
def get_class(self, arch):
if arch in self.DISPATCH_MAP:
return self.DISPATCH_MAP[arch]
else:
raise Exception("no support for {0}".format(arch))