From 8207792bf71f1a3155da257e500e6f39a7a1d67b Mon Sep 17 00:00:00 2001 From: illustris Date: Mon, 14 Apr 2025 08:06:10 +0530 Subject: [PATCH] Fix storage config parsing for keys without values Set keys without values (like 'sparse') to True when parsing storage configuration. --- src/pvestorage/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pvestorage/__init__.py b/src/pvestorage/__init__.py index e539707..9813152 100644 --- a/src/pvestorage/__init__.py +++ b/src/pvestorage/__init__.py @@ -65,9 +65,15 @@ def parse_storage_cfg(file_path='/etc/pve/storage.cfg'): else: # Parse key-value pairs within the current storage if current_storage: - key, value = line.split(None, 1) - sanitized_key = sanitize_key(key.strip()) - current_storage[sanitized_key] = value.strip() + parts = line.split(None, 1) + key = parts[0].strip() + sanitized_key = sanitize_key(key) + if len(parts) > 1: + # Regular key-value pair + current_storage[sanitized_key] = parts[1].strip() + else: + # Key with no value, set it to True + current_storage[sanitized_key] = True # Append the last storage section to the list if any if current_storage: