[pve-devel] [PATCH v2 guest-common 03/18] refactor code from qm/pct 'pending' call into AbstractConfig
Oguz Bektas
o.bektas at proxmox.com
Mon Sep 30 14:44:35 CEST 2019
Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
PVE/GuestHelpers.pm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/PVE/GuestHelpers.pm b/PVE/GuestHelpers.pm
index ebe2781..a16433f 100644
--- a/PVE/GuestHelpers.pm
+++ b/PVE/GuestHelpers.pm
@@ -60,4 +60,30 @@ sub exec_hookscript {
}
}
+sub format_pending {
+ my ($data) = @_;
+ foreach my $item (sort { $a->{key} cmp $b->{key}} @$data) {
+ my $k = $item->{key};
+ next if $k eq 'digest';
+ my $v = $item->{value};
+ my $p = $item->{pending};
+ if ($k eq 'description') {
+ $v = PVE::Tools::encode_text($v) if defined($v);
+ $p = PVE::Tools::encode_text($p) if defined($p);
+ }
+ if (defined($v)) {
+ if ($item->{delete}) {
+ print "del $k: $v\n";
+ } elsif (defined($p)) {
+ print "cur $k: $v\n";
+ print "new $k: $p\n";
+ } else {
+ print "cur $k: $v\n";
+ }
+ } elsif (defined($p)) {
+ print "new $k: $p\n";
+ }
+ }
+}
+
1;
--
2.20.1
More information about the pve-devel
mailing list