'Pick a cell where we should create a new instance(s).'

def _schedule_build_to_cells(self, message, instance_uuids, filter_properties, method, method_kwargs):

    try:
        for i in range((max(0, CONF.cells.scheduler_retries) + 1)):
            try:
                target_cells = self._grab_target_cells(filter_properties)
                if (target_cells is None):
                    return
                return method(message, target_cells, instance_uuids, method_kwargs)
            except exception.NoCellsAvailable:
                if (i == max(0, CONF.cells.scheduler_retries)):
                    raise
                sleep_time = max(1, CONF.cells.scheduler_retry_delay)
                LOG.info('No    cells    available    when    scheduling.        Will    retry    in    %(sleep_time)s    second(s)', {'sleep_time': sleep_time})
                time.sleep(sleep_time)
                continue
    except Exception:
        LOG.exception('Error    scheduling    instances    %(instance_uuids)s', {'instance_uuids': instance_uuids})
        ctxt = message.ctxt
        for instance_uuid in instance_uuids:
            instance = objects.Instance(context=ctxt, uuid=instance_uuid, vm_state=vm_states.ERROR)
            self.msg_runner.instance_update_at_top(ctxt, instance)
            try:
                instance.vm_state = vm_states.ERROR
                instance.save()
            except Exception:
                pass
