-
- try:
- InitializeBootManager.Run( self.VARS, self.LOG )
- ReadNodeConfiguration.Run( self.VARS, self.LOG )
- AuthenticateWithPLC.Run( self.VARS, self.LOG )
- GetAndUpdateNodeDetails.Run( self.VARS, self.LOG )
-
- if self.VARS['BOOT_STATE'] == 'new' or \
- self.VARS['BOOT_STATE'] == 'inst':
- if not ConfirmInstallWithUser.Run( self.VARS, self.LOG ):
- return 0
-
- self.VARS['BOOT_STATE']= 'rins'
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
-
- if not CheckHardwareRequirements.Run( self.VARS, self.LOG ):
- self.VARS['BOOT_STATE']= 'dbg'
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
- raise BootManagerException, "Hardware requirements not met."
-
- self.RunInstaller()
-
- if ValidateNodeInstall.Run( self.VARS, self.LOG ):
- SendHardwareConfigToPLC.Run( self.VARS, self.LOG )
- ChainBootNode.Run( self.VARS, self.LOG )
- else:
- self.VARS['BOOT_STATE']= 'dbg'
- self.VARS['STATE_CHANGE_NOTIFY']= 1
- self.VARS['STATE_CHANGE_NOTIFY_MESSAGE']= \
- notify_messages.MSG_NODE_NOT_INSTALLED
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
-
-
- elif self.VARS['BOOT_STATE'] == 'rins':
- if not CheckHardwareRequirements.Run( self.VARS, self.LOG ):
- self.VARS['BOOT_STATE']= 'dbg'
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
- raise BootManagerException, "Hardware requirements not met."
-
- self.RunInstaller()
-
- if ValidateNodeInstall.Run( self.VARS, self.LOG ):
- SendHardwareConfigToPLC.Run( self.VARS, self.LOG )
- ChainBootNode.Run( self.VARS, self.LOG )
- else:
- self.VARS['BOOT_STATE']= 'dbg'
- self.VARS['STATE_CHANGE_NOTIFY']= 1
- self.VARS['STATE_CHANGE_NOTIFY_MESSAGE']= \
- notify_messages.MSG_NODE_NOT_INSTALLED
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
-
- elif self.VARS['BOOT_STATE'] == 'boot':
- if ValidateNodeInstall.Run( self.VARS, self.LOG ):
- UpdateNodeConfiguration.Run( self.VARS, self.LOG )
- CheckForNewDisks.Run( self.VARS, self.LOG )
- SendHardwareConfigToPLC.Run( self.VARS, self.LOG )
- ChainBootNode.Run( self.VARS, self.LOG )
- else:
- self.VARS['BOOT_STATE']= 'dbg'
- self.VARS['STATE_CHANGE_NOTIFY']= 1
- self.VARS['STATE_CHANGE_NOTIFY_MESSAGE']= \
- notify_messages.MSG_NODE_NOT_INSTALLED
- UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
-
- elif self.VARS['BOOT_STATE'] == 'dbg':
- StartDebug.Run( self.VARS, self.LOG )
-
- except KeyError, e:
- self.LOG.write( "\n\nKeyError while running: %s\n" % str(e) )
- except BootManagerException, e:
- self.LOG.write( "\n\nException while running: %s\n" % str(e) )
-
- return 1
+
+ def _nodeNotInstalled(message='MSG_NODE_NOT_INSTALLED'):
+ # called by the _xxxState() functions below upon failure
+ self.VARS['RUN_LEVEL'] = 'failboot'
+ notify = getattr(notify_messages, message)
+ self.VARS['STATE_CHANGE_NOTIFY'] = 1
+ self.VARS['STATE_CHANGE_NOTIFY_MESSAGE'] = notify
+ raise BootManagerException, notify
+
+ def _bootRun():
+ # implements the boot logic, which consists of first
+ # double checking that the node was properly installed,
+ # checking whether someone added or changed disks, and
+ # then finally chain boots.
+
+ # starting the fallback/debug ssh daemon for safety:
+ # if the node install somehow hangs, or if it simply takes ages,
+ # we can still enter and investigate
+ try:
+ StartDebug.Run(self.VARS, self.LOG, last_resort = False)
+ except:
+ pass
+
+ InstallInit.Run(self.VARS, self.LOG)
+ ret = ValidateNodeInstall.Run(self.VARS, self.LOG)
+ if ret == 1:
+# Thierry - feb. 2013 turning off WriteModprobeConfig for now on lxc
+# for one thing this won't work at all with f18, as modules.pcimap
+# has disappeared (Daniel suggested modules.aliases could be used instead)
+# and second, in any case it's been years now that modprobe.conf was deprecated
+# so most likely this code has no actual effect
+ if self.VARS['virt'] == 'vs':
+ WriteModprobeConfig.Run(self.VARS, self.LOG)
+ WriteNetworkConfig.Run(self.VARS, self.LOG)
+ CheckForNewDisks.Run(self.VARS, self.LOG)
+ SendHardwareConfigToPLC.Run(self.VARS, self.LOG)
+ ChainBootNode.Run(self.VARS, self.LOG)
+ elif ret == -1:
+ _nodeNotInstalled('MSG_NODE_FILESYSTEM_CORRUPT')
+ elif ret == -2:
+ _nodeNotInstalled('MSG_NODE_MOUNT_FAILED')
+ elif ret == -3:
+ _nodeNotInstalled('MSG_NODE_MISSING_KERNEL')
+ else:
+ _nodeNotInstalled()
+
+ def _reinstallRun(upgrade=False):
+
+ # starting the fallback/debug ssh daemon for safety:
+ # if the node install somehow hangs, or if it simply takes ages,
+ # we can still enter and investigate
+ try:
+ StartDebug.Run(self.VARS, self.LOG, last_resort = False)
+ except:
+ pass
+
+ # implements the reinstall logic, which will check whether
+ # the min. hardware requirements are met, install the
+ # software, and upon correct installation will switch too
+ # 'boot' state and chainboot into the production system
+ if not CheckHardwareRequirements.Run(self.VARS, self.LOG):
+ self.VARS['RUN_LEVEL'] = 'failboot'
+ raise BootManagerException, "Hardware requirements not met."
+
+ # runinstaller
+ 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)
+ self.VARS['BOOT_STATE'] = 'boot'
+ self.VARS['STATE_CHANGE_NOTIFY'] = 1
+ self.VARS['STATE_CHANGE_NOTIFY_MESSAGE'] = \
+ notify_messages.MSG_INSTALL_FINISHED
+ AnsibleHook.Run(self.VARS, self.LOG)
+ UpdateBootStateWithPLC.Run(self.VARS, self.LOG)
+ _bootRun()