[pve-devel] [PATCH cluster] parse_datacenter_config: return early if no raw data for parsing
Oguz Bektas
o.bektas at proxmox.com
Mon Nov 15 13:58:46 CET 2021
in case datacenter.cfg file is missing (e.g. because node is
standalone), it causes a warning message on 'split'.
avoid the warnings by doing an early return to stop processing in case
we got an empty config.
Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
data/PVE/DataCenterConfig.pm | 2 ++
1 file changed, 2 insertions(+)
diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
index 2e802d3..8a5892d 100644
--- a/data/PVE/DataCenterConfig.pm
+++ b/data/PVE/DataCenterConfig.pm
@@ -231,6 +231,8 @@ sub get_datacenter_schema { return $datacenter_schema };
sub parse_datacenter_config {
my ($filename, $raw) = @_;
+ return {} if !defined($raw);
+
# description may be comment or key-value pair (or both)
my $comment = '';
my @lines = split(/\n/, $raw);
--
2.30.2
More information about the pve-devel
mailing list