- sliver_state_updated[sliver_id] = False
-
- constraint = SliverAllocation.sliver_id.in_(sliver_state_updated.keys())
- cur_sliver_allocations = dbsession.query(SliverAllocation).filter(constraint)
- for sliver_allocation in cur_sliver_allocations:
- sliver_allocation.allocation_state = 'geni_allocated'
- sliver_state_updated[sliver_allocation.sliver_id] = True
- dbsession.commit()
-
- # Some states may not have been updated becuase no sliver allocation state record
- # exists for the sliver. Insert new allocation records for these slivers and set
- # it to geni_allocated.
- for (sliver_id, state_updated) in sliver_state_updated.items():
- if state_updated == False:
- record = SliverAllocation(sliver_id=sliver_id, allocation_state='geni_allocated')
- dbsession.add(record)
- dbsession.commit()
-
+ sliver_ids.append(sliver_id)
+ SliverAllocation.set_allocations(sliver_ids, 'geni_allocated')
+