Skip to content

Commit ea902c8

Browse files
committed
Fix idempotency for storages configured with no content
1 parent 6c1cb9c commit ea902c8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

library/proxmox_storage.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ def prepare_storage_args(self):
218218
args = {}
219219

220220
args['type'] = self.type
221-
args['content'] = ','.join(self.content)
221+
if self.content is not None and len(self.content) > 0:
222+
args['content'] = ','.join(self.content)
223+
else:
224+
# PVE uses "none" to represent when no content types are selected
225+
args['content'] = 'none'
222226
if self.nodes is not None:
223227
args['nodes'] = ','.join(self.nodes)
224228
if self.disable is not None:
@@ -273,7 +277,8 @@ def modify_storage(self):
273277

274278
for key in new_storage:
275279
if key == 'content':
276-
if set(self.content) != set(lookup.get('content', '').split(',')):
280+
if set(new_storage['content'].split(',')) \
281+
!= set(lookup.get('content', '').split(',')):
277282
updated_fields.append(key)
278283
staged_storage[key] = new_storage[key]
279284
elif key == 'monhost':

tests/vagrant/group_vars/all

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ pve_storages:
6363
disable: yes
6464
content: [ "images" ]
6565
path: /tmp/fakedir
66+
- name: no-content-dir
67+
type: dir
68+
path: /tmp/fakedir2
6669
pve_zfs_create_volumes:
6770
- testpool/zfs2
6871
pve_ceph_osds:

0 commit comments

Comments
 (0)