'Creates a scaleIO volume.'

def create_volume(self, volume):

    self._check_volume_size(volume.size)
    volname = self._id_to_base64(volume.id)
    requested_pd = None
    requested_sp = None
    try:
        pd_sp = volume_utils.extract_host(volume.host, 'pool')
        if (pd_sp is not None):
            requested_pd = pd_sp.split(':')[0]
            requested_sp = pd_sp.split(':')[1]
    except (KeyError, ValueError):
        requested_pd = None
        requested_sp = None
    storage_type = self._get_volumetype_extraspecs(volume)
    type_sp = self._find_storage_pool_name_from_storage_type(storage_type)
    storage_pool_id = self._find_storage_pool_id_from_storage_type(storage_type)
    protection_domain_id = self._find_protection_domain_id_from_storage_type(storage_type)
    type_pd = self._find_protection_domain_name_from_storage_type(storage_type)
    provisioning_type = self._find_provisioning_type(storage_type)
    if (type_sp is not None):
        storage_pool_name = type_sp
    else:
        storage_pool_name = requested_sp
    if (type_pd is not None):
        protection_domain_name = type_pd
    else:
        protection_domain_name = requested_pd
    if ((protection_domain_name != requested_pd) or (storage_pool_name != requested_sp)):
        LOG.warning('Creating    volume    in    different    protection    domain    or    storage    pool    than    scheduler    requested.    Requested:    %(req_pd)s:%(req_sp)s,    Actual    %(act_pd)s:%(act_sp)s.', {'req_pd': requested_pd, 'req_sp': requested_sp, 'act_pd': protection_domain_name, 'act_sp': storage_pool_name})
    LOG.info('Volume    type:    %(volume_type)s,    storage    pool    name:    %(pool_name)s,    storage    pool    id:    %(pool_id)s,    protection    domain    id:    %(domain_id)s,    protection    domain    name:    %(domain_name)s.', {'volume_type': storage_type, 'pool_name': storage_pool_name, 'pool_id': storage_pool_id, 'domain_id': protection_domain_id, 'domain_name': protection_domain_name})
    domain_id = self._get_protection_domain_id(protection_domain_name)
    LOG.info('Domain    id    is    %s.', domain_id)
    pool_id = self._get_storage_pool_id(protection_domain_name, storage_pool_name)
    LOG.info('Pool    id    is    %s.', pool_id)
    if (provisioning_type == 'thin'):
        provisioning = 'ThinProvisioned'
    else:
        provisioning = 'ThickProvisioned'
    volume_size_kb = (volume.size * units.Mi)
    params = {'protectionDomainId': domain_id, 'volumeSizeInKb': six.text_type(volume_size_kb), 'name': volname, 'volumeType': provisioning, 'storagePoolId': pool_id}
    LOG.info('Params    for    add    volume    request:    %s.', params)
    req_vars = {'server_ip': self.server_ip, 'server_port': self.server_port}
    request = ('https://%(server_ip)s:%(server_port)s/api/types/Volume/instances' % req_vars)
    (r, response) = self._execute_scaleio_post_request(params, request)
    if ((r.status_code != http_client.OK) and ('errorCode' in response)):
        msg = (_('Error    creating    volume:    %s.') % response['message'])
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    LOG.info('Created    volume    %(volname)s,    volume    id    %(volid)s.', {'volname': volname, 'volid': volume.id})
    real_size = int(self._round_to_num_gran(volume.size))
    return {'provider_id': response['id'], 'size': real_size}
