]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Use catalog access in changer listall endpoint only if it is configured...
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 17 Apr 2021 15:47:14 +0000 (17:47 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 17 Apr 2021 15:47:14 +0000 (17:47 +0200)
gui/baculum/protected/API/Pages/API/ChangerListAll.php

index 876aea3e7b4d301af84cc5ab762921d600d4ca67..c7b1a19aec98b4e2ea08600c5d14171824e26246 100644 (file)
@@ -59,7 +59,15 @@ class ChangerListAll extends BaculumAPIServer {
        private function parseListAll($device_name, $output) {
                $list = ['drives' => [], 'slots' => [], 'ie_slots' => []];
                $drives = $this->getModule('device_config')->getChangerDrives($device_name);
-               $volumes = $this->getModule('volume')->getVolumesKeys();
+               $volumes = [];
+               $db_params = $this->getModule('api_config')->getConfig('db');
+               if (key_exists('enabled', $db_params) && $db_params['enabled'] == 1) {
+                       /**
+                        * Volume information is provided only if on API host with autochanger
+                        * enabled is access to the Catalog database for the API instance.
+                        */
+                       $volumes = $this->getModule('volume')->getVolumesKeys();
+               }
                $get_volume_info  = function($volname) use ($volumes) {
                        $volume = [
                                'mediaid' => 0,