# 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
- # as this information is then used to compute rights
- # roadmap: there is an intention to redesign the SFA database so as to clear up
- # this constraint, based on the principle that SFA should not rely on the
- # testbed database to perform such a core operation (i.e. getting rights right)
+ # 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
local_records = dbsession.query(RegRecord).filter(RegRecord.hrn.in_(local_hrns))
if type:
local_records = local_records.filter_by(type=type)
- local_records=local_records.all()
+ local_records=local_records.all()
- logger.info("Resolve: local_records=%s (type=%s)"%(local_records,type))
+
+ for local_record in local_records:
+ augment_with_sfa_builtins (local_record)
+
+ logger.info("Resolve, (details=%s,type=%s) local_records=%s "%(details,type,local_records))
local_dicts = [ record.__dict__ for record in local_records ]
- if full:
- # in full mode we get as much info as we can, which involves contacting the
+ if details:
+ # in details mode we get as much info as we can, which involves contacting the
# testbed for getting implementation details about the record
self.driver.augment_records_with_testbed_info(local_dicts)
- #logger.debug("Resolve: local_dicts =%s "%(local_dicts))
# 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):
record.url=neighbour_dict[hrn].get_url()
return
for record in local_records: solve_neighbour_url (record)
- #logger.debug("\solve_neighbour_url = OK ")
-
# convert local record objects to dicts for xmlrpc
# xxx somehow here calling dict(record) issues a weird error
# however record.todict() seems to work fine
else:
network_elem = xml
- lease_elems = []
- for lease in leases:
- lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration']
- lease_elem = network_elem.add_instance('lease', lease, lease_fields)
+ # group the leases by slice and timeslots
+ grouped_leases = []
+
+ while leases:
+ slice_id = leases[0]['slice_id']
+ start_time = leases[0]['start_time']
+ duration = leases[0]['duration']
+ group = []
+
+ for lease in leases:
+ if slice_id == lease['slice_id'] and start_time == lease['start_time'] and duration == lease['duration']:
+ group.append(lease)
+
+ grouped_leases.append(group)
+
+ for lease1 in group:
+ leases.remove(lease1)
+
+ lease_elems = []
+ for lease in grouped_leases:
+ #lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration']
+ lease_fields = ['slice_id', 'start_time', 'duration']
+ lease_elem = network_elem.add_instance('lease', lease[0], lease_fields)
lease_elems.append(lease_elem)
+ logger.debug("SFAV1LEASE \t add_lease lease %s" %(lease))
+ # add nodes of this lease
+ for node in lease:
+ lease_elem.add_instance('node', node, ['component_id'])
+
+
+
+ # lease_elems = []
+ # for lease in leases:
+ # lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration']
+ # lease_elem = network_elem.add_instance('lease', lease, lease_fields)
+ # lease_elems.append(lease_elem)
+
@staticmethod
def get_leases(xml, filter={}):