3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
12 from Exceptions import *
16 AUTH_FAILURE_COUNT_FILE= "/tmp/authfailurecount"
21 Authenticate this node with PLC. This ensures that the node can operate
22 as normal, and that our management authority has authorized it.
24 For this, just call the PLC api function BootCheckAuthentication
26 Return 1 if authorized, a BootManagerException if not or the
29 If there are two consecutive authentication failures, put the node
30 into debug mode and exit the bootmanager.
32 Expect the following variables from the store:
33 NUM_AUTH_FAILURES_BEFORE_DEBUG How many failures before debug
36 log.write( "\n\nStep: Authenticating node with PLC.\n" )
38 # make sure we have the variables we need
40 NUM_AUTH_FAILURES_BEFORE_DEBUG= int(vars["NUM_AUTH_FAILURES_BEFORE_DEBUG"])
42 raise BootManagerException, "Missing variable in vars: %s\n" % var
43 except ValueError, var:
44 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
47 authorized= BootAPI.call_api_function( vars, "BootCheckAuthentication", () )
49 log.write( "Authentication successful.\n" )
52 os.unlink( AUTH_FAILURE_COUNT_FILE )
57 except BootManagerException, e:
58 log.write( "Authentication failed: %s.\n" % e )
61 if vars['DISCONNECTED_OPERATION']:
62 vars['API_SERVER_INST']= None
67 # increment auth failure
70 auth_failure_count= int(file(AUTH_FAILURE_COUNT_FILE,"r").read().strip())
76 auth_failure_count += 1
79 fail_file= file(AUTH_FAILURE_COUNT_FILE,"w")
80 fail_file.write( str(auth_failure_count) )
85 if auth_failure_count >= NUM_AUTH_FAILURES_BEFORE_DEBUG:
86 log.write( "Maximum number of authentication failures reached.\n" )
87 log.write( "Canceling boot process and going into debug mode.\n" )
89 raise BootManagerException, "Unable to authenticate node."