as a single point where we get the type of upid status Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> --- src/PVE/Tools.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 8946e93..7cca4a4 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -1179,6 +1179,26 @@ sub upid_status_is_error { return !($status eq 'OK' || $status =~ m/^WARNINGS: \d+$/); } +# takes the parsed status and returns the type, +# either ok, warning, error or unknown +sub upid_get_status_type { + my ($status) = @_; + + if (!$status) { + return 'unknown'; + } + + if ($status eq 'OK') { + return 'ok'; + } elsif ($status =~ m/^WARNINGS: \d+$/) { + return 'warning'; + } elsif ($status eq 'unexpected status') { + return 'unknown'; + } else { + return 'error'; + } +} + # useful functions to store comments in config files sub encode_text { my ($text) = @_; -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel