diff --git a/cobbler/action_import.py b/cobbler/action_import.py index 9bb84d0..b1ce371 100644 --- a/cobbler/action_import.py +++ b/cobbler/action_import.py @@ -78,11 +78,10 @@ class Importer: raise CX(_("import failed. no --name specified")) if self.arch is not None: self.arch = self.arch.lower() - if self.arch not in [ "i386", "x86", "ia64", "x86_64", "s390x" ]: - raise CX(_("arch must be x86, x86_64, s390x, or ia64")) - if self.arch == "x86": - # be consistent - self.arch = "i386" + if self.arch in utils.archmaps.keys(): + self.arch = utils.archmaps[self.arch] + if self.arch not in utils.validarchs: + raise CX(_("arch must be one of %s") % ", ".join(utils.validarchs)) mpath = os.path.join(self.settings.webdir, "ks_mirror", self.mirror_name) @@ -92,16 +91,11 @@ class Importer: if self.arch: # append the arch path to the name if the arch is not already # found in the name. - found = False - for x in [ "ia64", "i386", "x86_64", "x86", "s390x" ]: + for x in utils.validarchs: if self.mirror_name.lower().find(x) != -1: - found = True break - if not found: + else: self.mirror_name = self.mirror_name + "-" + self.arch - - if self.mirror_name is None: - raise CX(_("import failed. no --name specified")) # make the output path and mirror content but only if not specifying that a network # accessible support location already exists @@ -537,9 +531,6 @@ class Importer: def get_proposed_name(self,dirname,pxe_arch): archname = pxe_arch - if archname == "x86": - # be consistent - archname = "i386" # FIXME: this is new, needs testing ... if self.network_root is not None: name = "-".join(self.path_tail(self.path,dirname).split("/")) @@ -556,16 +547,9 @@ class Importer: name = name.replace("ks_mirror-","") name = name.replace("-pxeboot","") name = name.replace("--","-") - name = name.replace("-i386","") - name = name.replace("_i386","") - name = name.replace("-x86_64","") - name = name.replace("_x86_64","") - name = name.replace("-ia64","") - name = name.replace("_ia64","") - name = name.replace("-x86","") - name = name.replace("_x86","") - name = name.replace("-s390x","") - name = name.replace("_s390x","") + for separator in [ '-' , '_' ] : + for arch in utils.validarchs: + name = name.replace("%s%s" % ( separator , arch ),"") # ensure arch is on the end, regardless of path used. name = name + "-" + archname @@ -591,18 +575,14 @@ class Importer: continue if x.find("kernel-header") != -1: print _("- kernel header found: %s") % x - if x.find("i386") != -1: - foo["result"] = "i386" - return - elif x.find("x86_64") != -1: - foo["result"] = "x86_64" - return - elif x.find("ia64") != -1: - foo["result"] = "ia64" - return - elif x.find("s390") != -1: - foo["result"] = "s390x" - return + for arch in utils.validarchs: + if x.find(arch) != -1: + foo["result"] = arch + return + for arch in utils.archmaps.keys(): + if x.find(arch) != -1: + foo["result"] = utils.archmaps[arch] + return # This extra code block is a temporary fix for rhel4.x 64bit [x86_64] # distro ARCH identification-- L.M. @@ -612,18 +592,14 @@ class Importer: continue if x.find("kernel-largesmp") != -1: print _("- kernel header found: %s") % x - if x.find("i386") != -1: - foo["result"] = "i386" - return - elif x.find("x86_64") != -1: - foo["result"] = "x86_64" - return - elif x.find("ia64") != -1: - foo["result"] = "ia64" - return - elif x.find("s390") != -1: - foo["result"] = "s390x" - return + for arch in utils.validarchs: + if x.find(arch) != -1: + foo["result"] = arch + return + for arch in utils.archmaps.keys(): + if x.find(arch) != -1: + foo["result"] = utils.archmaps[arch] + return def learn_arch_from_tree(self,dirname): """ @@ -640,13 +616,11 @@ class Importer: def get_pxe_arch(self,dirname): t = dirname.lower() - if t.find("x86_64") != -1: - return "x86_64" - if t.find("ia64") != -1: - return "ia64" - if t.find("i386") != -1 or t.find("386") != -1 or t.find("x86") != -1: - return "i386" - if t.find("s390") != -1: - return "s390x" + for arch in utils.validarchs: + if t.find(arch) != -1: + return arch + for arch in utils.archmaps.keys(): + if t.find(arch) != -1: + return utils.archmaps[arch] return self.learn_arch_from_tree(dirname) diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py index ccd437b..0f62426 100644 --- a/cobbler/item_distro.py +++ b/cobbler/item_distro.py @@ -149,7 +149,7 @@ class Distro(item.Item): This field is named "arch" because mainly on Linux, we only care about the architecture, though if (in the future) new provisioning types - are added, an arch value might be something like "bsd_x86". + are added, an arch value might be something like "bsd_i386". Update: (7/2008) this is now used to build fake PXE trees for s390x also """ diff --git a/cobbler/modules/cli_distro.py b/cobbler/modules/cli_distro.py index 793b025..11a7c5c 100644 --- a/cobbler/modules/cli_distro.py +++ b/cobbler/modules/cli_distro.py @@ -46,7 +46,7 @@ class DistroFunction(commands.CobblerFunction): def add_options(self, p, args): if not self.matches_args(args,["dumpvars","remove","report","list"]): - p.add_option("--arch", dest="arch", help="ex: x86, x86_64, ia64") + p.add_option("--arch", dest="arch", help="ex: i386, x86_64, ia64") p.add_option("--breed", dest="breed", help="ex: redhat, debian, suse") if self.matches_args(args,["add"]): p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true") diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py index 7d12d95..80c6815 100644 --- a/cobbler/pxegen.py +++ b/cobbler/pxegen.py @@ -177,7 +177,7 @@ class PXEGen: working_arch = distro.arch if working_arch is None or working_arch == "": - working_arch = "x86" + working_arch = "i386" # for tftp only ... if working_arch in [ "i386", "x86", "x86_64", "standard"]: diff --git a/cobbler/utils.py b/cobbler/utils.py index 758cfa2..77f671f 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -38,6 +38,9 @@ import signal from cexceptions import * import codes +validarchs = [ "i386", "ia64", "x86_64", "s390x" ] +archmaps = { "x86" : "i386" , "amd64" : "x86_68" } + CHEETAH_ERROR_DISCLAIMER=""" # There is a templating error preventing this file from rendering correctly. #