Skip to content

Commit e705e81

Browse files
authored
Merge pull request #316 from pascalb97/feature/snapshot-as-volume-chain
Support for new parameter `snapshot-as-volume-chain` in LVM storage configuration
2 parents 340d799 + 1b9dc73 commit e705e81

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

library/proxmox_storage.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@
155155
type: bool
156156
description:
157157
- Use ZFS thin-provisioning.
158+
snapshot_as_volume_chain:
159+
required: false
160+
type: bool
161+
default: false
162+
description:
163+
- Enable support for creating storage-vendor agnostic snapshot through volume backing-chains.
164+
- Only supported for LVM storage type.
158165
is_mountpoint:
159166
required: false
160167
type: bool
@@ -227,6 +234,13 @@
227234
type: lvm
228235
content: [ "images", "rootdir" ]
229236
vgname: vg1
237+
- name: Create an LVM storage type with snapshot support
238+
proxmox_storage:
239+
name: lvm1
240+
type: lvm
241+
content: [ "images", "rootdir" ]
242+
vgname: vg1
243+
snapshot_as_volume_chain: true
230244
- name: Create an LVM-thin storage type
231245
proxmox_storage:
232246
name: lvmthin1
@@ -318,6 +332,7 @@ def __init__(self, module):
318332
self.vgname = module.params['vgname']
319333
self.thinpool = module.params['thinpool']
320334
self.sparse = module.params['sparse']
335+
self.snapshot_as_volume_chain = module.params['snapshot_as_volume_chain']
321336
self.is_mountpoint = module.params['is_mountpoint']
322337
self.create_subdirs = module.params['create_subdirs']
323338

@@ -345,6 +360,12 @@ def __init__(self, module):
345360
self.module.fail_json(msg=("encryption_key needs to be valid "
346361
"JSON or set to 'autogen'."))
347362

363+
if self.krbd is not None and self.type != 'rbd':
364+
self.module.fail_json(msg="krbd is only allowed with 'rbd' storage type")
365+
366+
if self.snapshot_as_volume_chain is not None and self.type != 'lvm':
367+
self.module.fail_json(msg="snapshot_as_volume_chain is only allowed with 'lvm' storage type")
368+
348369
# Attempt to retrieve current/live storage definitions
349370
try:
350371
self.existing_storages = pvesh.get("storage")
@@ -418,6 +439,8 @@ def prepare_storage_args(self):
418439
args['namespace'] = self.namespace
419440
if self.sparse is not None:
420441
args['sparse'] = 1 if self.sparse else 0
442+
if self.snapshot_as_volume_chain is not None:
443+
args['snapshot-as-volume-chain'] = 1 if self.snapshot_as_volume_chain else 0
421444
if self.is_mountpoint is not None:
422445
args['is_mountpoint'] = 1 if self.is_mountpoint else 0
423446
if self.create_subdirs is not None:
@@ -453,8 +476,6 @@ def prepare_storage_args(self):
453476
map(lambda cfg: '{}={}'.format(cfg['option'], cfg['value']), other_entries)
454477
)
455478
)
456-
if self.krbd is not None and self.type != 'rbd':
457-
self.module.fail_json(msg="krbd is only allowed with 'rbd' storage type")
458479

459480
return args
460481

@@ -594,6 +615,7 @@ def main():
594615
vgname=dict(default=None, type='str', required=False),
595616
thinpool=dict(default=None, type='str', required=False),
596617
sparse=dict(default=None, type='bool', required=False),
618+
snapshot_as_volume_chain=dict(default=None, type='bool', required=False),
597619
is_mountpoint=dict(default=None, type='bool', required=False),
598620
create_subdirs=dict(default=None, type='bool', required=False),
599621
namespace=dict(default=None, type='str', required=False),

tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
shared: "{{ item.shared | default(omit) }}"
353353
create_subdirs: "{{ item.create_subdirs | default(omit) }}"
354354
is_mountpoint: "{{ item.is_mountpoint | default(omit) }}"
355+
snapshot_as_volume_chain: "{{ item.snapshot_as_volume_chain | default(omit) }}"
355356
no_log: "{{ pve_no_log }}"
356357
with_items: "{{ pve_storages }}"
357358
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"

0 commit comments

Comments
 (0)