Merge branch 'master' into senslab2
[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     def augment_records_with_testbed_info (self, sfa_records):
22         return sfa_records
23
24     # incoming record, as provided by the client to the Register API call
25     # expected retcod 'pointer'
26     # 'pointer' is typically an int db id, that makes sense in the testbed environment
27     # -1 if this feature is not relevant 
28     # here type will be 'authority'
29     def register (self, sfa_record, hrn, pub_key) : 
30         return -1
31
32     # incoming record is the existing sfa_record
33     # expected retcod boolean, error message logged if result is False
34     def remove (self, sfa_record): 
35         return True
36
37     # incoming are the sfa_record:
38     # (*) old_sfa_record is what we have in the db for that hrn
39     # (*) new_sfa_record is what was passed in the Update call
40     # expected retcod boolean, error message logged if result is False
41     # NOTE 1. about keys
42     # this is confusing because a user may have several ssh keys in 
43     # the planetlab database, but we need to pick one to generate its cert
44     # so as much as in principle we should be able to use new_sfa_record['keys']
45     # the manager code actually picks one (the first one), and it seems safer
46     # to pass it along rather than depending on the driver code to do the same
47     #
48     # NOTE 2. about keys
49     # when changing the ssh key through this method the gid gets changed too
50     # should anything be passed back to the caller in this case ?
51     def update (self, old_sfa_record, new_sfa_record, hrn, new_key): 
52         return True