X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FInstallUninitHardware.py;fp=source%2Fsteps%2FInstallUninitHardware.py;h=6497081053565b27a67860eb9e277cd8500a1b77;hb=7cd82eb93512460e8dd748f9737648aabf05f70d;hp=0000000000000000000000000000000000000000;hpb=0ead051299a3094173442795ee262b0900a71ecd;p=bootmanager.git diff --git a/source/steps/InstallUninitHardware.py b/source/steps/InstallUninitHardware.py new file mode 100644 index 0000000..6497081 --- /dev/null +++ b/source/steps/InstallUninitHardware.py @@ -0,0 +1,76 @@ +#!/usr/bin/python +# +# Copyright (c) 2003 Intel Corporation +# All rights reserved. +# +# Copyright (c) 2004-2006 The Trustees of Princeton University +# All rights reserved. +# expected /proc/partitions format + +import os + +from Exceptions import * +import utils + + + +def Run( vars, log ): + """ + Unitializes hardware: + - unmount everything mounted during install, except the + /dev/planetlab/root and /dev/planetlab/vservers. This includes + calling swapoff for /dev/planetlab/swap. + + Except the following variables from the store: + TEMP_PATH the path to download and store temp files to + SYSIMG_PATH the path where the system image will be mounted + (always starts with TEMP_PATH) + PARTITIONS dictionary of generic part. types (root/swap) + and their associated devices. + + Sets the following variables: + None + + """ + + log.write( "\n\nStep: Install: Shutting down installer.\n" ) + + # make sure we have the variables we need + try: + TEMP_PATH= vars["TEMP_PATH"] + if TEMP_PATH == "": + raise ValueError, "TEMP_PATH" + + SYSIMG_PATH= vars["SYSIMG_PATH"] + if SYSIMG_PATH == "": + raise ValueError, "SYSIMG_PATH" + + PARTITIONS= vars["PARTITIONS"] + if PARTITIONS == None: + raise ValueError, "PARTITIONS" + + except KeyError, var: + raise BootManagerException, "Missing variable in vars: %s\n" % var + except ValueError, var: + raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var + + + try: + # make sure the required partitions exist + val= PARTITIONS["root"] + val= PARTITIONS["swap"] + val= PARTITIONS["vservers"] + except KeyError, part: + raise BootManagerException, "Missing partition in PARTITIONS: %s\n" % part + + try: + # backwards compat, though, we should never hit this case post PL 3.2 + os.stat("%s/rcfs/taskclass"%SYSIMG_PATH) + utils.sysexec_chroot_noerr( SYSIMG_PATH, "umount /rcfs", log ) + except OSError, e: + pass + + log.write( "Shutting down swap\n" ) + utils.sysexec( "swapoff %s" % PARTITIONS["swap"], log ) + + return 1