- def suspend_slice(self, slicename):
- logger.log('reservation.suspend_slice, slice %s, to be written'%slicename)
-
- def restart_slice(self, slicename):
- logger.log('reservation.restart_slice, slice %s, to be written'%slicename)
+ ########## nothing is starting nor ending
+ if not ending_lease and not starting_lease:
+ ### this might be useful for robustness - not sure what to do now though
+ logger.log("reservation.granularity_callback: xxx todo - should make sure to start the running lease if relevant")
+ ########## something to start - something to end
+ elif ending_lease and starting_lease:
+ ## yes, but that's the same sliver
+ if ending_lease['name']==starting_lease['name']:
+ slicename=ending_lease['name']
+ if self.is_running(slicename):
+ logger.log("reservation.granularity_callback: end/start of same sliver %s -- ignored"%ending_lease['name'])
+ else:
+ logger.log("reservation.granularity_callback: mmh, the sliver is unexpectedly not running, starting it...")
+ self.restart_slice(slicename)
+ ## two different slivers
+ else:
+ self.restart_slice(starting_lease['name'])
+ self.suspend_slice(ending_lease['name'])
+ ########## something to start, nothing to end
+ elif starting_lease and not ending_lease:
+ self.restart_slice(starting_lease['name'])
+ # with the lease_or_shared policy, this is mandatory
+ # otherwise it's just safe
+ self.suspend_all_slices(exclude=starting_lease['name'])
+ ########## so now, something to end, nothing to start
+ else:
+ self.suspend_slice (ending_lease['name'])
+ if self.reservation_policy=='lease_or_shared':
+ logger.log("reservation.granularity_callback: 'lease_or_shared' not implemented - using 'lease_or_idle'")
+ # only lease_or_idle policy available for now: we freeze the box
+ logger.log("reservation.granularity_callback: suspending all slices")
+ self.suspend_all_slices()