6 # Copyright (c) 2003 Intel Corporation
9 # Copyright (c) 2004-2006 The Trustees of Princeton University
10 # All rights reserved.
15 from Exceptions import *
19 AUTH_FAILURE_COUNT_FILE= "/tmp/authfailurecount"
24 Authenticate this node with PLC. This ensures that the node can operate
25 as normal, and that our management authority has authorized it.
27 For this, just call the PLC api function BootCheckAuthentication
29 Return 1 if authorized, a BootManagerException if not or the
32 If there are two consecutive authentication failures, put the node
33 into debug mode and exit the bootmanager.
35 Expect the following variables from the store:
36 NUM_AUTH_FAILURES_BEFORE_DEBUG How many failures before debug
39 log.write( "\n\nStep: Authenticating node with PLC.\n" )
41 # make sure we have the variables we need
43 NUM_AUTH_FAILURES_BEFORE_DEBUG= int(vars["NUM_AUTH_FAILURES_BEFORE_DEBUG"])
45 raise BootManagerException, "Missing variable in vars: %s\n" % var
46 except ValueError, var:
47 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
50 authorized= BootAPI.call_api_function( vars, "BootCheckAuthentication", () )
52 log.write( "Authentication successful.\n" )
55 os.unlink( AUTH_FAILURE_COUNT_FILE )
60 except BootManagerException, e:
61 log.write( "Authentication failed: %s.\n" % e )
64 if vars['DISCONNECTED_OPERATION']:
65 vars['API_SERVER_INST']= None
70 # increment auth failure
73 auth_failure_count= int(file(AUTH_FAILURE_COUNT_FILE,"r").read().strip())
79 auth_failure_count += 1
82 fail_file= file(AUTH_FAILURE_COUNT_FILE,"w")
83 fail_file.write( str(auth_failure_count) )
88 if auth_failure_count >= NUM_AUTH_FAILURES_BEFORE_DEBUG:
89 log.write( "Maximum number of authentication failures reached.\n" )
90 log.write( "Canceling boot process and going into debug mode.\n" )
92 raise BootManagerException, "Unable to authenticate node."