* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
const SUDO = 'sudo';
- const BCONSOLE_COMMAND_PATTERN = "%s%s -c %s %s 2>&1 <<END_OF_DATA\n%s\nquit\nEND_OF_DATA";
+ const BCONSOLE_COMMAND_PATTERN = "%s%s -c %s %s 2>&1 <<END_OF_DATA\ngui on\n%s\nquit\nEND_OF_DATA";
const BCONSOLE_DIRECTORS_PATTERN = "%s%s -c %s -l 2>&1";
'.fileset',
'.storage',
'.client',
- '.pool'
+ '.pool',
+ '.schedule'
);
private $config;
}
private function prepareResult(array $output, $exitcode, $bconsole_command) {
+ array_shift($output); // deleted 'gui on'
array_pop($output); // deleted 'quit' bconsole command
for($i = 0; $i < count($output); $i++) {
if(strstr($output[$i], $bconsole_command) == false) {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class JobManager extends APIModule {
- public function getJobs($limit, $allowedJobs = array()) {
+ public function getJobs($limit, $params = array()) {
$criteria = new TActiveRecordCriteria;
$order = 'JobId';
$db_params = $this->getModule('api_config')->getConfig('db');
$criteria->Limit = $limit;
}
- if (count($allowedJobs) > 0) {
- $where = array();
- $names = array();
- for ($i = 0; $i < count($allowedJobs); $i++) {
- $where[] = "name = :name$i";
- $names[":name$i"] = $allowedJobs[$i];
- }
- $criteria->Condition = implode(' OR ', $where);
- foreach($names as $name => $jobname) {
- $criteria->Parameters[$name] = $jobname;
+ if (count($params) > 0) {
+ $condition = array();
+ foreach ($params as $key => $value) {
+ $cond = array();
+ $vals = array();
+ if (is_array($value['vals'])) {
+ for ($i = 0; $i < count($value['vals']); $i++) {
+ $cond[] = "{$key} = :{$key}{$i}";
+ $vals[":{$key}{$i}"] = $value['vals'][$i];
+ }
+ } else {
+ $cond[] = "$key = :$key";
+ $vals[":$key"] = $value['vals'];
+ }
+ $condition[] = implode(' ' . $value['operator'] . ' ', $cond);
+ foreach ($vals as $pkey => $pval) {
+ $criteria->Parameters[$pkey] = $pval;
+ }
}
+ $criteria->Condition = '(' . implode(') AND (' , $condition) . ')';
}
return JobRecord::finder()->findAll($criteria);
}
return $jobids;
}
- public function getJobTotals($allowedJobs = array()) {
+ public function getJobTotals($allowed_jobs = array()) {
$jobtotals = array('bytes' => 0, 'files' => 0);
$connection = JobRecord::finder()->getDbConnection();
$connection->setActive(true);
$where = '';
- if (count($allowedJobs) > 0) {
- $where = " WHERE name='" . implode("' OR name='", $allowedJobs) . "'";
+ if (count($allowed_jobs) > 0) {
+ $where = " WHERE name='" . implode("' OR name='", $allowed_jobs) . "'";
}
$sql = "SELECT sum(JobFiles) AS files, sum(JobBytes) AS bytes FROM Job $where";
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class VolumeManager extends APIModule {
- public function getVolumes($limit, $with_pools = false) {
+ public function getVolumes($limit) {
$criteria = new TActiveRecordCriteria;
$orderPool = 'PoolId';
$orderVolume = 'VolumeName';
$criteria->Limit = $limit;
}
$volumes = VolumeRecord::finder()->findAll($criteria);
- $this->setExtraVariables($volumes, $with_pools);
+ $this->setExtraVariables($volumes);
return $volumes;
}
public function getVolumesByPoolId($poolid) {
- return VolumeRecord::finder()->findBypoolid($poolid);
+ $volumes = VolumeRecord::finder()->findAllBypoolid($poolid);
+ $this->setExtraVariables($volumes);
+ return $volumes;
+ }
+
+ public function getVolumeByPoolId($poolid) {
+ $volume = VolumeRecord::finder()->findBypoolid($poolid);
+ $this->setExtraVariables($volume);
+ return $volume;
}
public function getVolumeByName($volumeName) {
- return VolumeRecord::finder()->findByvolumename($volumeName);
+ $volume = VolumeRecord::finder()->findByvolumename($volumeName);
+ $this->setExtraVariables($volume);
+ return $volume;
}
public function getVolumeById($volumeId) {
- return VolumeRecord::finder()->findBymediaid($volumeId);
+ $volume = VolumeRecord::finder()->findBymediaid($volumeId);
+ $this->setExtraVariables($volume);
+ return $volume;
}
- private function setExtraVariables(&$volumes, $with_pools) {
- $pools = $this->Application->getModule('pool')->getPools(false);
- foreach($volumes as $volume) {
- $volstatus = strtolower($volume->volstatus);
- $volume->whenexpire = ($volstatus == 'full' || $volstatus == 'used') ? date( 'Y-m-d H:i:s', (strtotime($volume->lastwritten) + $volume->volretention)) : 'no date';
- if ($with_pools === true) {
- foreach($pools as $pool) {
- if($volume->poolid == $pool->poolid) {
- $volume->pool = $pool;
- }
- }
+ private function setExtraVariables(&$volumes) {
+ if (is_array($volumes)) {
+ foreach($volumes as $volume) {
+ $this->setWhenExpire($volume);
}
+ } else {
+ $this->setWhenExpire($volumes);
+ }
+ }
+
+ private function setWhenExpire(&$volume) {
+ $volstatus = strtolower($volume->volstatus);
+ if ($volstatus == 'full' || $volstatus == 'used') {
+ $whenexpire = strtotime($volume->lastwritten) + $volume->volretention;
+ $whenexpire = date( 'Y-m-d H:i:s', $whenexpire);
+ } else{
+ $whenexpire = 'no date';
}
+ $volume->whenexpire = $whenexpire;
}
/**
'bvfs',
'joblog',
'filesets',
+ 'schedules',
'config'
];
var set_scopes = function(field_id) {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
public function get() {
$clientid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
- $client = $this->getModule('client')->getClientById($clientid);
+ $client_name = $this->Request->contains('name') ? $this->Request['name'] : '';
+ $client = null;
+ if ($clientid > 0) {
+ $client = $this->getModule('client')->getClientById($clientid);
+ } elseif (!empty($client_name)) {
+ $client = $this->getModule('client')->getClientByName($client_name);
+ }
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.client'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
if(!is_null($client) && in_array($client->name, $result->output)) {
$this->output = $client;
$this->error = ClientError::ERROR_NO_ERRORS;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
public function get() {
$clientid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
- $client = $this->getModule('client')->getClientById($clientid);
- if(is_object($client)) {
- $result = $this->getModule('bconsole')->bconsoleCommand(
- $this->director,
- array('show', 'client="' . $client->name . '"')
- );
+
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.client'));
+ if ($result->exitcode === 0) {
+ array_shift($result->output);
+ $client = $this->getModule('client')->getClientById($clientid);
+ if(!is_null($client) && in_array($client->name, $result->output)) {
+ $result = $this->getModule('bconsole')->bconsoleCommand(
+ $this->director,
+ array('show', 'client="' . $client->name . '"')
+ );
+ $this->output = $result->output;
+ $this->error = $result->exitcode;
+ } else {
+ $this->output = ClientError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
+ $this->error = ClientError::ERROR_CLIENT_DOES_NOT_EXISTS;
+ }
+ } else {
$this->output = $result->output;
$this->error = $result->exitcode;
- } else {
- $this->output = ClientError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
- $this->error = ClientError::ERROR_CLIENT_DOES_NOT_EXISTS;
}
}
}
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$clients = $this->getModule('client')->getClients($limit);
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.client'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$clients_output = array();
foreach($clients as $client) {
if(in_array($client->name, $result->output)) {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class FileSet extends BaculumAPIServer {
public function get() {
$filesetid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
- $fileset = $this->getModule('fileset')->getFileSetById($filesetid);
+ $fileset_name = $this->Request->contains('name') ? $this->Request['name'] : '';
+ $fileset = null;
+ if ($filesetid > 0) {
+ $fileset = $this->getModule('fileset')->getFileSetById($filesetid);
+ } elseif (!empty($fileset_name)) {
+ // Not advised for many directors (filesets per director)
+ $fileset = $this->getModule('fileset')->getFileSetByName($fileset_name);
+ }
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.fileset'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
if(!is_null($fileset) && in_array($fileset->fileset, $result->output)) {
$this->output = $fileset;
$this->error = FileSetError::ERROR_NO_ERRORS;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$filesets = $this->getModule('fileset')->getFileSets();
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.fileset'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
if (is_array($filesets) && count($filesets) > 0) {
$fs = array();
for ($i = 0; $i < count($filesets); $i++) {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$job = $this->getModule('job')->getJobById($jobid);
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
if(!is_null($job) && in_array($job->name, $result->output)) {
$this->output = $job;
$this->error = JobError::ERROR_NO_ERRORS;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
} elseif ($this->Request->contains('name')) {
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$jobname = in_array($this->Request['name'], $result->output) ? $this->Request['name'] : null;
} else {
$error_obj = $result;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
* Checking by "show job" command is ugly way to be sure that is reading jobname but not some
* random output (eg. "You have messages." or debugging).
* For now I did not find nothing better for be sure that output contains job.
+ * @NOTE, now is used "gui on" so it is not necessarly @TODO: Rework it
*/
for($k = 0; $k < count($jobs_show->output); $k++) {
if(preg_match('/^Job: name=' . $job_list->output[$j] . '.*/', $jobs_show->output[$k]) === 1) {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class Jobs extends BaculumAPIServer {
public function get() {
$limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0;
+ $jobstatus = $this->Request->contains('jobstatus') ? $this->Request['jobstatus'] : '';
+ $params = array();
+ $jobstatuses = array_keys($this->getModule('misc')->getJobState());
+ $sts = str_split($jobstatus);
+ for ($i = 0; $i < count($sts); $i++) {
+ if (in_array($sts[$i], $jobstatuses)) {
+ if (!key_exists('jobstatus', $params)) {
+ $params['jobstatus'] = array('operator' => 'OR', 'vals' => array());
+ }
+ $params['jobstatus']['vals'][] = $sts[$i];
+ }
+ }
$allowed = array();
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
if ($result->exitcode === 0) {
array_shift($result->output);
- $allowed = $result->output;
- $jobs = $this->getModule('job')->getJobs($limit, $allowed);
+ $params['name']['operator'] = 'OR';
+ $params['name']['vals'] = $result->output;
+ $jobs = $this->getModule('job')->getJobs($limit, $params);
$this->output = $jobs;
$this->error = JobError::ERROR_NO_ERRORS;
} else {
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$error = false;
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$allowed_jobs = $result->output;
} else {
$error = true;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$error = false;
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$allowed = $result->output;
} else {
$error = true;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class Pool extends BaculumAPIServer {
public function get() {
$poolid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
- $pool = $this->getModule('pool')->getPoolById($poolid);
+ $pool_name = $this->Request->contains('name') ? $this->Request['name'] : '';
+ $pool = null;
+ if ($poolid > 0) {
+ $pool = $this->getModule('pool')->getPoolById($poolid);
+ } elseif (!empty($pool_name)) {
+ $pool = $this->getModule('pool')->getPoolByName($pool_name);
+ }
$allowedPools = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.pool'));
if ($allowedPools->exitcode === 0) {
+ array_shift($allowedPools->output);
if(!is_null($pool) && in_array($pool->name, $allowedPools->output)) {
$this->output = $pool;
$this->error = PoolError::ERROR_NO_ERRORS;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$poolid = intval($id);
$pool = $this->getModule('pool')->getPoolById($poolid);
if(is_object($pool)) {
- $voldata = $this->getModule('volume')->getVolumesByPoolId($pool->poolid);
+ $voldata = $this->getModule('volume')->getVolumeByPoolId($pool->poolid);
if(is_object($voldata)) {
$result = $this->getModule('bconsole')->bconsoleCommand(
$this->director,
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$pools = $this->getModule('pool')->getPools($limit);
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.pool'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$pools_output = array();
foreach($pools as $pool) {
if(in_array($pool->name, $result->output)) {
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2018 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+class Schedules extends BaculumAPIServer {
+ public function get() {
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.schedule'));
+ if ($result->exitcode === 0) {
+ array_shift($result->output);
+ $this->output = $result->output;
+ $this->error = PoolError::ERROR_NO_ERRORS;
+ } else {
+ $this->output = $result->output;
+ $this->error = $result->exitcode;
+ }
+ }
+}
+?>
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
class Storage extends BaculumAPIServer {
public function get() {
$storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
- $storage = $this->getModule('storage')->getStorageById($storageid);
+ $storage_name = $this->Request->contains('name') ? $this->Request['name'] : '';
+ $storage = null;
+ if ($storageid > 0) {
+ $storage = $this->getModule('storage')->getStorageById($storageid);
+ } elseif (!empty($storage_name)) {
+ $storage = $this->getModule('storage')->getStorageByName($storage_name);
+ }
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.storage'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
if(!is_null($storage) && in_array($storage->name, $result->output)) {
$this->output = $storage;
$this->error = StorageError::ERROR_NO_ERRORS;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
public function get() {
$storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
$drive = $this->Request->contains('drive') ? intval($this->Request['drive']) : 0;
+ $device = $this->Request->contains('device') ? $this->Request['device'] : null;
$slot = $this->Request->contains('slot') ? intval($this->Request['slot']) : 0;
$storage = $this->getModule('storage')->getStorageById($storageid);
if(is_object($storage)) {
$result = $this->getModule('bconsole')->bconsoleCommand(
$this->director,
- array('mount', 'storage="' . $storage->name . '"', 'drive=' . $drive, 'slot=' . $slot)
+ array(
+ 'mount',
+ 'storage="' . $storage->name . '"',
+ (is_string($device) ? 'device="' . $device . '" drive=0' : 'drive=' . $drive),
+ 'slot=' . $slot
+ )
);
$this->output = $result->output;
$this->error = $result->exitcode;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
public function get() {
$storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
$drive = $this->Request->contains('drive') ? intval($this->Request['drive']) : 0;
+ $device = $this->Request->contains('device') ? $this->Request['device'] : null;
$storage = $this->getModule('storage')->getStorageById($storageid);
if (is_object($storage)) {
$result = $this->getModule('bconsole')->bconsoleCommand(
$this->director,
- array('release', 'storage="' . $storage->name . '"', 'drive="' . $drive . '"')
+ array(
+ 'release',
+ 'storage="' . $storage->name . '"',
+ (is_string($device) ? 'device="' . $device . '" drive=0 slot=0' : 'drive=' . $drive . ' slot=0')
+ )
);
$this->output = $result->output;
$this->error = $result->exitcode;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
public function get() {
$storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
$drive = $this->Request->contains('drive') ? intval($this->Request['drive']) : 0;
+ $device = $this->Request->contains('device') ? $this->Request['device'] : null;
$storage = $this->getModule('storage')->getStorageById($storageid);
if (is_object($storage)) {
$result = $this->getModule('bconsole')->bconsoleCommand(
$this->director,
- array('umount', 'storage="' . $storage->name . '"', 'drive=' . $drive)
+ array(
+ 'umount',
+ 'storage="' . $storage->name . '"',
+ (is_string($device) ? 'device="' . $device . '" slot=0 drive=0' : 'drive=' . $drive . ' slot=0')
+ )
);
$this->output = $result->output;
$this->error = $result->exitcode;
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2018 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
$storages = $this->getModule('storage')->getStorages($limit);
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.storage'));
if ($result->exitcode === 0) {
+ array_shift($result->output);
$storages_output = array();
foreach($storages as $storage) {
if(in_array($storage->name, $result->output)) {
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2018 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+class VolumesInPool extends BaculumAPIServer {
+ public function get() {
+ $poolid = $this->Request->contains('poolid') ? intval($this->Request['poolid']) : 0;
+ $result = $this->getModule('volume')->getVolumesByPoolId($poolid);
+ $this->output = $result;
+ $this->error = VolumeError::ERROR_NO_ERRORS;
+ }
+}
+?>
<!-- clients (file daemons) endpoints -->
<url ServiceParameter="API.Clients" pattern="api/clients/" />
<url ServiceParameter="API.Client" pattern="api/clients/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="API.Client" pattern="api/clients/{name}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="API.Clients" pattern="api/clients/limit/{limit}/" parameters.limit="\d+" />
<url ServiceParameter="API.ClientsShow" pattern="api/clients/show/" />
<url ServiceParameter="API.ClientShow" pattern="api/clients/show/{id}/" parameters.id="\d+" />
<!-- storages (storage daemons) endpoints -->
<url ServiceParameter="API.Storages" pattern="api/storages/" />
<url ServiceParameter="API.Storage" pattern="api/storages/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="API.Storage" pattern="api/storages/{name}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="API.Storages" pattern="api/storages/limit/{limit}/" parameters.limit="\d+" />
<url ServiceParameter="API.StoragesShow" pattern="api/storages/show/" />
<url ServiceParameter="API.StorageShow" pattern="api/storages/show/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.StorageStatus" pattern="api/storages/status/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.StorageMount" pattern="api/storages/mount/{id}/{drive}/{slot}/" parameters.id="\d+" parameters.drive="\d+" parameters.slot="\d+" />
+ <url ServiceParameter="API.StorageMount" pattern="api/storages/mount/{id}/{device}/{slot}/" parameters.id="\d+" parameters.device="[a-zA-Z0-9:.\-_ ]+" parameters.slot="\d+" />
<url ServiceParameter="API.StorageUmount" pattern="api/storages/umount/{id}/{drive}/" parameters.id="\d+" parameters.drive="\d+" />
+ <url ServiceParameter="API.StorageUmount" pattern="api/storages/umount/{id}/{device}/" parameters.id="\d+" parameters.device="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="API.StorageRelease" pattern="api/storages/release/{id}/{drive}/" parameters.id="\d+" parameters.drive="\d+" />
+ <url ServiceParameter="API.StorageRelease" pattern="api/storages/release/{id}/{device}/" parameters.id="\d+" parameters.device="[a-zA-Z0-9:.\-_ ]+" />
<!-- volumes (media) endpoints-->
<url ServiceParameter="API.Volumes" pattern="api/volumes/" />
<url ServiceParameter="API.Volumes" pattern="api/volumes/limit/{limit}/" parameters.limit="\d+" />
<!-- pools endpoints -->
<url ServiceParameter="API.Pools" pattern="api/pools/" />
<url ServiceParameter="API.Pool" pattern="api/pools/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="API.Pool" pattern="api/pools/{name}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" />
+ <url ServiceParameter="API.VolumesInPool" pattern="api/pools/{poolid}/volumes/" parameters.poolid="\d+" />
<url ServiceParameter="API.Pools" pattern="api/pools/limit/{limit}/" parameters.limit="\d+" />
<url ServiceParameter="API.PoolUpdate" pattern="api/pools/update/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.PoolUpdateVolumes" pattern="api/pools/update/volumes/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.PoolShow" pattern="api/pools/show/{id}/" parameters.id="\d+" />
<!-- jobs endpoints-->
<url ServiceParameter="API.Jobs" pattern="api/jobs/" />
+ <url ServiceParameter="API.Jobs" pattern="api/jobs/jobstatus/{jobstatus}/" parameters.jobstatus="[a-zA-Z]+" />
<url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/" />
<url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}" parameters.type="[a-zA-Z]" />
<url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}/limit/{limit}/" parameters.type="[a-zA-Z]" parameters.limit="\d+" />
<url ServiceParameter="API.FileSets" pattern="api/filesets/" />
<url ServiceParameter="API.FileSet" pattern="api/filesets/{id}/" parameters.id="\d+" />
<url ServiceParameter="API.FileSetsInfo" pattern="api/filesets/info/" />
+ <url ServiceParameter="API.FileSet" pattern="api/filesets/{name}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" />
+ <!-- schedule endpoints -->
+ <url ServiceParameter="API.Schedules" pattern="api/schedules/" />
<!-- Bacula config module endpoints -->
<url ServiceParameter="API.Config" pattern="api/config/" />
<url ServiceParameter="API.Config" pattern="api/config/{component_type}/" parameters.component_type="[a-z]+" />