X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2FBootManager.py;h=2518fb6a1f432ee4b3694f6b0a8e4ae550b7855e;hb=752736d288e356875e5a3198bf1ef1dd43ac9f34;hp=fd5c06fd380e925662b82417eae65d5cb4591f00;hpb=fbb0f48516a3d3fb8b2e67e700a0b7fa6dea0869;p=bootmanager.git diff --git a/source/BootManager.py b/source/BootManager.py index fd5c06f..2518fb6 100755 --- a/source/BootManager.py +++ b/source/BootManager.py @@ -23,12 +23,12 @@ BM_NODE_LOG = "/tmp/bm.log" VARS_FILE = "configuration" # the new contents of PATH when the boot manager is running -BIN_PATH= ('/usr/local/bin', - '/usr/local/sbin', - '/usr/bin', - '/usr/sbin', - '/bin', - '/sbin') +BIN_PATH = ('/usr/local/bin', + '/usr/local/sbin', + '/usr/bin', + '/usr/sbin', + '/bin', + '/sbin') def read_configuration_file(filename): # read in and store all variables in VARS_FILE into each line @@ -43,7 +43,7 @@ def read_configuration_file(filename): if line[:1] == "#" or string.strip(line) == "": continue - parts = string.split(line,"=") + parts = string.split(line, "=") if len(parts) != 2: validConfFile = False raise Exception("Invalid line in vars file: {}".format(line)) @@ -128,7 +128,7 @@ class log: self.LogEntry("Uploading logs to {}".format(self.VARS['UPLOAD_LOG_SCRIPT'])) self.OutputFile.close() - self.OutputFile= None + self.OutputFile = None hostname = self.VARS['INTERFACE_SETTINGS']['hostname'] + "." + \ self.VARS['INTERFACE_SETTINGS']['domainname'] @@ -163,10 +163,11 @@ class BootManager: # file containing initial variables/constants # the set of valid node run states - NodeRunStates = {'reinstall':None, - 'boot':None, - 'safeboot':None, - 'disabled':None, + NodeRunStates = {'reinstall' : None, + 'upgrade' : None, + 'boot' : None, + 'safeboot' : None, + 'disabled' : None, } def __init__(self, log, forceState): @@ -257,7 +258,7 @@ class BootManager: else: _nodeNotInstalled() - def _reinstallRun(): + def _reinstallRun(upgrade=False): # starting the fallback/debug ssh daemon for safety: # if the node install somehow hangs, or if it simply takes ages, @@ -276,8 +277,9 @@ class BootManager: raise BootManagerException, "Hardware requirements not met." # runinstaller - InstallPartitionDisks.Run( self.VARS, self.LOG ) InstallInit.Run(self.VARS, self.LOG) + if not upgrade: + InstallPartitionDisks.Run(self.VARS, self.LOG) InstallBootstrapFS.Run(self.VARS, self.LOG) InstallWriteConfig.Run(self.VARS, self.LOG) InstallUninitHardware.Run(self.VARS, self.LOG) @@ -315,7 +317,8 @@ class BootManager: _debugRun() # setup state -> function hash table - BootManager.NodeRunStates['reinstall'] = _reinstallRun + BootManager.NodeRunStates['reinstall'] = lambda : _reinstallRun(upgrade=False) + BootManager.NodeRunStates['upgrade'] = lambda : _reinstallRun(upgrade=True) BootManager.NodeRunStates['boot'] = _bootRun BootManager.NodeRunStates['safeboot'] = lambda : _debugRun('safeboot') BootManager.NodeRunStates['disabled'] = lambda : _debugRun('disabled') @@ -334,7 +337,7 @@ class BootManager: self.VARS['BOOT_STATE'] = self.forceState UpdateBootStateWithPLC.Run(self.VARS, self.LOG) - stateRun = BootManager.NodeRunStates.get(self.VARS['BOOT_STATE'],_badstateRun) + stateRun = BootManager.NodeRunStates.get(self.VARS['BOOT_STATE'], _badstateRun) stateRun() success = 1 @@ -430,6 +433,6 @@ def main(argv): return error -if __name__ == "__main__": +if __name__ ==e "__main__": error = main(sys.argv) sys.exit(error)