]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/rpc/lvol.py
1 def construct_lvol_store(client
, bdev_name
, lvs_name
, cluster_sz
=None, clear_method
=None):
2 """Construct a logical volume store.
5 bdev_name: bdev on which to construct logical volume store
6 lvs_name: name of the logical volume store to create
7 cluster_sz: cluster size of the logical volume store in bytes (optional)
8 clear_method: Change clear method for data region. Available: none, unmap, write_zeroes (optional)
11 UUID of created logical volume store.
13 params
= {'bdev_name': bdev_name
, 'lvs_name': lvs_name
}
15 params
['cluster_sz'] = cluster_sz
17 params
['clear_method'] = clear_method
18 return client
.call('construct_lvol_store', params
)
21 def rename_lvol_store(client
, old_name
, new_name
):
22 """Rename a logical volume store.
25 old_name: existing logical volume store name
26 new_name: new logical volume store name
32 return client
.call('rename_lvol_store', params
)
35 def construct_lvol_bdev(client
, lvol_name
, size
, thin_provision
=False, uuid
=None, lvs_name
=None, clear_method
=None):
36 """Create a logical volume on a logical volume store.
39 lvol_name: name of logical volume to create
40 size: desired size of logical volume in bytes (will be rounded up to a multiple of cluster size)
41 thin_provision: True to enable thin provisioning
42 uuid: UUID of logical volume store to create logical volume on (optional)
43 lvs_name: name of logical volume store to create logical volume on (optional)
45 Either uuid or lvs_name must be specified, but not both.
48 Name of created logical volume block device.
50 if (uuid
and lvs_name
) or (not uuid
and not lvs_name
):
51 raise ValueError("Either uuid or lvs_name must be specified, but not both")
53 params
= {'lvol_name': lvol_name
, 'size': size
}
55 params
['thin_provision'] = thin_provision
59 params
['lvs_name'] = lvs_name
61 params
['clear_method'] = clear_method
62 return client
.call('construct_lvol_bdev', params
)
65 def snapshot_lvol_bdev(client
, lvol_name
, snapshot_name
):
66 """Capture a snapshot of the current state of a logical volume.
69 lvol_name: logical volume to create a snapshot from
70 snapshot_name: name for the newly created snapshot
73 Name of created logical volume snapshot.
76 'lvol_name': lvol_name
,
77 'snapshot_name': snapshot_name
79 return client
.call('snapshot_lvol_bdev', params
)
82 def clone_lvol_bdev(client
, snapshot_name
, clone_name
):
83 """Create a logical volume based on a snapshot.
86 snapshot_name: snapshot to clone
87 clone_name: name of logical volume to create
90 Name of created logical volume clone.
93 'snapshot_name': snapshot_name
,
94 'clone_name': clone_name
96 return client
.call('clone_lvol_bdev', params
)
99 def rename_lvol_bdev(client
, old_name
, new_name
):
100 """Rename a logical volume.
103 old_name: existing logical volume name
104 new_name: new logical volume name
107 'old_name': old_name
,
110 return client
.call('rename_lvol_bdev', params
)
113 def resize_lvol_bdev(client
, name
, size
):
114 """Resize a logical volume.
117 name: name of logical volume to resize
118 size: desired size of logical volume in bytes (will be rounded up to a multiple of cluster size)
124 return client
.call('resize_lvol_bdev', params
)
127 def set_read_only_lvol_bdev(client
, name
):
128 """Mark logical volume as read only.
131 name: name of logical volume to set as read only
136 return client
.call('set_read_only_lvol_bdev', params
)
139 def destroy_lvol_bdev(client
, name
):
140 """Destroy a logical volume.
143 name: name of logical volume to destroy
148 return client
.call('destroy_lvol_bdev', params
)
151 def inflate_lvol_bdev(client
, name
):
152 """Inflate a logical volume.
155 name: name of logical volume to inflate
160 return client
.call('inflate_lvol_bdev', params
)
163 def decouple_parent_lvol_bdev(client
, name
):
164 """Decouple parent of a logical volume.
167 name: name of logical volume to decouple parent
172 return client
.call('decouple_parent_lvol_bdev', params
)
175 def destroy_lvol_store(client
, uuid
=None, lvs_name
=None):
176 """Destroy a logical volume store.
179 uuid: UUID of logical volume store to destroy (optional)
180 lvs_name: name of logical volume store to destroy (optional)
182 Either uuid or lvs_name must be specified, but not both.
184 if (uuid
and lvs_name
) or (not uuid
and not lvs_name
):
185 raise ValueError("Exactly one of uuid or lvs_name must be specified")
189 params
['uuid'] = uuid
191 params
['lvs_name'] = lvs_name
192 return client
.call('destroy_lvol_store', params
)
195 def get_lvol_stores(client
, uuid
=None, lvs_name
=None):
196 """List logical volume stores.
199 uuid: UUID of logical volume store to retrieve information about (optional)
200 lvs_name: name of logical volume store to retrieve information about (optional)
202 Either uuid or lvs_name may be specified, but not both.
203 If both uuid and lvs_name are omitted, information about all logical volume stores is returned.
205 if (uuid
and lvs_name
):
206 raise ValueError("Exactly one of uuid or lvs_name may be specified")
209 params
['uuid'] = uuid
211 params
['lvs_name'] = lvs_name
212 return client
.call('get_lvol_stores', params
)