2019-08-09 11:15:35 +00:00
|
|
|
from .helpers import deprecated_alias
|
|
|
|
|
|
|
|
|
2018-06-11 15:58:15 +00:00
|
|
|
def set_bdev_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None):
|
|
|
|
"""Set parameters for the bdev subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_io_pool_size: number of bdev_io structures in shared buffer pool (optional)
|
|
|
|
bdev_io_cache_size: maximum number of bdev_io structures cached per thread (optional)
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
if bdev_io_pool_size:
|
|
|
|
params['bdev_io_pool_size'] = bdev_io_pool_size
|
|
|
|
if bdev_io_cache_size:
|
|
|
|
params['bdev_io_cache_size'] = bdev_io_cache_size
|
|
|
|
|
|
|
|
return client.call('set_bdev_options', params)
|
|
|
|
|
|
|
|
|
2019-08-13 11:18:24 +00:00
|
|
|
@deprecated_alias('construct_compress_bdev')
|
|
|
|
def bdev_compress_create(client, base_bdev_name, pm_path):
|
2018-12-01 15:09:46 +00:00
|
|
|
"""Construct a compress virtual block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev_name: name of the underlying base bdev
|
2019-04-26 15:27:45 +00:00
|
|
|
pm_path: path to persistent memory
|
2018-12-01 15:09:46 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created virtual block device.
|
|
|
|
"""
|
2019-06-06 21:13:22 +00:00
|
|
|
params = {'base_bdev_name': base_bdev_name, 'pm_path': pm_path}
|
2018-12-01 15:09:46 +00:00
|
|
|
|
2019-08-13 11:18:24 +00:00
|
|
|
return client.call('bdev_compress_create', params)
|
2018-12-01 15:09:46 +00:00
|
|
|
|
|
|
|
|
2019-08-13 11:18:24 +00:00
|
|
|
@deprecated_alias('delete_compress_bdev')
|
|
|
|
def bdev_compress_delete(client, name):
|
2018-12-01 15:09:46 +00:00
|
|
|
"""Delete compress virtual block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of compress vbdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-13 11:18:24 +00:00
|
|
|
return client.call('bdev_compress_delete', params)
|
2018-12-01 15:09:46 +00:00
|
|
|
|
|
|
|
|
2019-05-30 00:05:38 +00:00
|
|
|
def set_compress_pmd(client, pmd):
|
|
|
|
"""Set pmd options for the bdev compress.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
pmd: 0 = auto-select, 1 = QAT, 2 = ISAL
|
|
|
|
"""
|
|
|
|
params = {'pmd': pmd}
|
|
|
|
|
|
|
|
return client.call('set_compress_pmd', params)
|
|
|
|
|
|
|
|
|
2019-08-20 17:12:59 +00:00
|
|
|
def bdev_compress_get_orphans(client, name=None):
|
|
|
|
"""Get a list of comp bdevs that do not have a pmem file (aka orphaned).
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: comp bdev name to query (optional; if omitted, query all comp bdevs)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of comp bdev names.
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
if name:
|
|
|
|
params['name'] = name
|
|
|
|
return client.call('bdev_compress_get_orphans', params)
|
|
|
|
|
|
|
|
|
2019-08-13 12:34:24 +00:00
|
|
|
@deprecated_alias('construct_crypto_bdev')
|
|
|
|
def bdev_crypto_create(client, base_bdev_name, name, crypto_pmd, key):
|
2018-03-07 23:44:06 +00:00
|
|
|
"""Construct a crypto virtual block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev_name: name of the underlying base bdev
|
2018-09-17 22:29:29 +00:00
|
|
|
name: name for the crypto vbdev
|
2018-03-07 23:44:06 +00:00
|
|
|
crypto_pmd: name of of the DPDK crypto driver to use
|
|
|
|
key: key
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created virtual block device.
|
|
|
|
"""
|
2018-09-17 22:29:29 +00:00
|
|
|
params = {'base_bdev_name': base_bdev_name, 'name': name, 'crypto_pmd': crypto_pmd, 'key': key}
|
2018-03-07 23:44:06 +00:00
|
|
|
|
2019-08-13 12:34:24 +00:00
|
|
|
return client.call('bdev_crypto_create', params)
|
2018-03-07 23:44:06 +00:00
|
|
|
|
|
|
|
|
2019-08-13 12:34:24 +00:00
|
|
|
@deprecated_alias('delete_crypto_bdev')
|
|
|
|
def bdev_crypto_delete(client, name):
|
2018-03-07 23:44:06 +00:00
|
|
|
"""Delete crypto virtual block device.
|
|
|
|
|
|
|
|
Args:
|
2018-09-17 22:29:29 +00:00
|
|
|
name: name of crypto vbdev to delete
|
2018-03-07 23:44:06 +00:00
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-13 12:34:24 +00:00
|
|
|
return client.call('bdev_crypto_delete', params)
|
2018-03-07 23:44:06 +00:00
|
|
|
|
|
|
|
|
2019-08-28 08:30:48 +00:00
|
|
|
@deprecated_alias('construct_ocf_bdev')
|
|
|
|
def bdev_ocf_create(client, name, mode, cache_bdev_name, core_bdev_name):
|
2018-10-29 20:23:51 +00:00
|
|
|
"""Add an OCF block device
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of constructed OCF bdev
|
2019-05-23 23:37:30 +00:00
|
|
|
mode: OCF cache mode: {'wb', 'wt', 'pt'}
|
2018-10-29 20:23:51 +00:00
|
|
|
cache_bdev_name: name of underlying cache bdev
|
|
|
|
core_bdev_name: name of underlying core bdev
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created block device
|
|
|
|
"""
|
|
|
|
params = {'name': name, 'mode': mode, 'cache_bdev_name': cache_bdev_name, 'core_bdev_name': core_bdev_name}
|
|
|
|
|
2019-08-28 08:30:48 +00:00
|
|
|
return client.call('bdev_ocf_create', params)
|
2018-10-29 20:23:51 +00:00
|
|
|
|
|
|
|
|
2019-08-28 08:30:48 +00:00
|
|
|
@deprecated_alias('delete_ocf_bdev')
|
|
|
|
def bdev_ocf_delete(client, name):
|
2018-10-29 20:23:51 +00:00
|
|
|
"""Delete an OCF device
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of OCF bdev
|
|
|
|
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
|
2019-08-28 08:30:48 +00:00
|
|
|
return client.call('bdev_ocf_delete', params)
|
2018-10-29 20:23:51 +00:00
|
|
|
|
|
|
|
|
2019-08-28 08:43:22 +00:00
|
|
|
@deprecated_alias('get_ocf_stats')
|
|
|
|
def bdev_ocf_get_stats(client, name):
|
2018-12-28 18:59:40 +00:00
|
|
|
"""Get statistics of chosen OCF block device
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of OCF bdev
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Statistics as json object
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
|
2019-08-28 08:43:22 +00:00
|
|
|
return client.call('bdev_ocf_get_stats', params)
|
2018-12-28 18:59:40 +00:00
|
|
|
|
|
|
|
|
2019-08-28 08:43:22 +00:00
|
|
|
@deprecated_alias('get_ocf_stats')
|
|
|
|
def bdev_ocf_get_bdevs(client, name=None):
|
2019-01-22 21:11:37 +00:00
|
|
|
"""Get list of OCF devices including unregistered ones
|
|
|
|
|
|
|
|
Args:
|
2019-03-11 17:16:32 +00:00
|
|
|
name: name of OCF vbdev or name of cache device or name of core device (optional)
|
2019-01-22 21:11:37 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Array of OCF devices with their current status
|
|
|
|
"""
|
2019-03-11 17:16:32 +00:00
|
|
|
params = None
|
|
|
|
if name:
|
|
|
|
params = {'name': name}
|
2019-08-28 08:43:22 +00:00
|
|
|
return client.call('bdev_ocf_get_bdevs', params)
|
2019-01-22 21:11:37 +00:00
|
|
|
|
|
|
|
|
2019-08-09 11:15:35 +00:00
|
|
|
@deprecated_alias('construct_malloc_bdev')
|
|
|
|
def bdev_malloc_create(client, num_blocks, block_size, name=None, uuid=None):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct a malloc block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
num_blocks: size of block device in blocks
|
|
|
|
block_size: block size of device; must be a power of 2 and at least 512
|
|
|
|
name: name of block device (optional)
|
|
|
|
uuid: UUID of block device (optional)
|
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
|
|
|
params = {'num_blocks': num_blocks, 'block_size': block_size}
|
|
|
|
if name:
|
|
|
|
params['name'] = name
|
|
|
|
if uuid:
|
|
|
|
params['uuid'] = uuid
|
2019-08-09 11:15:35 +00:00
|
|
|
return client.call('bdev_malloc_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-19 08:19:29 +00:00
|
|
|
@deprecated_alias('delete_malloc_bdev')
|
|
|
|
def bdev_malloc_delete(client, name):
|
2018-06-15 07:58:57 +00:00
|
|
|
"""Delete malloc block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of malloc bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-19 08:19:29 +00:00
|
|
|
return client.call('bdev_malloc_delete', params)
|
2018-06-15 07:58:57 +00:00
|
|
|
|
|
|
|
|
2019-08-20 13:06:22 +00:00
|
|
|
@deprecated_alias('construct_null_bdev')
|
|
|
|
def bdev_null_create(client, num_blocks, block_size, name, uuid=None, md_size=None,
|
|
|
|
dif_type=None, dif_is_head_of_md=None):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct a null block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
num_blocks: size of block device in blocks
|
2019-07-31 11:16:06 +00:00
|
|
|
block_size: block size of device; data part size must be a power of 2 and at least 512
|
2018-05-21 20:28:21 +00:00
|
|
|
name: name of block device
|
|
|
|
uuid: UUID of block device (optional)
|
2019-07-31 11:16:06 +00:00
|
|
|
md_size: metadata size of device (optional)
|
2019-08-01 08:58:16 +00:00
|
|
|
dif_type: protection information type (optional)
|
|
|
|
dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
|
2018-05-21 20:28:21 +00:00
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
|
|
|
params = {'name': name, 'num_blocks': num_blocks,
|
|
|
|
'block_size': block_size}
|
|
|
|
if uuid:
|
|
|
|
params['uuid'] = uuid
|
2019-07-31 11:16:06 +00:00
|
|
|
if md_size:
|
|
|
|
params['md_size'] = md_size
|
2019-08-01 08:58:16 +00:00
|
|
|
if dif_type:
|
|
|
|
params['dif_type'] = dif_type
|
|
|
|
if dif_is_head_of_md:
|
|
|
|
params['dif_is_head_of_md'] = dif_is_head_of_md
|
2019-08-20 13:06:22 +00:00
|
|
|
return client.call('bdev_null_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-20 13:06:22 +00:00
|
|
|
@deprecated_alias('delete_null_bdev')
|
|
|
|
def bdev_null_delete(client, name):
|
2018-06-22 07:42:57 +00:00
|
|
|
"""Remove null bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of null bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-20 13:06:22 +00:00
|
|
|
return client.call('bdev_null_delete', params)
|
2018-06-22 07:42:57 +00:00
|
|
|
|
|
|
|
|
2018-05-08 11:30:29 +00:00
|
|
|
def get_raid_bdevs(client, category):
|
|
|
|
"""Get list of raid bdevs based on category
|
|
|
|
|
|
|
|
Args:
|
|
|
|
category: any one of all or online or configuring or offline
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of raid bdev names
|
|
|
|
"""
|
|
|
|
params = {'category': category}
|
|
|
|
return client.call('get_raid_bdevs', params)
|
|
|
|
|
|
|
|
|
2018-12-19 18:04:18 +00:00
|
|
|
def construct_raid_bdev(client, name, raid_level, base_bdevs, strip_size=None, strip_size_kb=None):
|
2019-04-26 22:30:49 +00:00
|
|
|
"""Construct raid bdev. Either strip size arg will work but one is required.
|
2018-05-08 11:30:29 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name: user defined raid bdev name
|
2018-12-19 18:04:18 +00:00
|
|
|
strip_size (deprecated): strip size of raid bdev in KB, supported values like 8, 16, 32, 64, 128, 256, etc
|
|
|
|
strip_size_kb: strip size of raid bdev in KB, supported values like 8, 16, 32, 64, 128, 256, etc
|
2018-05-08 11:30:29 +00:00
|
|
|
raid_level: raid level of raid bdev, supported values 0
|
|
|
|
base_bdevs: Space separated names of Nvme bdevs in double quotes, like "Nvme0n1 Nvme1n1 Nvme2n1"
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
None
|
|
|
|
"""
|
2018-12-19 18:04:18 +00:00
|
|
|
params = {'name': name, 'raid_level': raid_level, 'base_bdevs': base_bdevs}
|
|
|
|
|
|
|
|
if strip_size:
|
|
|
|
params['strip_size'] = strip_size
|
|
|
|
|
|
|
|
if strip_size_kb:
|
|
|
|
params['strip_size_kb'] = strip_size_kb
|
2018-05-08 11:30:29 +00:00
|
|
|
|
|
|
|
return client.call('construct_raid_bdev', params)
|
|
|
|
|
|
|
|
|
|
|
|
def destroy_raid_bdev(client, name):
|
2019-04-26 22:30:49 +00:00
|
|
|
"""Destroy raid bdev
|
2018-05-08 11:30:29 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name: raid bdev name
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
None
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
return client.call('destroy_raid_bdev', params)
|
|
|
|
|
|
|
|
|
2019-08-13 09:38:42 +00:00
|
|
|
@deprecated_alias('construct_aio_bdev')
|
|
|
|
def bdev_aio_create(client, filename, name, block_size=None):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct a Linux AIO block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
filename: path to device or file (ex: /dev/sda)
|
|
|
|
name: name of block device
|
|
|
|
block_size: block size of device (optional; autodetected if omitted)
|
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
|
|
|
params = {'name': name,
|
|
|
|
'filename': filename}
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
if block_size:
|
|
|
|
params['block_size'] = block_size
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2019-08-13 09:38:42 +00:00
|
|
|
return client.call('bdev_aio_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-13 09:38:42 +00:00
|
|
|
@deprecated_alias('delete_aio_bdev')
|
|
|
|
def bdev_aio_delete(client, name):
|
2018-06-14 14:15:36 +00:00
|
|
|
"""Remove aio bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of aio bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-13 09:38:42 +00:00
|
|
|
return client.call('bdev_aio_delete', params)
|
2018-06-14 14:15:36 +00:00
|
|
|
|
|
|
|
|
2019-08-22 12:44:02 +00:00
|
|
|
@deprecated_alias('set_bdev_nvme_options')
|
|
|
|
def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, retry_count=None,
|
2019-07-10 05:13:31 +00:00
|
|
|
nvme_adminq_poll_period_us=None, nvme_ioq_poll_period_us=None, io_queue_requests=None):
|
2018-07-09 21:04:33 +00:00
|
|
|
"""Set options for the bdev nvme. This is startup command.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
action_on_timeout: action to take on command time out. Valid values are: none, reset, abort (optional)
|
|
|
|
timeout_us: Timeout for each command, in microseconds. If 0, don't track timeouts (optional)
|
|
|
|
retry_count: The number of attempts per I/O when an I/O fails (optional)
|
2019-03-11 22:26:53 +00:00
|
|
|
nvme_adminq_poll_period_us: How often the admin queue is polled for asynchronous events in microseconds (optional)
|
|
|
|
nvme_ioq_poll_period_us: How often to poll I/O queues for completions in microseconds (optional)
|
2019-07-10 05:13:31 +00:00
|
|
|
io_queue_requests: The number of requests allocated for each NVMe I/O queue. Default: 512 (optional)
|
2018-07-09 21:04:33 +00:00
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
if action_on_timeout:
|
|
|
|
params['action_on_timeout'] = action_on_timeout
|
|
|
|
|
|
|
|
if timeout_us:
|
|
|
|
params['timeout_us'] = timeout_us
|
|
|
|
|
|
|
|
if retry_count:
|
|
|
|
params['retry_count'] = retry_count
|
|
|
|
|
|
|
|
if nvme_adminq_poll_period_us:
|
|
|
|
params['nvme_adminq_poll_period_us'] = nvme_adminq_poll_period_us
|
|
|
|
|
2019-03-11 22:26:53 +00:00
|
|
|
if nvme_ioq_poll_period_us:
|
|
|
|
params['nvme_ioq_poll_period_us'] = nvme_ioq_poll_period_us
|
|
|
|
|
2019-07-10 05:13:31 +00:00
|
|
|
if io_queue_requests:
|
|
|
|
params['io_queue_requests'] = io_queue_requests
|
|
|
|
|
2019-08-22 12:44:02 +00:00
|
|
|
return client.call('bdev_nvme_set_options', params)
|
2018-07-09 21:04:33 +00:00
|
|
|
|
|
|
|
|
2019-08-22 13:04:52 +00:00
|
|
|
@deprecated_alias('bdev_nvme_set_hotplug')
|
|
|
|
def bdev_nvme_set_hotplug(client, enable, period_us=None):
|
2018-07-12 12:26:19 +00:00
|
|
|
"""Set options for the bdev nvme. This is startup command.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
enable: True to enable hotplug, False to disable.
|
|
|
|
period_us: how often the hotplug is processed for insert and remove events. Set 0 to reset to default. (optional)
|
|
|
|
"""
|
|
|
|
params = {'enable': enable}
|
|
|
|
|
|
|
|
if period_us:
|
|
|
|
params['period_us'] = period_us
|
|
|
|
|
2019-08-22 13:04:52 +00:00
|
|
|
return client.call('bdev_nvme_set_hotplug', params)
|
2018-07-12 12:26:19 +00:00
|
|
|
|
|
|
|
|
2019-02-08 01:06:45 +00:00
|
|
|
def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
|
|
|
|
subnqn=None, hostnqn=None, hostaddr=None, hostsvcid=None,
|
|
|
|
prchk_reftag=None, prchk_guard=None):
|
2018-11-01 16:16:56 +00:00
|
|
|
"""Construct NVMe namespace block devices.
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
Args:
|
|
|
|
name: bdev name prefix; "n" + namespace ID will be appended to create unique names
|
|
|
|
trtype: transport type ("PCIe", "RDMA")
|
|
|
|
traddr: transport address (PCI BDF or IP address)
|
|
|
|
adrfam: address family ("IPv4", "IPv6", "IB", or "FC") (optional for PCIe)
|
|
|
|
trsvcid: transport service ID (port number for IP-based addresses; optional for PCIe)
|
|
|
|
subnqn: subsystem NQN to connect to (optional)
|
2018-12-18 23:49:15 +00:00
|
|
|
hostnqn: NQN to connect from (optional)
|
2018-12-04 23:30:11 +00:00
|
|
|
hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional)
|
|
|
|
hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional)
|
2019-02-08 01:06:45 +00:00
|
|
|
prchk_reftag: Enable checking of PI reference tag for I/O processing (optional)
|
|
|
|
prchk_guard: Enable checking of PI guard for I/O processing (optional)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
Returns:
|
2018-11-01 16:16:56 +00:00
|
|
|
Names of created block devices.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
|
|
|
params = {'name': name,
|
|
|
|
'trtype': trtype,
|
|
|
|
'traddr': traddr}
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-12-18 23:49:15 +00:00
|
|
|
if hostnqn:
|
|
|
|
params['hostnqn'] = hostnqn
|
|
|
|
|
2018-12-04 23:30:11 +00:00
|
|
|
if hostaddr:
|
|
|
|
params['hostaddr'] = hostaddr
|
|
|
|
|
|
|
|
if hostsvcid:
|
|
|
|
params['hostsvcid'] = hostsvcid
|
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
if adrfam:
|
|
|
|
params['adrfam'] = adrfam
|
|
|
|
|
|
|
|
if trsvcid:
|
|
|
|
params['trsvcid'] = trsvcid
|
|
|
|
|
|
|
|
if subnqn:
|
|
|
|
params['subnqn'] = subnqn
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2019-02-08 01:06:45 +00:00
|
|
|
if prchk_reftag:
|
|
|
|
params['prchk_reftag'] = prchk_reftag
|
|
|
|
|
|
|
|
if prchk_guard:
|
|
|
|
params['prchk_guard'] = prchk_guard
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('construct_nvme_bdev', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-07-26 12:54:20 +00:00
|
|
|
def delete_nvme_controller(client, name):
|
|
|
|
"""Remove NVMe controller from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: controller name
|
|
|
|
"""
|
|
|
|
|
|
|
|
params = {'name': name}
|
|
|
|
return client.call('delete_nvme_controller', params)
|
|
|
|
|
|
|
|
|
2019-09-11 06:27:20 +00:00
|
|
|
@deprecated_alias('construct_rbd_bdev')
|
|
|
|
def bdev_rbd_create(client, pool_name, rbd_name, block_size, name=None, user=None, config=None):
|
|
|
|
"""Create a Ceph RBD block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
pool_name: Ceph RBD pool name
|
|
|
|
rbd_name: Ceph RBD image name
|
|
|
|
block_size: block size of RBD volume
|
|
|
|
name: name of block device (optional)
|
2018-10-26 12:06:15 +00:00
|
|
|
user: Ceph user name (optional)
|
|
|
|
config: map of config keys to values (optional)
|
2018-05-21 20:28:21 +00:00
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'pool_name': pool_name,
|
|
|
|
'rbd_name': rbd_name,
|
|
|
|
'block_size': block_size,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2018-02-23 19:05:47 +00:00
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
if name:
|
|
|
|
params['name'] = name
|
2018-10-26 12:06:15 +00:00
|
|
|
if user is not None:
|
|
|
|
params['user_id'] = user
|
|
|
|
if config is not None:
|
|
|
|
params['config'] = config
|
2018-02-23 19:05:47 +00:00
|
|
|
|
2019-09-11 06:27:20 +00:00
|
|
|
return client.call('bdev_rbd_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-11 08:00:10 +00:00
|
|
|
@deprecated_alias('delete_rbd_bdev')
|
|
|
|
def bdev_rbd_delete(client, name):
|
2018-06-22 11:51:35 +00:00
|
|
|
"""Remove rbd bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of rbd bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-09-11 08:00:10 +00:00
|
|
|
return client.call('bdev_rbd_delete', params)
|
2018-06-22 11:51:35 +00:00
|
|
|
|
|
|
|
|
2019-08-16 09:58:53 +00:00
|
|
|
@deprecated_alias('construct_error_bdev')
|
|
|
|
def bdev_error_create(client, base_name):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct an error injection block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_name: base bdev name
|
|
|
|
"""
|
|
|
|
params = {'base_name': base_name}
|
2019-08-16 09:58:53 +00:00
|
|
|
return client.call('bdev_error_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-05-07 22:43:11 +00:00
|
|
|
def bdev_delay_create(client, base_bdev_name, name, avg_read_latency, p99_read_latency, avg_write_latency, p99_write_latency):
|
|
|
|
"""Construct a delay block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev_name: name of the existing bdev
|
|
|
|
name: name of block device
|
|
|
|
avg_read_latency: complete 99% of read ops with this delay
|
|
|
|
p99_read_latency: complete 1% of read ops with this delay
|
|
|
|
avg_write_latency: complete 99% of write ops with this delay
|
|
|
|
p99_write_latency: complete 1% of write ops with this delay
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created block device.
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'base_bdev_name': base_bdev_name,
|
|
|
|
'name': name,
|
|
|
|
'avg_read_latency': avg_read_latency,
|
|
|
|
'p99_read_latency': p99_read_latency,
|
|
|
|
'avg_write_latency': avg_write_latency,
|
|
|
|
'p99_write_latency': p99_write_latency,
|
|
|
|
}
|
|
|
|
return client.call('bdev_delay_create', params)
|
|
|
|
|
|
|
|
|
|
|
|
def bdev_delay_delete(client, name):
|
|
|
|
"""Remove delay bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of delay bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
return client.call('bdev_delay_delete', params)
|
|
|
|
|
|
|
|
|
2019-08-07 21:11:19 +00:00
|
|
|
def bdev_delay_update_latency(client, delay_bdev_name, latency_type, latency_us):
|
|
|
|
"""Update the latency value for a delay block device
|
|
|
|
|
|
|
|
Args:
|
|
|
|
delay_bdev_name: name of the delay bdev
|
|
|
|
latency_type: 'one of: avg_read, avg_write, p99_read, p99_write. No other values accepted.'
|
|
|
|
latency_us: 'new latency value.'
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True if successful, or a specific error otherwise.
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'delay_bdev_name': delay_bdev_name,
|
|
|
|
'latency_type': latency_type,
|
|
|
|
'latency_us': latency_us,
|
|
|
|
}
|
|
|
|
return client.call('bdev_delay_update_latency', params)
|
|
|
|
|
|
|
|
|
2019-08-16 09:58:53 +00:00
|
|
|
@deprecated_alias('delete_error_bdev')
|
|
|
|
def bdev_error_delete(client, name):
|
2018-06-15 14:06:38 +00:00
|
|
|
"""Remove error bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of error bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-16 09:58:53 +00:00
|
|
|
return client.call('bdev_error_delete', params)
|
2018-06-15 14:06:38 +00:00
|
|
|
|
|
|
|
|
2019-08-22 10:51:25 +00:00
|
|
|
@deprecated_alias('construct_iscsi_bdev')
|
|
|
|
def bdev_iscsi_create(client, name, url, initiator_iqn):
|
2018-04-05 21:41:19 +00:00
|
|
|
"""Construct a iSCSI block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of block device
|
|
|
|
url: iSCSI URL
|
|
|
|
initiator_iqn: IQN name to be used by initiator
|
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-04-05 21:41:19 +00:00
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'name': name,
|
|
|
|
'url': url,
|
|
|
|
'initiator_iqn': initiator_iqn,
|
|
|
|
}
|
2019-08-22 10:51:25 +00:00
|
|
|
return client.call('bdev_iscsi_create', params)
|
2018-04-05 21:41:19 +00:00
|
|
|
|
|
|
|
|
2019-08-22 10:51:25 +00:00
|
|
|
@deprecated_alias('delete_iscsi_bdev')
|
|
|
|
def bdev_iscsi_delete(client, name):
|
2018-06-18 08:07:33 +00:00
|
|
|
"""Remove iSCSI bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of iSCSI bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-22 10:51:25 +00:00
|
|
|
return client.call('bdev_iscsi_delete', params)
|
2018-06-18 08:07:33 +00:00
|
|
|
|
|
|
|
|
2019-08-29 09:54:36 +00:00
|
|
|
@deprecated_alias('construct_pmem_bdev')
|
|
|
|
def bdev_pmem_create(client, pmem_file, name):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct a libpmemblk block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
pmem_file: path to pmemblk pool file
|
|
|
|
name: name of block device
|
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'pmem_file': pmem_file,
|
|
|
|
'name': name
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2019-08-29 09:54:36 +00:00
|
|
|
return client.call('bdev_pmem_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-29 10:19:03 +00:00
|
|
|
@deprecated_alias('delete_pmem_bdev')
|
|
|
|
def bdev_pmem_delete(client, name):
|
2018-06-22 09:48:31 +00:00
|
|
|
"""Remove pmem bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of pmem bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-08-29 10:19:03 +00:00
|
|
|
return client.call('bdev_pmem_delete', params)
|
2018-06-22 09:48:31 +00:00
|
|
|
|
|
|
|
|
2018-10-10 17:54:43 +00:00
|
|
|
def construct_passthru_bdev(client, base_bdev_name, name):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Construct a pass-through block device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev_name: name of the existing bdev
|
2018-10-10 17:54:43 +00:00
|
|
|
name: name of block device
|
2018-05-21 20:28:21 +00:00
|
|
|
|
|
|
|
Returns:
|
2018-06-21 10:46:59 +00:00
|
|
|
Name of created block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
2018-04-08 01:53:31 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'base_bdev_name': base_bdev_name,
|
2018-10-10 17:54:43 +00:00
|
|
|
'name': name,
|
2018-04-08 01:53:31 +00:00
|
|
|
}
|
|
|
|
return client.call('construct_passthru_bdev', params)
|
|
|
|
|
|
|
|
|
2018-06-22 12:30:19 +00:00
|
|
|
def delete_passthru_bdev(client, name):
|
|
|
|
"""Remove pass through bdev from the system.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of pass through bdev to delete
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
return client.call('delete_passthru_bdev', params)
|
|
|
|
|
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
def construct_split_vbdev(client, base_bdev, split_count, split_size_mb=None):
|
|
|
|
"""Construct split block devices from a base bdev.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev: name of bdev to split
|
|
|
|
split_count: number of split bdevs to create
|
|
|
|
split_size_mb: size of each split volume in MiB (optional)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of created block devices.
|
|
|
|
"""
|
2018-03-16 18:27:57 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'base_bdev': base_bdev,
|
|
|
|
'split_count': split_count,
|
2018-03-16 18:27:57 +00:00
|
|
|
}
|
2018-05-25 13:31:23 +00:00
|
|
|
if split_size_mb:
|
2018-05-21 20:28:21 +00:00
|
|
|
params['split_size_mb'] = split_size_mb
|
2018-03-16 18:27:57 +00:00
|
|
|
|
|
|
|
return client.call('construct_split_vbdev', params)
|
|
|
|
|
|
|
|
|
2018-05-21 20:28:21 +00:00
|
|
|
def destruct_split_vbdev(client, base_bdev):
|
|
|
|
"""Destroy split block devices.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
base_bdev: name of previously split bdev
|
|
|
|
"""
|
2018-03-16 18:27:57 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'base_bdev': base_bdev,
|
2018-03-16 18:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return client.call('destruct_split_vbdev', params)
|
|
|
|
|
|
|
|
|
2019-07-04 11:37:23 +00:00
|
|
|
def construct_ftl_bdev(client, name, trtype, traddr, punits, **kwargs):
|
2018-10-29 14:35:27 +00:00
|
|
|
"""Construct FTL bdev
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of the bdev
|
|
|
|
trtype: transport type
|
|
|
|
traddr: transport address
|
|
|
|
punit: parallel unit range
|
2019-07-04 11:37:23 +00:00
|
|
|
kwargs: optional parameters
|
2018-10-29 14:35:27 +00:00
|
|
|
"""
|
|
|
|
params = {'name': name,
|
|
|
|
'trtype': trtype,
|
|
|
|
'traddr': traddr,
|
2019-06-28 08:16:46 +00:00
|
|
|
'punits': punits}
|
2019-07-04 11:37:23 +00:00
|
|
|
for key, value in kwargs.items():
|
|
|
|
if value is not None:
|
|
|
|
params[key] = value
|
2019-03-15 16:37:44 +00:00
|
|
|
|
2018-10-29 14:35:27 +00:00
|
|
|
return client.call('construct_ftl_bdev', params)
|
|
|
|
|
|
|
|
|
|
|
|
def delete_ftl_bdev(client, name):
|
|
|
|
"""Delete FTL bdev
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of the bdev
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
|
|
|
|
|
|
|
return client.call('delete_ftl_bdev', params)
|
|
|
|
|
|
|
|
|
2019-09-11 09:29:55 +00:00
|
|
|
@deprecated_alias('get_bdevs')
|
|
|
|
def bdev_get_bdevs(client, name=None):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Get information about block devices.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: bdev name to query (optional; if omitted, query all bdevs)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of bdev information objects.
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {}
|
2018-05-21 20:28:21 +00:00
|
|
|
if name:
|
|
|
|
params['name'] = name
|
2019-09-11 09:29:55 +00:00
|
|
|
return client.call('bdev_get_bdevs', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-11 08:28:07 +00:00
|
|
|
@deprecated_alias('get_bdevs_iostat')
|
|
|
|
def bdev_get_iostat(client, name=None):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Get I/O statistics for block devices.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: bdev name to query (optional; if omitted, query all bdevs)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
I/O statistics for the requested block devices.
|
|
|
|
"""
|
2017-12-28 09:03:17 +00:00
|
|
|
params = {}
|
2018-05-21 20:28:21 +00:00
|
|
|
if name:
|
|
|
|
params['name'] = name
|
2019-09-11 08:28:07 +00:00
|
|
|
return client.call('bdev_get_iostat', params)
|
2017-12-28 09:03:17 +00:00
|
|
|
|
|
|
|
|
2019-09-11 10:39:52 +00:00
|
|
|
@deprecated_alias('enable_bdev_histogram')
|
|
|
|
def bdev_enable_histogram(client, name, enable):
|
2019-01-18 13:00:04 +00:00
|
|
|
"""Control whether histogram is enabled for specified bdev.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of bdev
|
|
|
|
"""
|
|
|
|
params = {'name': name, "enable": enable}
|
2019-09-11 10:39:52 +00:00
|
|
|
return client.call('bdev_enable_histogram', params)
|
2019-01-18 13:00:04 +00:00
|
|
|
|
|
|
|
|
2019-09-11 10:54:13 +00:00
|
|
|
@deprecated_alias('get_bdev_histogram')
|
|
|
|
def bdev_get_histogram(client, name):
|
2019-01-18 13:00:04 +00:00
|
|
|
"""Get histogram for specified bdev.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of bdev
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-09-11 10:54:13 +00:00
|
|
|
return client.call('bdev_get_histogram', params)
|
2019-01-18 13:00:04 +00:00
|
|
|
|
|
|
|
|
2019-08-16 09:58:53 +00:00
|
|
|
@deprecated_alias('bdev_inject_error')
|
|
|
|
def bdev_error_inject_error(client, name, io_type, error_type, num=1):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Inject an error via an error bdev.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of error bdev
|
|
|
|
io_type: one of "clear", "read", "write", "unmap", "flush", or "all"
|
|
|
|
error_type: one of "failure" or "pending"
|
|
|
|
num: number of commands to fail
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'name': name,
|
|
|
|
'io_type': io_type,
|
|
|
|
'error_type': error_type,
|
|
|
|
'num': num,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
|
|
|
|
2019-08-16 09:58:53 +00:00
|
|
|
return client.call('bdev_error_inject_error', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-02-14 21:34:55 +00:00
|
|
|
|
2019-09-11 10:24:12 +00:00
|
|
|
@deprecated_alias('set_bdev_qd_sampling_period')
|
|
|
|
def bdev_set_qd_sampling_period(client, name, period):
|
2018-07-05 18:41:41 +00:00
|
|
|
"""Enable queue depth tracking on a specified bdev.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of a bdev on which to track queue depth.
|
|
|
|
period: period (in microseconds) at which to update the queue depth reading. If set to 0, polling will be disabled.
|
|
|
|
"""
|
|
|
|
|
|
|
|
params = {}
|
|
|
|
params['name'] = name
|
|
|
|
params['period'] = period
|
2019-09-11 10:24:12 +00:00
|
|
|
return client.call('bdev_set_qd_sampling_period', params)
|
2018-07-05 18:41:41 +00:00
|
|
|
|
|
|
|
|
2019-09-11 10:32:34 +00:00
|
|
|
@deprecated_alias('set_bdev_qos_limit')
|
|
|
|
def bdev_set_qos_limit(
|
2018-06-22 02:15:02 +00:00
|
|
|
client,
|
|
|
|
name,
|
|
|
|
rw_ios_per_sec=None,
|
|
|
|
rw_mbytes_per_sec=None,
|
|
|
|
r_mbytes_per_sec=None,
|
|
|
|
w_mbytes_per_sec=None):
|
2018-06-22 02:15:02 +00:00
|
|
|
"""Set QoS rate limit on a block device.
|
2018-05-21 20:28:21 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of block device
|
2018-06-22 02:15:02 +00:00
|
|
|
rw_ios_per_sec: R/W IOs per second limit (>=10000, example: 20000). 0 means unlimited.
|
|
|
|
rw_mbytes_per_sec: R/W megabytes per second limit (>=10, example: 100). 0 means unlimited.
|
2018-06-22 02:15:02 +00:00
|
|
|
r_mbytes_per_sec: Read megabytes per second limit (>=10, example: 100). 0 means unlimited.
|
|
|
|
w_mbytes_per_sec: Write megabytes per second limit (>=10, example: 100). 0 means unlimited.
|
2018-05-21 20:28:21 +00:00
|
|
|
"""
|
2017-12-29 08:02:08 +00:00
|
|
|
params = {}
|
2018-05-21 20:28:21 +00:00
|
|
|
params['name'] = name
|
2018-06-22 02:15:02 +00:00
|
|
|
if rw_ios_per_sec is not None:
|
|
|
|
params['rw_ios_per_sec'] = rw_ios_per_sec
|
|
|
|
if rw_mbytes_per_sec is not None:
|
|
|
|
params['rw_mbytes_per_sec'] = rw_mbytes_per_sec
|
2018-06-22 02:15:02 +00:00
|
|
|
if r_mbytes_per_sec is not None:
|
|
|
|
params['r_mbytes_per_sec'] = r_mbytes_per_sec
|
|
|
|
if w_mbytes_per_sec is not None:
|
|
|
|
params['w_mbytes_per_sec'] = w_mbytes_per_sec
|
2019-09-11 10:32:34 +00:00
|
|
|
return client.call('bdev_set_qos_limit', params)
|
2017-12-29 08:02:08 +00:00
|
|
|
|
|
|
|
|
2019-08-27 20:43:52 +00:00
|
|
|
@deprecated_alias('apply_firmware')
|
|
|
|
def bdev_nvme_apply_firmware(client, bdev_name, filename):
|
2018-05-21 20:28:21 +00:00
|
|
|
"""Download and commit firmware to NVMe device.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: name of NVMe block device
|
|
|
|
filename: filename of the firmware to download
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-05-21 20:28:21 +00:00
|
|
|
'filename': filename,
|
|
|
|
'bdev_name': bdev_name,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2019-08-27 20:43:52 +00:00
|
|
|
return client.call('bdev_nvme_apply_firmware', params)
|