From 2683c0bfdddafa53495a8d037778cb7d79ad035e Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 28 Nov 2011 20:01:28 +0100 Subject: [PATCH] bugfixes --- sfa/managers/driver.py | 11 +++++++++-- sfa/managers/registry_manager.py | 4 ++-- sfa/plc/pldriver.py | 17 ++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/sfa/managers/driver.py b/sfa/managers/driver.py index a939ef3c..7d4b5b23 100644 --- a/sfa/managers/driver.py +++ b/sfa/managers/driver.py @@ -11,9 +11,16 @@ class Driver: # when running GetCredential # This is to reflect the 'enabled' user field in planetlab testbeds # expected retcod boolean - def is_enabled_entity (self, record) : + def is_enabled (self, record) : return True - + + # 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 + def augment_records_with_testbed_info (self, 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 diff --git a/sfa/managers/registry_manager.py b/sfa/managers/registry_manager.py index 41531a11..da0b127b 100644 --- a/sfa/managers/registry_manager.py +++ b/sfa/managers/registry_manager.py @@ -55,7 +55,7 @@ class RegistryManager: # verify_cancreate_credential requires that the member lists # (researchers, pis, etc) be filled in - if not self.driver.is_enabled_entity (record): + if not self.driver.is_enabled (record): raise AccountNotEnabled(": PlanetLab account %s is not enabled. Please contact your site PI" %(record['email'])) # get the callers gid @@ -141,7 +141,7 @@ class RegistryManager: if full: # in full mode we get as much info as we can, which involves contacting the # testbed for getting implementation details about the record - self.driver.fill_record_info(local_records) + self.driver.augment_records_with_testbed_info(local_records) # also we fill the 'url' field for known authorities # used to be in the driver code, sounds like a poorman thing though def solve_neighbour_url (record): diff --git a/sfa/plc/pldriver.py b/sfa/plc/pldriver.py index 1ec55b04..834661b3 100644 --- a/sfa/plc/pldriver.py +++ b/sfa/plc/pldriver.py @@ -44,13 +44,16 @@ class PlDriver (Driver, PlShell): rspec_type == 'eucalyptus' or rspec_type == 'max') ########## disabled users - def is_enabled_entity (self, record): - self.fill_record_info(record) + def is_enabled (self, record): + self.fill_record_info(record, deep=False) if record['type'] == 'user': return record['enabled'] # only users can be disabled return True + def augment_records_with_testbed_info (self, sfa_records): + return self.fill_record_info (sfa_records, deep=True) + ########## def register (self, sfa_record, hrn, pub_key): type = sfa_record['type'] @@ -233,7 +236,7 @@ class PlDriver (Driver, PlShell): return pl_record #################### - def fill_record_info(self, records): + def fill_record_info(self, records, deep=False): """ Given a (list of) SFA record, fill in the PLC specific and SFA specific fields in the record. @@ -242,7 +245,10 @@ class PlDriver (Driver, PlShell): records = [records] self.fill_record_pl_info(records) - self.fill_record_sfa_info(records) + if deep: + self.fill_record_hrns(records) + self.fill_record_sfa_info(records) + return records def fill_record_pl_info(self, records): """ @@ -308,9 +314,6 @@ class PlDriver (Driver, PlShell): pubkeys = [keys[key_id]['key'] for key_id in record['key_ids'] if key_id in keys] record['keys'] = pubkeys - # fill in record hrns - records = self.fill_record_hrns(records) - return records def fill_record_hrns(self, records): -- 2.43.0