2019-08-23 09:35:34 +00:00
|
|
|
from .helpers import deprecated_alias
|
|
|
|
|
|
|
|
|
2019-08-29 13:31:19 +00:00
|
|
|
@deprecated_alias('construct_lvol_store')
|
|
|
|
def bdev_lvol_create_lvstore(client, bdev_name, lvs_name, cluster_sz=None, clear_method=None):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Construct a logical volume store.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
bdev_name: bdev on which to construct logical volume store
|
|
|
|
lvs_name: name of the logical volume store to create
|
|
|
|
cluster_sz: cluster size of the logical volume store in bytes (optional)
|
2019-02-28 09:57:19 +00:00
|
|
|
clear_method: Change clear method for data region. Available: none, unmap, write_zeroes (optional)
|
2018-04-11 21:31:09 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
UUID of created logical volume store.
|
|
|
|
"""
|
|
|
|
params = {'bdev_name': bdev_name, 'lvs_name': lvs_name}
|
|
|
|
if cluster_sz:
|
|
|
|
params['cluster_sz'] = cluster_sz
|
2019-02-28 09:57:19 +00:00
|
|
|
if clear_method:
|
|
|
|
params['clear_method'] = clear_method
|
2019-08-29 13:31:19 +00:00
|
|
|
return client.call('bdev_lvol_create_lvstore', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-29 13:11:18 +00:00
|
|
|
@deprecated_alias('rename_lvol_store')
|
|
|
|
def bdev_lvol_rename_lvstore(client, old_name, new_name):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Rename a logical volume store.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
old_name: existing logical volume store name
|
|
|
|
new_name: new logical volume store name
|
|
|
|
"""
|
2018-01-10 10:03:39 +00:00
|
|
|
params = {
|
2018-04-11 21:31:09 +00:00
|
|
|
'old_name': old_name,
|
|
|
|
'new_name': new_name
|
2018-01-10 10:03:39 +00:00
|
|
|
}
|
2019-08-29 13:11:18 +00:00
|
|
|
return client.call('bdev_lvol_rename_lvstore', params)
|
2018-01-10 10:03:39 +00:00
|
|
|
|
|
|
|
|
2019-08-29 11:01:30 +00:00
|
|
|
@deprecated_alias('construct_lvol_bdev')
|
|
|
|
def bdev_lvol_create(client, lvol_name, size, thin_provision=False, uuid=None, lvs_name=None, clear_method=None):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Create a logical volume on a logical volume store.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
lvol_name: name of logical volume to create
|
|
|
|
size: desired size of logical volume in bytes (will be rounded up to a multiple of cluster size)
|
|
|
|
thin_provision: True to enable thin provisioning
|
|
|
|
uuid: UUID of logical volume store to create logical volume on (optional)
|
|
|
|
lvs_name: name of logical volume store to create logical volume on (optional)
|
|
|
|
|
|
|
|
Either uuid or lvs_name must be specified, but not both.
|
2018-06-21 10:46:59 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created logical volume block device.
|
2018-04-11 21:31:09 +00:00
|
|
|
"""
|
|
|
|
if (uuid and lvs_name) or (not uuid and not lvs_name):
|
|
|
|
raise ValueError("Either uuid or lvs_name must be specified, but not both")
|
|
|
|
|
|
|
|
params = {'lvol_name': lvol_name, 'size': size}
|
|
|
|
if thin_provision:
|
|
|
|
params['thin_provision'] = thin_provision
|
|
|
|
if uuid:
|
|
|
|
params['uuid'] = uuid
|
|
|
|
if lvs_name:
|
|
|
|
params['lvs_name'] = lvs_name
|
2019-01-22 08:47:24 +00:00
|
|
|
if clear_method:
|
|
|
|
params['clear_method'] = clear_method
|
2019-08-29 11:01:30 +00:00
|
|
|
return client.call('bdev_lvol_create', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-29 09:40:39 +00:00
|
|
|
@deprecated_alias('snapshot_lvol_bdev')
|
|
|
|
def bdev_lvol_snapshot(client, lvol_name, snapshot_name):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Capture a snapshot of the current state of a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
lvol_name: logical volume to create a snapshot from
|
|
|
|
snapshot_name: name for the newly created snapshot
|
2018-06-21 10:46:59 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created logical volume snapshot.
|
2018-04-11 21:31:09 +00:00
|
|
|
"""
|
2018-02-22 12:29:49 +00:00
|
|
|
params = {
|
2018-04-11 21:31:09 +00:00
|
|
|
'lvol_name': lvol_name,
|
|
|
|
'snapshot_name': snapshot_name
|
2018-02-22 12:29:49 +00:00
|
|
|
}
|
2019-08-29 09:40:39 +00:00
|
|
|
return client.call('bdev_lvol_snapshot', params)
|
2018-02-22 12:29:49 +00:00
|
|
|
|
|
|
|
|
2019-08-23 09:35:34 +00:00
|
|
|
@deprecated_alias('clone_lvol_bdev')
|
|
|
|
def bdev_lvol_clone(client, snapshot_name, clone_name):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Create a logical volume based on a snapshot.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
snapshot_name: snapshot to clone
|
|
|
|
clone_name: name of logical volume to create
|
2018-06-21 10:46:59 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Name of created logical volume clone.
|
2018-04-11 21:31:09 +00:00
|
|
|
"""
|
2018-02-22 12:29:49 +00:00
|
|
|
params = {
|
2018-04-11 21:31:09 +00:00
|
|
|
'snapshot_name': snapshot_name,
|
|
|
|
'clone_name': clone_name
|
2018-02-22 12:29:49 +00:00
|
|
|
}
|
2019-08-23 09:35:34 +00:00
|
|
|
return client.call('bdev_lvol_clone', params)
|
2018-02-22 12:29:49 +00:00
|
|
|
|
|
|
|
|
2019-08-23 09:57:07 +00:00
|
|
|
@deprecated_alias('rename_lvol_bdev')
|
|
|
|
def bdev_lvol_rename(client, old_name, new_name):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Rename a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
old_name: existing logical volume name
|
|
|
|
new_name: new logical volume name
|
|
|
|
"""
|
2018-01-10 10:02:27 +00:00
|
|
|
params = {
|
2018-04-11 21:31:09 +00:00
|
|
|
'old_name': old_name,
|
|
|
|
'new_name': new_name
|
2018-01-10 10:02:27 +00:00
|
|
|
}
|
2019-08-23 09:57:07 +00:00
|
|
|
return client.call('bdev_lvol_rename', params)
|
2018-01-10 10:02:27 +00:00
|
|
|
|
|
|
|
|
2019-08-26 13:06:42 +00:00
|
|
|
@deprecated_alias('resize_lvol_bdev')
|
|
|
|
def bdev_lvol_resize(client, name, size):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Resize a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of logical volume to resize
|
|
|
|
size: desired size of logical volume in bytes (will be rounded up to a multiple of cluster size)
|
|
|
|
"""
|
2018-02-07 13:57:05 +00:00
|
|
|
params = {
|
2018-04-11 21:31:09 +00:00
|
|
|
'name': name,
|
|
|
|
'size': size,
|
2018-02-07 13:57:05 +00:00
|
|
|
}
|
2019-08-26 13:06:42 +00:00
|
|
|
return client.call('bdev_lvol_resize', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-08-26 12:49:31 +00:00
|
|
|
@deprecated_alias('set_read_only_lvol_bdev')
|
|
|
|
def bdev_lvol_set_read_only(client, name):
|
2019-01-15 15:31:05 +00:00
|
|
|
"""Mark logical volume as read only.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of logical volume to set as read only
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'name': name,
|
|
|
|
}
|
2019-08-26 12:49:31 +00:00
|
|
|
return client.call('bdev_lvol_set_read_only', params)
|
2019-01-15 15:31:05 +00:00
|
|
|
|
|
|
|
|
2019-08-29 10:33:16 +00:00
|
|
|
@deprecated_alias('destroy_lvol_bdev')
|
|
|
|
def bdev_lvol_delete(client, name):
|
2018-04-11 22:12:13 +00:00
|
|
|
"""Destroy a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of logical volume to destroy
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'name': name,
|
|
|
|
}
|
2019-08-29 10:33:16 +00:00
|
|
|
return client.call('bdev_lvol_delete', params)
|
2018-04-11 22:12:13 +00:00
|
|
|
|
|
|
|
|
2019-08-29 09:25:48 +00:00
|
|
|
@deprecated_alias('inflate_lvol_bdev')
|
|
|
|
def bdev_lvol_inflate(client, name):
|
2018-04-23 13:53:21 +00:00
|
|
|
"""Inflate a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of logical volume to inflate
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'name': name,
|
|
|
|
}
|
2019-08-29 09:25:48 +00:00
|
|
|
return client.call('bdev_lvol_inflate', params)
|
2018-04-23 13:53:21 +00:00
|
|
|
|
|
|
|
|
2019-08-26 13:35:53 +00:00
|
|
|
@deprecated_alias('decouple_parent_lvol_bdev')
|
|
|
|
def bdev_lvol_decouple_parent(client, name):
|
2018-05-10 10:01:29 +00:00
|
|
|
"""Decouple parent of a logical volume.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: name of logical volume to decouple parent
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'name': name,
|
|
|
|
}
|
2019-08-26 13:35:53 +00:00
|
|
|
return client.call('bdev_lvol_decouple_parent', params)
|
2018-05-10 10:01:29 +00:00
|
|
|
|
|
|
|
|
2019-08-29 12:07:56 +00:00
|
|
|
@deprecated_alias('destroy_lvol_store')
|
|
|
|
def bdev_lvol_delete_lvstore(client, uuid=None, lvs_name=None):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""Destroy a logical volume store.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
uuid: UUID of logical volume store to destroy (optional)
|
|
|
|
lvs_name: name of logical volume store to destroy (optional)
|
|
|
|
|
|
|
|
Either uuid or lvs_name must be specified, but not both.
|
|
|
|
"""
|
|
|
|
if (uuid and lvs_name) or (not uuid and not lvs_name):
|
|
|
|
raise ValueError("Exactly one of uuid or lvs_name must be specified")
|
|
|
|
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {}
|
2018-04-11 21:31:09 +00:00
|
|
|
if uuid:
|
|
|
|
params['uuid'] = uuid
|
|
|
|
if lvs_name:
|
|
|
|
params['lvs_name'] = lvs_name
|
2019-08-29 12:07:56 +00:00
|
|
|
return client.call('bdev_lvol_delete_lvstore', params)
|
2018-04-11 21:31:09 +00:00
|
|
|
|
|
|
|
|
2019-08-26 11:54:05 +00:00
|
|
|
@deprecated_alias('get_lvol_stores')
|
|
|
|
def bdev_lvol_get_lvstores(client, uuid=None, lvs_name=None):
|
2018-04-11 21:31:09 +00:00
|
|
|
"""List logical volume stores.
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-04-11 21:31:09 +00:00
|
|
|
Args:
|
|
|
|
uuid: UUID of logical volume store to retrieve information about (optional)
|
|
|
|
lvs_name: name of logical volume store to retrieve information about (optional)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-04-11 21:31:09 +00:00
|
|
|
Either uuid or lvs_name may be specified, but not both.
|
|
|
|
If both uuid and lvs_name are omitted, information about all logical volume stores is returned.
|
|
|
|
"""
|
|
|
|
if (uuid and lvs_name):
|
|
|
|
raise ValueError("Exactly one of uuid or lvs_name may be specified")
|
2018-01-29 07:09:35 +00:00
|
|
|
params = {}
|
2018-04-11 21:31:09 +00:00
|
|
|
if uuid:
|
|
|
|
params['uuid'] = uuid
|
|
|
|
if lvs_name:
|
|
|
|
params['lvs_name'] = lvs_name
|
2019-08-26 11:54:05 +00:00
|
|
|
return client.call('bdev_lvol_get_lvstores', params)
|