[pve-devel] [v3 ha-manager 1/5] Tools/Config: refactor lrm status json reading
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Oct 10 13:55:03 CEST 2018
to avoid unnecessary dependency on PVE::Cluster in PVE::HA::Tools.
reading the LRM status file was the only instance of reading from the
CFS via this method.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
note: new patch in v3
src/PVE/HA/Config.pm | 8 ++++++--
src/PVE/HA/Tools.pm | 11 +----------
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index 5de4779..5660d19 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -48,9 +48,13 @@ sub read_lrm_status {
die "undefined node" if !defined($node);
- my $filename = "/etc/pve/nodes/$node/lrm_status";
+ my $cfs_path = "nodes/$node/lrm_status";
+
+ my $raw = PVE::Cluster::get_config($cfs_path);
+ die "unable to read file '/etc/pve/$cfs_path'\n"
+ if !defined($raw);
- return PVE::HA::Tools::read_json_from_file($filename, {});
+ return json_reader(undef, $raw);
}
sub write_lrm_status {
diff --git a/src/PVE/HA/Tools.pm b/src/PVE/HA/Tools.pm
index 88f775e..2bdd6ea 100644
--- a/src/PVE/HA/Tools.pm
+++ b/src/PVE/HA/Tools.pm
@@ -124,16 +124,7 @@ sub read_json_from_file {
if (defined($default) && (! -f $filename)) {
$data = $default;
} else {
- my $raw;
- # workaround for bug #775
- if ($filename =~ m|^/etc/pve/|) {
- $filename =~ s|^/etc/pve/+||;
- $raw = PVE::Cluster::get_config($filename);
- die "unable to read file '/etc/pve/$filename'\n"
- if !defined($raw);
- } else {
- $raw = PVE::Tools::file_get_contents($filename);
- }
+ my $raw = PVE::Tools::file_get_contents($filename);
$data = decode_json($raw);
}
--
2.19.1
More information about the pve-devel
mailing list