+
+ def _nodeNotInstalled():
+ # called by the _xxxState() functions below upon failure
+ self.VARS['BOOT_STATE']= 'dbg'
+ self.VARS['STATE_CHANGE_NOTIFY']= 1
+ self.VARS['STATE_CHANGE_NOTIFY_MESSAGE']= \
+ notify_messages.MSG_NODE_NOT_INSTALLED
+ raise BootManagerException, \
+ notify_messages.MSG_NODE_NOT_INSTALLED
+
+ 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.
+
+ InstallInit.Run( self.VARS, self.LOG )
+ if ValidateNodeInstall.Run( self.VARS, self.LOG ):
+ WriteModprobeConfig.Run( self.VARS, self.LOG )
+ MakeInitrd.Run( self.VARS, self.LOG )
+ WriteNetworkConfig.Run( self.VARS, self.LOG )
+ # the following step should be done by NM
+ 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:
+ _nodeNotInstalled()
+
+ def _rinsRun():
+ # 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['BOOT_STATE']= 'dbg'
+ raise BootManagerException, "Hardware requirements not met."
+
+ # runinstaller
+ InstallInit.Run( self.VARS, self.LOG )
+ InstallPartitionDisks.Run( self.VARS, self.LOG )
+ InstallBootstrapRPM.Run( self.VARS, self.LOG )
+ InstallWriteConfig.Run( self.VARS, self.LOG )
+ InstallBuildVServer.Run( self.VARS, self.LOG )
+ InstallNodeInit.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
+ UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
+ _bootRun()
+
+ def _newRun():
+ # implements the new install logic, which will first check
+ # with the user whether it is ok to install on this
+ # machine, switch to 'rins' state and then invoke the rins
+ # logic. See rinsState logic comments for further
+ # details.
+ if not ConfirmInstallWithUser.Run( self.VARS, self.LOG ):
+ return 0
+ self.VARS['BOOT_STATE']= 'rins'
+ UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
+ _rinsRun()
+
+ def _debugRun():
+ # implements debug logic, which just starts the sshd
+ # and just waits around
+ self.VARS['BOOT_STATE']='dbg'
+ UpdateBootStateWithPLC.Run( self.VARS, self.LOG )
+ StartDebug.Run( self.VARS, self.LOG )
+
+ def _badRun():
+ # should never happen; log event
+ self.LOG.write( "\nInvalid BOOT_STATE = %s\n" % self.VARS['BOOT_STATE'])
+ _debugRun()
+
+ global NodeRunStates
+ # setup state -> function hash table
+ NodeRunStates['new'] = _newRun
+ NodeRunStates['inst'] = _newRun
+ NodeRunStates['rins'] = _rinsRun
+ NodeRunStates['boot'] = _bootRun
+ NodeRunStates['dbg'] = _debugRun
+
+ success = 0