minor tweaks
[sfa.git] / sfa / managers / driver.py
1
2 # an attempt to document what a driver class should provide, 
3 # and implement reasonable defaults
4 #
5
6 class Driver:
7     
8     def __init__ (self): pass
9
10     # redefine this if you want to check again records 
11     # when running GetCredential
12     # This is to reflect the 'enabled' user field in planetlab testbeds
13     # expected retcod boolean
14     def is_enabled (self, record) : 
15         return True
16
17     # the following is used in Resolve (registry) when run in full mode
18     #     after looking up the sfa db, we wish to be able to display
19     #     testbed-specific info as well
20     # this at minima should fill in the 'researcher' field for slice records
21     # as this information is then used to compute rights
22     # roadmap: there is an intention to redesign the SFA database so as to clear up 
23     # this constraint, based on the principle that SFA should not rely on the
24     # testbed database to perform such a core operation (i.e. getting rights right)
25     def augment_records_with_testbed_info (self, sfa_records):
26         return sfa_records
27
28     # incoming record, as provided by the client to the Register API call
29     # expected retcod 'pointer'
30     # 'pointer' is typically an int db id, that makes sense in the testbed environment
31     # -1 if this feature is not relevant 
32     def register (self, sfa_record, hrn, pub_key) : 
33         return -1
34
35     # incoming record is the existing sfa_record
36     # expected retcod boolean, error message logged if result is False
37     def remove (self, sfa_record): 
38         return True
39
40     # incoming are the sfa_record:
41     # (*) old_sfa_record is what we have in the db for that hrn
42     # (*) new_sfa_record is what was passed in the Update call
43     # expected retcod boolean, error message logged if result is False
44     # NOTE 1. about keys
45     # this is confusing because a user may have several ssh keys in 
46     # the planetlab database, but we need to pick one to generate its cert
47     # so as much as in principle we should be able to use new_sfa_record['keys']
48     # the manager code actually picks one (the first one), and it seems safer
49     # to pass it along rather than depending on the driver code to do the same
50     #
51     # NOTE 2. about keys
52     # when changing the ssh key through this method the gid gets changed too
53     # should anything be passed back to the caller in this case ?
54     def update (self, old_sfa_record, new_sfa_record, hrn, new_key): 
55         return True