]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
tools: add upid_status_is_error function
[pve-common.git] / src / PVE / Tools.pm
index 465c338375d8bc652f4d32ecc75e6b4b37a6e39d..8946e93c6c1f1d8c22cf87533a1eb3cc2abe6a51 100644 (file)
@@ -1171,6 +1171,14 @@ sub upid_read_status {
     return "unable to read tail (got $br bytes)";
 }
 
+# Check if the status returned by upid_read_status is an error status.
+# If the status could not be parsed it's also treated as an error.
+sub upid_status_is_error {
+    my ($status) = @_;
+
+    return !($status eq 'OK' || $status =~ m/^WARNINGS: \d+$/);
+}
+
 # useful functions to store comments in config files
 sub encode_text {
     my ($text) = @_;