Skip to content

Commit 6c1cb9c

Browse files
committed
Fix boolean settings for PVE storage module
1 parent 6274a16 commit 6c1cb9c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

library/proxmox_role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@ def main():
186186
module.exit_json(**result)
187187

188188
if __name__ == '__main__':
189-
main()
189+
main()

library/proxmox_storage.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ def lookup(self):
202202
for item in self.existing_storages:
203203
if item['storage'] == self.name:
204204
# pvesh doesn't return the disable param value if it's false,
205-
# so we set it to False.
205+
# so we set it to 0, which is what PVE would normally use.
206206
if item.get('disable') is None:
207-
item['disable'] = False
207+
item['disable'] = 0
208208
return item
209209
return None
210210

@@ -222,9 +222,7 @@ def prepare_storage_args(self):
222222
if self.nodes is not None:
223223
args['nodes'] = ','.join(self.nodes)
224224
if self.disable is not None:
225-
args['disable'] = self.disable
226-
else:
227-
args['disable'] = False
225+
args['disable'] = 1 if self.disable else 0
228226
if self.path is not None:
229227
args['path'] = self.path
230228
if self.pool is not None:
@@ -234,7 +232,7 @@ def prepare_storage_args(self):
234232
if self.username is not None:
235233
args['username'] = self.username
236234
if self.krbd is not None:
237-
args['krbd'] = self.krbd
235+
args['krbd'] = 1 if self.krbd else 0
238236
if self.maxfiles is not None:
239237
args['maxfiles'] = self.maxfiles
240238
if self.server is not None:
@@ -248,7 +246,7 @@ def prepare_storage_args(self):
248246
if self.thinpool is not None:
249247
args['thinpool'] = self.thinpool
250248
if self.sparse is not None:
251-
args['sparse'] = self.sparse
249+
args['sparse'] = 1 if self.sparse else 0
252250

253251
if self.maxfiles is not None and 'backup' not in self.content:
254252
self.module.fail_json(msg="maxfiles is not allowed when there is no 'backup' in content")

tests/vagrant/group_vars/all

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ pve_storages:
5858
type: dir
5959
content: [ "iso", "vztmpl", "backup" ]
6060
path: /testpool/zfs2
61+
- name: disabled-dir
62+
type: dir
63+
disable: yes
64+
content: [ "images" ]
65+
path: /tmp/fakedir
6166
pve_zfs_create_volumes:
6267
- testpool/zfs2
6368
pve_ceph_osds:

0 commit comments

Comments
 (0)