X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Fdriver.py;h=ab3b2165578eea3d1ee9de73ccafbe90e8bada7f;hb=dbd15819d950b69d0c6ba5527660969d0754ad29;hp=7d4b5b236f3d96a23265f8c03c5c441d11025234;hpb=d58bbc6238ee07a3e386b2627aa64ccb2dce352f;p=sfa.git diff --git a/sfa/managers/driver.py b/sfa/managers/driver.py index 7d4b5b23..ab3b2165 100644 --- a/sfa/managers/driver.py +++ b/sfa/managers/driver.py @@ -2,30 +2,35 @@ # an attempt to document what a driver class should provide, # and implement reasonable defaults # - +import sys class Driver: - def __init__ (self): pass + def __init__ (self, config): + # this is the hrn attached to the running server + self.hrn = config.SFA_INTERFACE_HRN - # redefine this if you want to check again records - # when running GetCredential - # This is to reflect the 'enabled' user field in planetlab testbeds - # expected retcod boolean - def is_enabled (self, record) : - return True + ######################################## + ########## registry oriented + ######################################## + + # NOTE: the is_enabled method is deprecated + # it was only making things confusing, as the (PL) import mechanism would + # ignore not enabled users anyway.. # the following is used in Resolve (registry) when run in full mode # after looking up the sfa db, we wish to be able to display # testbed-specific info as well - # this at minima should fill in the 'researcher' field for slice records + # based on the principle that SFA should not rely on the testbed database + # to perform such a core operation (i.e. getting rights right) + # this is no longer in use when performing other SFA operations def augment_records_with_testbed_info (self, sfa_records): + print >>sys.stderr, " \r\n \r\n DRIVER.PY augment_records_with_testbed_info sfa_records ",sfa_records return sfa_records # incoming record, as provided by the client to the Register API call # expected retcod 'pointer' # 'pointer' is typically an int db id, that makes sense in the testbed environment # -1 if this feature is not relevant - # here type will be 'authority' def register (self, sfa_record, hrn, pub_key) : return -1 @@ -50,3 +55,67 @@ class Driver: # should anything be passed back to the caller in this case ? def update (self, old_sfa_record, new_sfa_record, hrn, new_key): return True + + # callack for register/update + # this allows to capture changes in the relations between objects + # the ids below are the ones found in the 'pointer' field + # this can get typically called with + # 'slice' 'user' 'researcher' slice_id user_ids + # 'authority' 'user' 'pi' authority_id user_ids + def update_relation (self, subject_type, target_type, relation_name, subject_id, link_ids): + pass + + ######################################## + ########## aggregate oriented + ######################################## + + # a name for identifying the kind of testbed + def testbed_name (self): return "undefined" + + # a dictionary that gets appended to the generic answer to GetVersion + # 'geni_request_rspec_versions' and 'geni_ad_rspec_versions' are mandatory + def aggregate_version (self): return {} + + # the answer to ListSlices, a list of slice urns + def list_slices (self, creds, options): + return [] + + # answer to ListResources + # first 2 args are None in case of resource discovery + # expected : rspec (xml string) + def list_resources (self, slice_urn, slice_hrn, creds, options): + return "dummy Driver.list_resources needs to be redefined" + + # the answer to SliverStatus on a given slice + def sliver_status (self, slice_urn, slice_hrn): return {} + + # the answer to CreateSliver on a given slice + # expected to return a valid rspec + # identical to ListResources after the slice was modified + def create_sliver (self, slice_urn, slice_hrn, creds, rspec_string, users, options): + return "dummy Driver.create_sliver needs to be redefined" + + # the answer to DeleteSliver on a given slice + def delete_sliver (self, slice_urn, slice_hrn, creds, options): + return "dummy Driver.delete_sliver needs to be redefined" + + # the answer to RenewSliver + # expected to return a boolean to indicate success + def renew_sliver (self, slice_urn, slice_hrn, creds, expiration_time, options): + return False + + # the answer to start_slice/stop_slice + # 1 means success, otherwise raise exception + def start_slice (self, slice_urn, slice_xrn, creds): + return 1 + def stop_slice (self, slice_urn, slice_xrn, creds): + return 1 + # somehow this one does not have creds - not implemented in PL anyways + def reset_slice (self, slice_urn, slice_xrn, creds): + return 1 + + # the answer to GetTicket + # expected is a ticket, i.e. a certificate, as a string + def get_ticket (self, slice_urn, slice_xrn, creds, rspec, options): + return "dummy Driver.get_ticket needs to be redefined" +