Skip to content

Commit

Permalink
Merge pull request #1109
Browse files Browse the repository at this point in the history
webui: introduce rerun of multiple jobs at once
  • Loading branch information
pstorz committed Apr 11, 2022
2 parents 61b4f7d + b8fde4e commit 47905d4
Show file tree
Hide file tree
Showing 9 changed files with 467 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -25,6 +25,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- bareos-contrib-tools
- systemtest py3plug-fd-contrib-mysql_dump [PR #768]
- systemtest py*plug-fd-contrib-bareos_tasks_mysql [PR #768]
- webui: introduce rerun of multiple jobs at once [PR #1109]

### Fixed
- NDMP_BAREOS: support autoxflate plugin [PR #1013]
Expand Down Expand Up @@ -55,7 +56,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- webui: remove an unnecessary .bvfs_get_jobids and buildSubtree() call [PR #1050]
- git: set merge strategy for CHANGELOG.md to union [PR #1062]
- webui: add timeline chart by jobs [PR #1059]
- stored: enable labeling of tapes in drives even if `autoselect=no` [PR #1021]
- stored: enable labeling of tapes in drives even if `autoselect=no` [PR #1021]
- dir, stored: start statistics threads only if needed [PR #1040]
- gitignore: cleanup .gitignore files [PR #1067]
- webui: update jstree from v3.3.8 to v3.3.12 [PR #1088]
Expand Down
70 changes: 67 additions & 3 deletions webui/module/Job/src/Job/Controller/JobController.php
Expand Up @@ -536,6 +536,43 @@ public function runAction()
}
}

public function rerunAction()
{
$this->RequestURIPlugin()->setRequestURI();

if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute(
'auth',
array(
'action' => 'login'
),
array(
'query' => array(
'req' => $this->RequestURIPlugin()->getRequestURI(),
'dird' => $_SESSION['bareos']['director']
)
)
);
}

$module_config = $this->getServiceLocator()->get('ModuleManager')->getModule('Application')->getConfig();
$invalid_commands = $this->CommandACLPlugin()->getInvalidCommands(
$module_config['console_commands']['Job']['optional']
);
if(count($invalid_commands) > 0 && in_array('rerun', $invalid_commands)) {
$this->acl_alert = true;
return new ViewModel(
array(
'acl_alert' => $this->acl_alert,
'invalid_commands' => 'rerun'
)
);
}

return new ViewModel();

}

public function timelineAction()
{
$this->RequestURIPlugin()->setRequestURI();
Expand Down Expand Up @@ -569,8 +606,6 @@ public function timelineAction()
);
}

$this->bsock = $this->getServiceLocator()->get('director');

return new ViewModel();
}

Expand Down Expand Up @@ -679,7 +714,36 @@ public function getDataAction()
echo $e->getMessage();
}
}
elseif($data="job-timeline") {
elseif($data == "jobs-to-rerun") {
try {
$result = $this->getJobModel()->getJobsToRerun($this->bsock, $period, null);
}
catch(Exception $e) {
echo $e->getMessages();
}
}
elseif($data == "job-rerun") {
try {
$result = [];
$j = explode(",", $jobs);
foreach($j as $job) {
array_push($result, $this->getJobModel()->rerunJob($this->bsock, $job));
}
}
catch(Exception $e) {
echo $e->getMessage();
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');

if(isset($result)) {
$response->setContent(JSON::encode($result));
}

return $response;
}
elseif($data == "job-timeline") {
try {
$result = [];
$j = explode(",", $jobs);
Expand Down
17 changes: 17 additions & 0 deletions webui/module/Job/src/Job/Model/JobModel.php
Expand Up @@ -136,6 +136,23 @@ public function getJobsByStatus(&$bsock=null, $jobname=null, $status=null, $days
}
}

public function getJobsToRerun(&$bsock=null, $period=null)
{
if(isset($bsock, $period)) {
$cmd = 'llist jobs jobtype=B days='.$period;
$result = $bsock->send_command($cmd, 2);
$jobs = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
if (empty($jobs['result'])) {
return false;
} else {
return $jobs['result']['jobs'];
}
}
else {
throw new \Exception('Missing argument.');
}
}

public function getClientJobsForPeriod(&$bsock=null, $client=null, $period=null)
{
if(isset($bsock, $client, $period)) {
Expand Down
3 changes: 2 additions & 1 deletion webui/module/Job/view/job/job/actions.phtml
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (C) 2013-2021 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (C) 2013-2022 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -32,6 +32,7 @@ $this->headTitle($title);
<li><a href="<?php echo $this->url('job', array('action'=>'index')); ?>"><?php echo $this->translate('Show'); ?></a></li>
<li class="active"><a href="<?php echo $this->url('job', array('action'=>'actions')); ?>"><?php echo $this->translate('Actions'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'run')); ?>"><?php echo $this->translate('Run'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'rerun')); ?>"><?php echo $this->translate('Rerun'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'timeline')); ?>"><?php echo $this->translate('Timeline'); ?></a></li>
</ul>

Expand Down
3 changes: 2 additions & 1 deletion webui/module/Job/view/job/job/details.phtml
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (C) 2013-2021 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (C) 2013-2022 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -32,6 +32,7 @@ $this->headTitle($title);
<li class="active"><a href="<?php echo $this->url('job', array('action'=>'index')); ?>"><?php echo $this->translate('Show'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'actions')); ?>"><?php echo $this->translate('Actions'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'run')); ?>"><?php echo $this->translate('Run'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'rerun')); ?>"><?php echo $this->translate('Rerun'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'timeline')); ?>"><?php echo $this->translate('Timeline'); ?></a></li>
</ul>

Expand Down
3 changes: 2 additions & 1 deletion webui/module/Job/view/job/job/index.phtml
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (C) 2013-2021 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (C) 2013-2022 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -32,6 +32,7 @@ $this->headTitle($title);
<li class="active"><a href="<?php echo $this->url('job', array('action'=>'index')); ?>"><?php echo $this->translate('Show'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'actions')); ?>"><?php echo $this->translate('Actions'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'run')); ?>"><?php echo $this->translate('Run'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'rerun')); ?>"><?php echo $this->translate('Rerun'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'timeline')); ?>"><?php echo $this->translate('Timeline'); ?></a></li>
</ul>

Expand Down

0 comments on commit 47905d4

Please sign in to comment.