'Creates the volume.'

@objects.Volume.set_workers
def create_volume(self, context, volume, request_spec=None, filter_properties=None, allow_reschedule=True):

    utils.log_unsupported_driver_warning(self.driver)
    self._set_resource_host(volume)
    context_elevated = context.elevated()
    if (filter_properties is None):
        filter_properties = {}
    if (request_spec is None):
        request_spec = objects.RequestSpec()
    try:
        flow_engine = create_volume.get_flow(context_elevated, self, self.db, self.driver, self.scheduler_rpcapi, self.host, volume, allow_reschedule, context, request_spec, filter_properties, image_volume_cache=self.image_volume_cache)
    except Exception:
        msg = _('Create    manager    volume    flow    failed.')
        LOG.exception(msg, resource={'type': 'volume', 'id': volume.id})
        raise exception.CinderException(msg)
    snapshot_id = request_spec.get('snapshot_id')
    source_volid = request_spec.get('source_volid')
    source_replicaid = request_spec.get('source_replicaid')
    if (snapshot_id is not None):
        locked_action = ('%s-%s' % (snapshot_id, 'delete_snapshot'))
    elif (source_volid is not None):
        locked_action = ('%s-%s' % (source_volid, 'delete_volume'))
    elif (source_replicaid is not None):
        locked_action = ('%s-%s' % (source_replicaid, 'delete_volume'))
    else:
        locked_action = None
    def _run_flow():
        with flow_utils.DynamicLogListener(flow_engine, logger=LOG):
            flow_engine.run()
    rescheduled = False
    try:
        if (locked_action is None):
            _run_flow()
        else:
            with coordination.COORDINATOR.get_lock(locked_action):
                _run_flow()
    finally:
        try:
            flow_engine.storage.fetch('refreshed')
        except tfe.NotFound:
            try:
                rescheduled = flow_engine.storage.get_revert_result(create_volume.OnFailureRescheduleTask.make_name([create_volume.ACTION]))
            except tfe.NotFound:
                pass
        if (not rescheduled):
            self._update_allocated_capacity(volume)
    LOG.info('Created    volume    successfully.', resource=volume)
    return volume.id
