3 from Exceptions import *
8 AUTH_FAILURE_COUNT_FILE= "/tmp/authfailurecount"
13 Authenticate this node with PLC. This ensures that the node can operate
14 as normal, and that our management authority has authorized it.
16 For this, just call the PLC api function BootCheckAuthentication
18 Return 1 if authorized, a BootManagerException if not or the
21 If there are two consecutive authentication failures, put the node
22 into debug mode and exit the bootmanager.
24 Expect the following variables from the store:
25 NUM_AUTH_FAILURES_BEFORE_DEBUG How many failures before debug
28 log.write( "\n\nStep: Authenticating node with PLC.\n" )
30 # make sure we have the variables we need
32 NUM_AUTH_FAILURES_BEFORE_DEBUG= int(vars["NUM_AUTH_FAILURES_BEFORE_DEBUG"])
34 raise BootManagerException, "Missing variable in vars: %s\n" % var
35 except ValueError, var:
36 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
39 authorized= BootAPI.call_api_function( vars, "BootCheckAuthentication", () )
41 log.write( "Authentication successful.\n" )
44 os.unlink( AUTH_FAILURE_COUNT_FILE )
49 except BootManagerException, e:
50 log.write( "Authentication failed: %s.\n" % e )
52 # increment auth failure
55 auth_failure_count= int(file(AUTH_FAILURE_COUNT_FILE,"r").read().strip())
61 auth_failure_count += 1
64 fail_file= file(AUTH_FAILURE_COUNT_FILE,"w")
65 fail_file.write( str(auth_failure_count) )
70 if auth_failure_count >= NUM_AUTH_FAILURES_BEFORE_DEBUG:
71 log.write( "Maximum number of authentication failures reached.\n" )
72 log.write( "Canceling boot process and going into debug mode.\n" )
74 StartDebug.Run( vars, log )
76 raise BootManagerException, "Unable to authenticate node."