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