]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add dedupengine output type to status storage
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 15 Dec 2022 09:49:22 +0000 (10:49 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 9 Jan 2023 12:34:42 +0000 (13:34 +0100)
gui/baculum/protected/API/Modules/StatusStorage.php
gui/baculum/protected/API/Pages/API/StorageStatus.php
gui/baculum/protected/API/openapi_baculum.json

index d8690f88da1ce8d39db73188ff76eb2de238026e..724478a5515673890b3a33710b081dd4b35f5f33 100644 (file)
@@ -38,6 +38,7 @@ class StatusStorage extends ComponentStatusModule {
        const OUTPUT_TYPE_RUNNING = 'running';
        const OUTPUT_TYPE_TERMINATED = 'terminated';
        const OUTPUT_TYPE_DEVICES = 'devices';
+       const OUTPUT_TYPE_DEDUPENGINE = 'dedupengine';
 
        /**
         * Get parsed storage status.
@@ -78,18 +79,23 @@ class StatusStorage extends ComponentStatusModule {
                $autochangers = [];
                $ach_dev = [];
                $empty_lines = 0;
-               for($i = 0; $i < count($output); $i++) {
+               for ($i = 0; $i < count($output); $i++) {
+                       if (preg_match('/[\[\]]$/', $output[$i]) === 1) {
+                               $output[$i] = '';
+                       }
                        if (empty($output[$i])) {
                                $empty_lines++;
-                               if  (count($part) > 10) {
-                                       $result[] = $part;
-                                       $part = [];
-                               }
                                if (count($ach_dev) == 2) {
                                        $autochangers[$autochanger]['devices'][]  = $ach_dev;
                                        $ach_dev = [];
+                                       continue;
+                               }
+                               if  (count($part) > 7) {
+                                       $result[] = $part;
+                                       $part = [];
+                                       continue;
                                }
-                               if ($empty_lines == 4 && $autochanger) {
+                               if ($empty_lines > 3 && $autochanger) {
                                        $autochanger = null;
                                }
                        } else {
@@ -144,7 +150,8 @@ class StatusStorage extends ComponentStatusModule {
                                self::OUTPUT_TYPE_HEADER,
                                self::OUTPUT_TYPE_RUNNING,
                                self::OUTPUT_TYPE_TERMINATED,
-                               self::OUTPUT_TYPE_DEVICES
+                               self::OUTPUT_TYPE_DEVICES,
+                               self::OUTPUT_TYPE_DEDUPENGINE
                        )
                );
        }
index a2f97423fc62e51f1064b0f2ad5720fce7f4c6eb..900f9de9e148d3338f7ee6d93941926be83dd1b9 100644 (file)
@@ -58,7 +58,9 @@ class StorageStatus extends ConsoleOutputPage {
 
                $out = (object)['output' => [], 'error' => 0];
                if ($out_format === parent::OUTPUT_FORMAT_RAW) {
-                       $out = $this->getRawOutput(['storage' => $storage->name]);
+                       $out = $this->getRawOutput([
+                               'storage' => $storage->name
+                       ]);
                } elseif ($out_format === parent::OUTPUT_FORMAT_JSON) {
                        $out = $this->getJSONOutput([
                                'storage' => $storage->name,
index 3b8df22e7bc5e3d8328cef02afd56872a7277d8f..e4b5401429652b8446652634a9ac88b5505c0a35 100644 (file)
                                        {
                                                "$ref": "#/components/parameters/StorageId"
                                        },
-                                       {
-                                               "$ref": "#/components/parameters/Output"
-                                       },
                                        {
                                                "name": "type",
                                                "in": "query",
+                                               "required": false,
                                                "description": "Output type using together with output=json parameter.",
                                                "schema": {
                                                        "type": "string",
-                                                       "enum": ["header", "running", "devices", "terminated"]
+                                                       "enum": ["header", "running", "devices", "terminated", "dedupengine"]
                                                }
+                                       },
+                                       {
+                                               "$ref": "#/components/parameters/Output"
                                        }
                                ]
                        }