2 # an attempt to document what a driver class should provide,
3 # and implement reasonable defaults
8 def __init__ (self, config):
9 # this is the hrn attached to the running server
10 self.hrn = config.SFA_INTERFACE_HRN
12 ########################################
13 ########## registry oriented
14 ########################################
16 # redefine this if you want to check again records
17 # when running GetCredential
18 # This is to reflect the 'enabled' user field in planetlab testbeds
19 # expected retcod boolean
20 def is_enabled (self, record) :
23 # the following is used in Resolve (registry) when run in full mode
24 # after looking up the sfa db, we wish to be able to display
25 # testbed-specific info as well
26 # this at minima should fill in the 'researcher' field for slice records
27 # as this information is then used to compute rights
28 # roadmap: there is an intention to redesign the SFA database so as to clear up
29 # this constraint, based on the principle that SFA should not rely on the
30 # testbed database to perform such a core operation (i.e. getting rights right)
31 def augment_records_with_testbed_info (self, sfa_records):
32 print >>sys.stderr, " \r\n \r\n DRIVER.PY augment_records_with_testbed_info sfa_records ",sfa_records
35 # incoming record, as provided by the client to the Register API call
36 # expected retcod 'pointer'
37 # 'pointer' is typically an int db id, that makes sense in the testbed environment
38 # -1 if this feature is not relevant
39 def register (self, sfa_record, hrn, pub_key) :
42 # incoming record is the existing sfa_record
43 # expected retcod boolean, error message logged if result is False
44 def remove (self, sfa_record):
47 # incoming are the sfa_record:
48 # (*) old_sfa_record is what we have in the db for that hrn
49 # (*) new_sfa_record is what was passed in the Update call
50 # expected retcod boolean, error message logged if result is False
52 # this is confusing because a user may have several ssh keys in
53 # the planetlab database, but we need to pick one to generate its cert
54 # so as much as in principle we should be able to use new_sfa_record['keys']
55 # the manager code actually picks one (the first one), and it seems safer
56 # to pass it along rather than depending on the driver code to do the same
59 # when changing the ssh key through this method the gid gets changed too
60 # should anything be passed back to the caller in this case ?
61 def update (self, old_sfa_record, new_sfa_record, hrn, new_key):
64 ########################################
65 ########## aggregate oriented
66 ########################################
68 # a name for identifying the kind of testbed
69 def testbed_name (self): return "undefined"
71 # a dictionary that gets appended to the generic answer to GetVersion
72 # 'geni_request_rspec_versions' and 'geni_ad_rspec_versions' are mandatory
73 def aggregate_version (self): return {}
75 # the answer to ListSlices, a list of slice urns
76 def list_slices (self, creds, options):
79 # answer to ListResources
80 # first 2 args are None in case of resource discovery
81 # expected : rspec (xml string)
82 def list_resources (self, slice_urn, slice_hrn, creds, options):
83 return "dummy Driver.list_resources needs to be redefined"
85 # the answer to SliverStatus on a given slice
86 def sliver_status (self, slice_urn, slice_hrn): return {}
88 # the answer to CreateSliver on a given slice
89 # expected to return a valid rspec
90 # identical to ListResources after the slice was modified
91 def create_sliver (self, slice_urn, slice_hrn, creds, rspec_string, users, options):
92 return "dummy Driver.create_sliver needs to be redefined"
94 # the answer to DeleteSliver on a given slice
95 def delete_sliver (self, slice_urn, slice_hrn, creds, options):
96 return "dummy Driver.delete_sliver needs to be redefined"
98 # the answer to RenewSliver
99 # expected to return a boolean to indicate success
100 def renew_sliver (self, slice_urn, slice_hrn, creds, expiration_time, options):
103 # the answer to start_slice/stop_slice
104 # 1 means success, otherwise raise exception
105 def start_slice (self, slice_urn, slice_xrn, creds):
107 def stop_slice (self, slice_urn, slice_xrn, creds):
109 # somehow this one does not have creds - not implemented in PL anyways
110 def reset_slice (self, slice_urn, slice_xrn, creds):
113 # the answer to GetTicket
114 # expected is a ticket, i.e. a certificate, as a string
115 def get_ticket (self, slice_urn, slice_xrn, creds, rspec, options):
116 return "dummy Driver.get_ticket needs to be redefined"