X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FInstallBootstrapFS.py;h=b9862ef745ec51e36259a45cab66c0d16af1b914;hb=662b49c8efbe89581f6adda297e51dcdd8bfbfa4;hp=3bff207da7db054d0cc0dde368d186fd87bcc9ad;hpb=b6b8fd27ad48790426ef332f8fceda260c924db0;p=bootmanager.git diff --git a/source/steps/InstallBootstrapFS.py b/source/steps/InstallBootstrapFS.py index 3bff207..b9862ef 100644 --- a/source/steps/InstallBootstrapFS.py +++ b/source/steps/InstallBootstrapFS.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python # Copyright (c) 2003 Intel Corporation # All rights reserved. @@ -10,6 +10,7 @@ import os, sys, string import popen2 import shutil +import traceback from Exceptions import * import utils @@ -90,55 +91,91 @@ def Run( vars, log ): vars['ROOT_MOUNTED']= 1 - # check which nodegroups we are part of (>=4.0) - utils.breakpoint("querying nodegroups for loading extensions") + # which extensions are we part of ? + utils.breakpoint("Checking for the extension(s) tags") + extensions = [] try: - nodes = BootAPI.call_api_function(vars, "GetNodes", ([NODE_ID], ['nodegroup_ids'])) - node = nodes[0] - nodegroups = BootAPI.call_api_function(vars, "GetNodeGroups", (node['nodegroup_ids'], ['name'])) - nodegroupnames = [ nodegroup['name'].lower() for nodegroup in nodegroups ] + extension_tag = BootAPI.call_api_function(vars, "GetNodeExtensions", (NODE_ID,) ) + if extension_tag: + extensions = extension_tag.split() except: - log.write("WARNING : Failed to query nodegroups - installing only core software\n") - nodegroupnames = [] - pass + log.write("WARNING : Failed to query tag 'extensions'\n") + log.write(traceback.format_exc()) - # fetch the distribution our myplc was built upon + if not extensions: + log.write("installing only core software\n") + + # check if the plain-bootstrapfs tag is set + download_suffix=".tar.bz2" + untar_option="-j" try: - plc_release = BootAPI.call_api_function (vars, "GetPlcRelease",()) - distribution = plc_release ['build']['planetlab-distro'] + if BootAPI.call_api_function (vars, "GetNodePlainBootstrapfs", (NODE_ID,) ): + download_suffix=".tar" + untar_option="" except: - distribution = 'planetlab' + log.write("WARNING : Failed to query tag 'plain-bootstrapfs'\n") + log.write(traceback.format_exc()) + + if not untar_option: + log.write("Using uncompressed bootstrapfs images\n") + + # see also GetBootMedium in PLCAPI that does similar things + # figuring the default node family: + # (1) get node's tags 'arch' and 'pldistro' + # (2) if unsuccessful search /etc/planetlab/nodefamily on the bootcd + # (3) if that fails, set to planetlab-i386 - # fetch the distribution our myplc was built upon try: -# done that already -# plc_release = BootAPI.call_api_function (var, "GetPlcRelease",()) - arch = plc_release ['build']['target-arch'] + api_pldistro = BootAPI.call_api_function(vars, "GetNodePldistro", (NODE_ID,) ) except: - arch = 'i386' - - # scan nodegroupnames - temporary, as most of this nodegroup-based info - # should be more adequately defined in the nodes data model - extensions = [] - for nodegroupname in nodegroupnames: - if nodegroupname in [ 'x86_64','i386' ] : - arch = nodegroupname - elif nodegroupname in [ 'planetlab', 'onelab', 'vini' ] : - distribution = nodegroupname - else : - extensions.append(nodegroupname) - - bootstrapfs_names = [ distribution ] + extensions + log.write("WARNING : Failed to query tag 'pldistro'\n") + api_pldistro = None + try: + api_arch = BootAPI.call_api_function(vars, "GetNodeArch", (NODE_ID,) ) + except: + log.write("WARNING : Failed to query tag 'arch'\n") + api_arch = None + try: + (etc_pldistro,etc_arch) = file("/etc/planetlab/nodefamily").read().strip().split("-") + except: + log.write("WARNING : Failed to parse /etc/planetlab/nodefamily\n") + (etc_pldistro,etc_arch)=(None,None) + default_pldistro="planetlab" + default_arch="i386" + + if api_pldistro: + pldistro = api_pldistro + log.write ("Using pldistro from pldistro API tag\n") + elif etc_pldistro: + pldistro = etc_pldistro + log.write ("Using pldistro from /etc/planetlab/nodefamily\n") + else: + pldistro = default_pldistro + log.write ("Using default pldistro\n") + + if api_arch: + arch = api_arch + log.write ("Using arch from arch API tag\n") + elif etc_arch: + arch = etc_arch + log.write ("Using arch from /etc/planetlab/nodefamily\n") + else: + arch = default_arch + log.write ("Using default arch\n") + + log.write ("Using nodefamily=%s-%s\n"%(pldistro,arch)) + + bootstrapfs_names = [ pldistro ] + extensions # download and extract support tarball for this step, which has # everything we need to successfully run # we first try to find a tarball, if it is not found we use yum instead yum_extensions = [] - # download and extract support tarball for this step, which has + # download and extract support tarball for this step, for bootstrapfs_name in bootstrapfs_names: - tarball = "bootstrapfs-%s-%s.tar.bz2"%(bootstrapfs_name,arch) + tarball = "bootstrapfs-%s-%s%s"%(bootstrapfs_name,arch,download_suffix) source_file= "%s/%s" % (SUPPORT_FILE_DIR,tarball) dest_file= "%s/%s" % (SYSIMG_PATH, tarball) @@ -150,12 +187,12 @@ def Run( vars, log ): 30, 14400) if result: log.write( "extracting %s in %s\n" % (dest_file,SYSIMG_PATH) ) - result= utils.sysexec( "tar -C %s -xpjf %s" % (SYSIMG_PATH,dest_file), log ) + result= utils.sysexec( "tar -C %s -xpf %s %s" % (SYSIMG_PATH,dest_file,untar_option), log ) log.write( "Done\n") utils.removefile( dest_file ) else: # the main tarball is required - if bootstrapfs_name == distribution: + if bootstrapfs_name == pldistro: raise BootManagerException, "Unable to download main tarball %s from server." % \ source_file else: @@ -195,36 +232,10 @@ def Run( vars, log ): utils.sysexec("chroot %s rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab" % \ SYSIMG_PATH) - # yum-based extensions: - # before we can use yum, yum.conf needs to get installed - # xxx this should probably depend on the node's nodegroup, at least among alpha, beta .. - # however there does not seem to be a clear interface for that in yum.conf.php - # so let's keep it simple for the bootstrap phase, as yum.conf will get overwritten anyway + # the yum config has changed entirely; + # in addition yum installs have more or less never worked - let's forget about this + # maybe NodeManager could profitably do the job instead if yum_extensions: - getDict = {'gpgcheck':1,'arch':arch} - url="PlanetLabConf/yum.conf.php" - dest="%s/etc/yum.conf"%SYSIMG_PATH - log.write("downloading bootstrap yum.conf\n") - yumconf=bs_request.DownloadFile (url,getDict,None, - 1, 1, dest) - if not yumconf: - log.write("Cannot fetch %s from %s - aborting yum extensions"%(dest,url)) - # failures here should not stop the install process - return 1 - - # yum also needs /proc to be mounted - # do it here so as to not break the tarballs-only case - cmd = "mount -t proc none %s/proc" % SYSIMG_PATH - utils.sysexec( cmd, log ) - # we now just need to yum groupinstall everything - for extension in yum_extensions: - yum_command="yum groupinstall extension%s"%extension - utils.breakpoint ("before chroot %s %s"%(SYSIMG_PATH,yum_command)) - log.write("Attempting to install extension %s through yum\n"%extension) - utils.sysexec_noerr("chroot %s %s" % (SYSIMG_PATH,yum_command)) - # xxx how to check that this completed correctly ? - # let's cleanup - utils.sysexec_noerr( "umount %s/proc" % SYSIMG_PATH, log ) - utils.breakpoint ("Done with yum extensions") + log.write("WARNING : yum installs for node extensions are not supported anymore\n") return 1