Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
Implement reload status provider
Browse files Browse the repository at this point in the history
refs #5098
  • Loading branch information
mxhash committed Nov 19, 2013
1 parent 5c346ce commit 08fb2d1
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
70 changes: 70 additions & 0 deletions app/modules/Cronks/actions/Util/ReloadStatusAction.class.php
@@ -0,0 +1,70 @@
<?php
// {{{ICINGA_LICENSE_CODE}}}
// -----------------------------------------------------------------------------
// This file is part of icinga-web.
//
// Copyright (c) 2009-2013 Icinga Developer Team.
// All rights reserved.
//
// icinga-web is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// icinga-web is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with icinga-web. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------
// {{{ICINGA_LICENSE_CODE}}}

class Cronks_Util_ReloadStatusAction extends CronksBaseAction {
/**
* Returns the default view if the action does not serve the request
* method used.
*
* @return mixed <ul>
* <li>A string containing the view name associated
* with this action; or</li>
* <li>An array with two indices: the parent module
* of the view to be executed and the view to be
* executed.</li>
* </ul>
*/
public function getDefaultViewName() {
return 'Success';
}

public function executeRead(AgaviParameterHolder $rd) {

/** @var Cronks_Provider_ProgramStatusModel $model */
$model = $this->context->getModel('Provider.ProgramStatus', 'Cronks');

if (!$model->isApplicable() || $model->config_dump_in_progress === '1') {
$this->setAttribute('config_reload', true);
} else {
$this->setAttribute('config_reload', false);
}

return $this->getDefaultViewName();
}

public function executeWrite(AgaviParameterHolder $rd) {
return $this->executeRead($rd);
}

public function isSecure() {
return true;
}

public function getCredentials() {
return array('icinga.user');
}

public function handleError(AgaviRequestDataHolder $rd) {
return $this->getDefaultViewName();
}
}
4 changes: 4 additions & 0 deletions app/modules/Cronks/config/routing.xml
Expand Up @@ -41,6 +41,10 @@
<route name=".monitorPerformance.json" pattern="^/monitorPerformance/json"
output_type="json" action="System.MonitorPerformance" />

<!-- IDO reload status -->
<route name=".reloadStatus.json" pattern="^/reloadStatus/json"
output_type="json" action="Util.ReloadStatus" />

<!-- Source of the grid processor -->
<route name=".viewProc" pattern="^/viewproc/(template:([\w\.\-\_\s]+))">
<route name=".json" pattern="^/json" output_type="json"
Expand Down
15 changes: 15 additions & 0 deletions app/modules/Cronks/validate/Util/ReloadStatus.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ae:configurations
xmlns="http://agavi.org/agavi/config/parts/validators/1.0"
xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0"
parent="%core.module_dir%/Cronks/config/validators.xml"
>

<ae:configuration>

<validators>
</validators>

</ae:configuration>

</ae:configurations>
34 changes: 34 additions & 0 deletions app/modules/Cronks/views/Util/ReloadStatusSuccessView.class.php
@@ -0,0 +1,34 @@
<?php
// {{{ICINGA_LICENSE_CODE}}}
// -----------------------------------------------------------------------------
// This file is part of icinga-web.
//
// Copyright (c) 2009-2013 Icinga Developer Team.
// All rights reserved.
//
// icinga-web is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// icinga-web is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with icinga-web. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------
// {{{ICINGA_LICENSE_CODE}}}

class Cronks_Util_ReloadStatusSuccessView extends CronksBaseView {

public function executeJson(AgaviRequestDataHolder $rd) {
$output = array(
'config_reload' => $this->getAttribute('config_reload')
);

return json_encode($output);
}

}

0 comments on commit 08fb2d1

Please sign in to comment.