mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
Merge branch 'feature/travis-enforce-psr2'
This commit is contained in:
commit
83b5b27803
@ -22,9 +22,13 @@ env:
|
|||||||
DIRECTOR_TESTDB_USER="director_test"
|
DIRECTOR_TESTDB_USER="director_test"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update --stable
|
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
|
||||||
|
- wget https://github.com/Icinga/icingaweb2/archive/v2.4.0.tar.gz
|
||||||
|
- tar xfz v2.4.0.tar.gz
|
||||||
|
- ln -s icingaweb2-2.4.0/library/Icinga
|
||||||
|
- ln -s icingaweb2-2.4.0/library/vendor/Zend
|
||||||
- ./test/travis-prepare.sh
|
- ./test/travis-prepare.sh
|
||||||
- composer install
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- php phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Director/ application/ configuration.php run.php test
|
||||||
- phpunit --testdox || phpunit --verbose
|
- phpunit --testdox || phpunit --verbose
|
||||||
|
@ -110,7 +110,6 @@ class ConfigCommand extends Command
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($api->dumpConfig($config, $db)) {
|
if ($api->dumpConfig($config, $db)) {
|
||||||
|
@ -61,7 +61,6 @@ class DataController extends ActionController
|
|||||||
'url' => 'director/data/listentry' . '?list_id=' . $id,
|
'url' => 'director/data/listentry' . '?list_id=' . $id,
|
||||||
'label' => $this->translate('List entries'),
|
'label' => $this->translate('List entries'),
|
||||||
))->activate('editlist');
|
))->activate('editlist');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->view->title = $this->translate('Add');
|
$this->view->title = $this->translate('Add');
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ use Exception;
|
|||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Module\Director\Exception\NestingError;
|
use Icinga\Module\Director\Exception\NestingError;
|
||||||
use Icinga\Module\Director\IcingaConfig\AgentWizard;
|
use Icinga\Module\Director\IcingaConfig\AgentWizard;
|
||||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
||||||
use Icinga\Module\Director\Objects\IcingaZone;
|
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Director\Web\Controller\ObjectController;
|
use Icinga\Module\Director\Web\Controller\ObjectController;
|
||||||
|
|
||||||
@ -167,8 +165,8 @@ class HostController extends ObjectController
|
|||||||
)->where('hs.host_id = ?', $host->id);
|
)->where('hs.host_id = ?', $host->id);
|
||||||
|
|
||||||
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
|
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
|
||||||
foreach ($sets as $name => $set) {
|
|
||||||
|
|
||||||
|
foreach ($sets as $name => $set) {
|
||||||
$title = sprintf($this->translate('%s (Service set)'), $name);
|
$title = sprintf($this->translate('%s (Service set)'), $name);
|
||||||
$table = $this->loadTable('IcingaServiceSetService')
|
$table = $this->loadTable('IcingaServiceSetService')
|
||||||
->setServiceSet($set)
|
->setServiceSet($set)
|
||||||
@ -337,7 +335,6 @@ class HostController extends ObjectController
|
|||||||
$wizard->setTicketSalt($this->api()->getTicketSalt());
|
$wizard->setTicketSalt($this->api()->getTicketSalt());
|
||||||
$this->view->windows = $wizard->renderWindowsInstaller();
|
$this->view->windows = $wizard->renderWindowsInstaller();
|
||||||
$this->view->linux = $wizard->renderLinuxInstaller();
|
$this->view->linux = $wizard->renderLinuxInstaller();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->view->ticket = 'ERROR';
|
$this->view->ticket = 'ERROR';
|
||||||
$this->view->error = sprintf(
|
$this->view->error = sprintf(
|
||||||
|
@ -13,7 +13,7 @@ class ImportsourceController extends ActionController
|
|||||||
{
|
{
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$this->setAutoRefreshInterval(10);
|
$this->setAutorefreshInterval(10);
|
||||||
$id = $this->params->get('id');
|
$id = $this->params->get('id');
|
||||||
$this->prepareTabs($id)->activate('show');
|
$this->prepareTabs($id)->activate('show');
|
||||||
$source = $this->view->source = ImportSource::load($id, $this->db());
|
$source = $this->view->source = ImportSource::load($id, $this->db());
|
||||||
@ -173,7 +173,6 @@ class ImportsourceController extends ActionController
|
|||||||
'url' => 'director/importsource/preview' . '?id=' . $id,
|
'url' => 'director/importsource/preview' . '?id=' . $id,
|
||||||
'label' => $this->translate('Preview'),
|
'label' => $this->translate('Preview'),
|
||||||
));
|
));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$tabs->add('add', array(
|
$tabs->add('add', array(
|
||||||
'url' => 'director/importsource/add',
|
'url' => 'director/importsource/add',
|
||||||
|
@ -23,7 +23,7 @@ class JobsController extends ActionController
|
|||||||
$this->loadTable('job')
|
$this->loadTable('job')
|
||||||
->setConnection($this->db())
|
->setConnection($this->db())
|
||||||
);
|
);
|
||||||
$this->setViewScript('list/table');
|
|
||||||
|
|
||||||
|
$this->setViewScript('list/table');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,6 @@ class ServiceController extends ObjectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->host && $object->usesVarOverrides()) {
|
if ($this->host && $object->usesVarOverrides()) {
|
||||||
|
|
||||||
$parent = IcingaService::create(array(
|
$parent = IcingaService::create(array(
|
||||||
'object_type' => 'template',
|
'object_type' => 'template',
|
||||||
// TODO: => 'myself', -> There is no such import: "myself"
|
// TODO: => 'myself', -> There is no such import: "myself"
|
||||||
@ -157,7 +156,6 @@ class ServiceController extends ObjectController
|
|||||||
if ($object->isTemplate()
|
if ($object->isTemplate()
|
||||||
&& $object->getResolvedProperty('check_command_id')
|
&& $object->getResolvedProperty('check_command_id')
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->view->actionLinks .= ' ' . $this->view->qlink(
|
$this->view->actionLinks .= ' ' . $this->view->qlink(
|
||||||
'Create apply-rule',
|
'Create apply-rule',
|
||||||
'director/service/add',
|
'director/service/add',
|
||||||
|
@ -25,7 +25,6 @@ class SyncruleController extends ActionController
|
|||||||
|
|
||||||
if ($lastRunId = $rule->getLastSyncRunId()) {
|
if ($lastRunId = $rule->getLastSyncRunId()) {
|
||||||
$this->loadSyncRun($lastRunId);
|
$this->loadSyncRun($lastRunId);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->view->run = null;
|
$this->view->run = null;
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,11 @@ class DirectorDatafieldForm extends DirectorObjectForm
|
|||||||
protected function onRequest()
|
protected function onRequest()
|
||||||
{
|
{
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
|
|
||||||
if ($this->shouldBeDeleted()) {
|
if ($this->shouldBeDeleted()) {
|
||||||
$varname = $this->getSentValue('varname');
|
$varname = $this->getSentValue('varname');
|
||||||
if ($cnt = CustomVariables::countAll($varname, $this->getDb())) {
|
if ($cnt = CustomVariables::countAll($varname, $this->getDb())) {
|
||||||
$this->askForVariableDeletion($varname, $cnt);
|
$this->askForVariableDeletion($varname, $cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ class DirectorJobForm extends DirectorObjectForm
|
|||||||
));
|
));
|
||||||
|
|
||||||
$periods = $this->db->enumTimeperiods();
|
$periods = $this->db->enumTimeperiods();
|
||||||
if (!empty($periods)) {
|
|
||||||
|
|
||||||
|
if (!empty($periods)) {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'select',
|
'select',
|
||||||
'timeperiod_id',
|
'timeperiod_id',
|
||||||
|
@ -31,7 +31,6 @@ class IcingaCloneObjectForm extends QuickForm
|
|||||||
$this->translate('Clone "%s"'),
|
$this->translate('Clone "%s"'),
|
||||||
$this->object->getObjectName()
|
$this->object->getObjectName()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
|
@ -17,7 +17,6 @@ class IcingaDeleteObjectForm extends QuickForm
|
|||||||
$this->translate('YES, please delete "%s"'),
|
$this->translate('YES, please delete "%s"'),
|
||||||
$this->object->getObjectName()
|
$this->object->getObjectName()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
|
@ -26,7 +26,6 @@ class IcingaImportObjectForm extends QuickForm
|
|||||||
$this->translate('Import external "%s"'),
|
$this->translate('Import external "%s"'),
|
||||||
$this->object->object_name
|
$this->object->object_name
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
|
@ -93,7 +93,6 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
$this->setSubmitLabel(
|
$this->setSubmitLabel(
|
||||||
$this->translate('Override vars')
|
$this->translate('Override vars')
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->addElementsToGroup(
|
$this->addElementsToGroup(
|
||||||
array('inheritance_hint'),
|
array('inheritance_hint'),
|
||||||
@ -360,8 +359,8 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
'NOTE: only custom variables of type "Array" are eligible.'
|
'NOTE: only custom variables of type "Array" are eligible.'
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ class IcingaTimePeriodForm extends DirectorObjectForm
|
|||||||
'description' => $this->translate('the update method'),
|
'description' => $this->translate('the update method'),
|
||||||
'value' => 'LegacyTimePeriod',
|
'value' => 'LegacyTimePeriod',
|
||||||
));
|
));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: I'd like to skip this for objects inheriting from a template
|
// TODO: I'd like to skip this for objects inheriting from a template
|
||||||
// with a defined update_method. However, unfortunately it's too
|
// with a defined update_method. However, unfortunately it's too
|
||||||
|
@ -31,7 +31,6 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
|
|||||||
));
|
));
|
||||||
|
|
||||||
$this->setButtons();
|
$this->setButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTimePeriod(IcingaTimePeriod $period)
|
public function setTimePeriod(IcingaTimePeriod $period)
|
||||||
@ -52,9 +51,9 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
|
|||||||
|
|
||||||
if ($this->period->hasBeenModified()) {
|
if ($this->period->hasBeenModified()) {
|
||||||
if (! $object->hasBeenLoadedFromDb()) {
|
if (! $object->hasBeenLoadedFromDb()) {
|
||||||
|
|
||||||
$this->setHttpResponseCode(201);
|
$this->setHttpResponseCode(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = sprintf(
|
$msg = sprintf(
|
||||||
$object->hasBeenLoadedFromDb()
|
$object->hasBeenLoadedFromDb()
|
||||||
? $this->translate('The %s has successfully been stored')
|
? $this->translate('The %s has successfully been stored')
|
||||||
@ -63,7 +62,6 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->period->store($this->db);
|
$this->period->store($this->db);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($this->isApiRequest()) {
|
if ($this->isApiRequest()) {
|
||||||
$this->setHttpResponseCode(304);
|
$this->setHttpResponseCode(304);
|
||||||
|
@ -29,7 +29,6 @@ class IcingaUserForm extends DirectorObjectForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->isTemplate()) {
|
if (! $this->isTemplate()) {
|
||||||
|
|
||||||
$this->addElement('text', 'email', array(
|
$this->addElement('text', 'email', array(
|
||||||
'label' => $this->translate('Email'),
|
'label' => $this->translate('Email'),
|
||||||
'description' => $this->translate('The Email address of the user.')
|
'description' => $this->translate('The Email address of the user.')
|
||||||
|
@ -20,7 +20,6 @@ class IcingaUserGroupForm extends DirectorObjectForm
|
|||||||
->addZoneElements()
|
->addZoneElements()
|
||||||
->groupMainProperties()
|
->groupMainProperties()
|
||||||
->setButtons();
|
->setButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addZoneElements()
|
protected function addZoneElements()
|
||||||
|
@ -33,7 +33,6 @@ class ImportCheckForm extends QuickForm
|
|||||||
$this->setSuccessMessage(
|
$this->setSuccessMessage(
|
||||||
$this->translate('This Import Source provides modified data')
|
$this->translate('This Import Source provides modified data')
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->setSuccessMessage(
|
$this->setSuccessMessage(
|
||||||
$this->translate(
|
$this->translate(
|
||||||
|
@ -33,7 +33,6 @@ class ImportRunForm extends QuickForm
|
|||||||
$this->setSuccessMessage(
|
$this->setSuccessMessage(
|
||||||
$this->translate('Imported new data from this Import Source')
|
$this->translate('Imported new data from this Import Source')
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->setSuccessMessage(
|
$this->setSuccessMessage(
|
||||||
$this->translate(
|
$this->translate(
|
||||||
|
@ -39,7 +39,6 @@ class KickstartForm extends QuickForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->migrations()->hasSchema()) {
|
if (!$this->migrations()->hasSchema()) {
|
||||||
|
|
||||||
$this->addHtmlHint($this->translate(
|
$this->addHtmlHint($this->translate(
|
||||||
'No database schema has been created yet'
|
'No database schema has been created yet'
|
||||||
), array('name' => 'HINT_schema'));
|
), array('name' => 'HINT_schema'));
|
||||||
@ -50,7 +49,6 @@ class KickstartForm extends QuickForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->migrations()->hasPendingMigrations()) {
|
if ($this->migrations()->hasPendingMigrations()) {
|
||||||
|
|
||||||
$this->addHtmlHint($this->translate(
|
$this->addHtmlHint($this->translate(
|
||||||
'There are pending database migrations'
|
'There are pending database migrations'
|
||||||
), array('name' => 'HINT_schema'));
|
), array('name' => 'HINT_schema'));
|
||||||
@ -182,7 +180,6 @@ class KickstartForm extends QuickForm
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$db->fetchOne('SELECT 1');
|
$db->fetchOne('SELECT 1');
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->getElement('resource')
|
$this->getElement('resource')
|
||||||
->addError('Could not connect to database: ' . $e->getMessage());
|
->addError('Could not connect to database: ' . $e->getMessage());
|
||||||
|
@ -62,6 +62,5 @@ class SyncCheckForm extends QuickForm
|
|||||||
} else {
|
} else {
|
||||||
$this->addError($this->translate('Checking this sync rule failed'));
|
$this->addError($this->translate('Checking this sync rule failed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,6 @@ class SyncPropertyForm extends DirectorObjectForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->setButtons();
|
$this->setButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function hasSubOption($options, $key)
|
protected function hasSubOption($options, $key)
|
||||||
|
@ -94,7 +94,6 @@ class ActivityLogTable extends QuickTable
|
|||||||
'director/show/activitylog',
|
'director/show/activitylog',
|
||||||
array_merge(array('id' => $row->id), $this->extraParams)
|
array_merge(array('id' => $row->id), $this->extraParams)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@ class IcingaServiceSetServiceTable extends QuickTable
|
|||||||
);
|
);
|
||||||
|
|
||||||
return $this->url('director/host/servicesetservice', $params);
|
return $this->url('director/host/servicesetservice', $params);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$params = array(
|
$params = array(
|
||||||
'name' => $row->service,
|
'name' => $row->service,
|
||||||
|
@ -35,7 +35,6 @@ class IcingaServiceTable extends QuickTable
|
|||||||
$params['id'] = $row->id;
|
$params['id'] = $row->id;
|
||||||
} else {
|
} else {
|
||||||
$params = array('name' => $row->service);
|
$params = array('name' => $row->service);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->url('director/service', $params);
|
return $this->url('director/service', $params);
|
||||||
@ -56,7 +55,6 @@ class IcingaServiceTable extends QuickTable
|
|||||||
array('class' => 'icon-plus')
|
array('class' => 'icon-plus')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$htm .= '. Related apply rules: <table class="apply-rules">';
|
$htm .= '. Related apply rules: <table class="apply-rules">';
|
||||||
foreach ($extra as $service) {
|
foreach ($extra as $service) {
|
||||||
|
@ -73,7 +73,6 @@ class ImportsourceHookTable extends QuickTable
|
|||||||
public function fetchData()
|
public function fetchData()
|
||||||
{
|
{
|
||||||
if ($this->dataCache === null) {
|
if ($this->dataCache === null) {
|
||||||
|
|
||||||
$query = $this->getBaseQuery()->columns($this->getColumns());
|
$query = $this->getBaseQuery()->columns($this->getColumns());
|
||||||
|
|
||||||
if ($this->hasLimit() || $this->hasOffset()) {
|
if ($this->hasLimit() || $this->hasOffset()) {
|
||||||
|
@ -75,7 +75,6 @@ class Zend_View_Helper_FormExtensibleSet extends Zend_View_Helper_FormElement
|
|||||||
$total = count($value);
|
$total = count($value);
|
||||||
|
|
||||||
foreach ($value as $val) {
|
foreach ($value as $val) {
|
||||||
|
|
||||||
if ($multiOptions !== null) {
|
if ($multiOptions !== null) {
|
||||||
if (in_array($val, $validOptions)) {
|
if (in_array($val, $validOptions)) {
|
||||||
$multiOptions = $this->removeOption($multiOptions, $val);
|
$multiOptions = $this->removeOption($multiOptions, $val);
|
||||||
@ -129,7 +128,6 @@ class Zend_View_Helper_FormExtensibleSet extends Zend_View_Helper_FormElement
|
|||||||
$elements[] = $htm;
|
$elements[] = $htm;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$elements[] = '<li><input type="text"'
|
$elements[] = '<li><input type="text"'
|
||||||
. ' name="' . $name . '[]"'
|
. ' name="' . $name . '[]"'
|
||||||
. ($cnt === 0 ? '' : ' class="extend-set"')
|
. ($cnt === 0 ? '' : ' class="extend-set"')
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "icingaweb2-director",
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": ">= 4.8",
|
|
||||||
"icinga/icingaweb2": ">= 2.3",
|
|
||||||
"squizlabs/php_codesniffer": ">= 2"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Icinga\\Module\\Director\\": "library/Director/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "package",
|
|
||||||
"package": {
|
|
||||||
"name": "icinga/icingaweb2",
|
|
||||||
"version": "2.4.0",
|
|
||||||
"dist": {
|
|
||||||
"url": "https://github.com/Icinga/icingaweb2/archive/v2.4.0.zip",
|
|
||||||
"type": "zip"
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"url": "https://github.com/Icinga/icingaweb2.git",
|
|
||||||
"type": "git",
|
|
||||||
"reference": "master"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -135,7 +135,6 @@ class RestApiClient
|
|||||||
|
|
||||||
if (! $raw) {
|
if (! $raw) {
|
||||||
$headers[] = 'Accept: application/json';
|
$headers[] = 'Accept: application/json';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($body !== null) {
|
if ($body !== null) {
|
||||||
|
@ -214,11 +214,8 @@ abstract class CustomVariable implements IcingaConfigRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
|
|
||||||
return new CustomVariableString($key, $value);
|
return new CustomVariableString($key, $value);
|
||||||
|
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
|
|
||||||
foreach (array_keys($value) as $k) {
|
foreach (array_keys($value) as $k) {
|
||||||
if (! (is_int($k) || ctype_digit($k))) {
|
if (! (is_int($k) || ctype_digit($k))) {
|
||||||
return new CustomVariableDictionary($key, $value);
|
return new CustomVariableDictionary($key, $value);
|
||||||
@ -226,11 +223,9 @@ abstract class CustomVariable implements IcingaConfigRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new CustomVariableArray($key, array_values($value));
|
return new CustomVariableArray($key, array_values($value));
|
||||||
|
|
||||||
} elseif (is_object($value)) {
|
} elseif (is_object($value)) {
|
||||||
// TODO: check for specific class/stdClass/interface?
|
// TODO: check for specific class/stdClass/interface?
|
||||||
return new CustomVariableDictionary($key, $value);
|
return new CustomVariableDictionary($key, $value);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ProgrammingError('WTF (%s): %s', $key, var_export($value, 1));
|
throw new ProgrammingError('WTF (%s): %s', $key, var_export($value, 1));
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,6 @@ abstract class Dashlet
|
|||||||
} else {
|
} else {
|
||||||
$msg = $view->translate('One object has been defined');
|
$msg = $view->translate('One object has been defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$msg = sprintf(
|
$msg = sprintf(
|
||||||
$view->translate('%d objects have been defined'),
|
$view->translate('%d objects have been defined'),
|
||||||
@ -256,13 +255,13 @@ abstract class Dashlet
|
|||||||
|
|
||||||
$extra = array();
|
$extra = array();
|
||||||
if ($stat->cnt_total !== $stat->cnt_object) {
|
if ($stat->cnt_total !== $stat->cnt_object) {
|
||||||
|
|
||||||
if ($stat->cnt_template > 0) {
|
if ($stat->cnt_template > 0) {
|
||||||
$extra[] = sprintf(
|
$extra[] = sprintf(
|
||||||
$view->translate('%d of them are templates'),
|
$view->translate('%d of them are templates'),
|
||||||
$stat->cnt_template
|
$stat->cnt_template
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stat->cnt_external > 0) {
|
if ($stat->cnt_external > 0) {
|
||||||
$extra[] = sprintf(
|
$extra[] = sprintf(
|
||||||
$view->translate(
|
$view->translate(
|
||||||
|
@ -90,7 +90,6 @@ class DeploymentDashlet extends Dashlet
|
|||||||
if ($cnt === 0) {
|
if ($cnt === 0) {
|
||||||
$msgs[] = $this->translate('There are no pending changes');
|
$msgs[] = $this->translate('There are no pending changes');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$msgs[] = sprintf(
|
$msgs[] = sprintf(
|
||||||
$this->translate(
|
$this->translate(
|
||||||
'A total of %d config changes happened since your last'
|
'A total of %d config changes happened since your last'
|
||||||
|
@ -579,7 +579,6 @@ abstract class DbObject
|
|||||||
$properties = $this->db->fetchRow($select);
|
$properties = $this->db->fetchRow($select);
|
||||||
|
|
||||||
if (empty($properties)) {
|
if (empty($properties)) {
|
||||||
|
|
||||||
if (is_array($this->getKeyName())) {
|
if (is_array($this->getKeyName())) {
|
||||||
throw new NotFoundError(
|
throw new NotFoundError(
|
||||||
'Failed to load %s for %s',
|
'Failed to load %s for %s',
|
||||||
@ -654,7 +653,6 @@ abstract class DbObject
|
|||||||
$properties,
|
$properties,
|
||||||
$this->createWhere()
|
$this->createWhere()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -749,7 +747,6 @@ abstract class DbObject
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($e instanceof IE) {
|
if ($e instanceof IE) {
|
||||||
throw $e;
|
throw $e;
|
||||||
@ -1001,7 +998,6 @@ abstract class DbObject
|
|||||||
self::$prefetchStats[$class]->miss++;
|
self::$prefetchStats[$class]->miss++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self::$prefetchStats[$class]->miss++;
|
self::$prefetchStats[$class]->miss++;
|
||||||
return false;
|
return false;
|
||||||
|
@ -124,7 +124,6 @@ abstract class DbObjectWithSettings extends DbObject
|
|||||||
->from($this->settingsTable, array('setting_name', 'setting_value'))
|
->from($this->settingsTable, array('setting_name', 'setting_value'))
|
||||||
->where($this->settingsRemoteId . ' = ?', $this->get('id'))
|
->where($this->settingsRemoteId . ' = ?', $this->get('id'))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onLoadFromDb()
|
protected function onLoadFromDb()
|
||||||
|
@ -221,7 +221,6 @@ class IcingaObjectQuery
|
|||||||
if (! $this->hasAlias($alias . $cnt)) {
|
if (! $this->hasAlias($alias . $cnt)) {
|
||||||
return $alias . $cnt;
|
return $alias . $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (! $this->hasAlias($alias));
|
} while (! $this->hasAlias($alias));
|
||||||
|
|
||||||
return $alias;
|
return $alias;
|
||||||
|
@ -41,7 +41,6 @@ class CustomVariableCache
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($db->fetchAll($query) as $row) {
|
foreach ($db->fetchAll($query) as $row) {
|
||||||
|
|
||||||
$id = $row->id;
|
$id = $row->id;
|
||||||
unset($row->id);
|
unset($row->id);
|
||||||
|
|
||||||
|
@ -46,9 +46,7 @@ class Migration
|
|||||||
$db->exec($query);
|
$db->exec($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
throw new IcingaException(
|
throw new IcingaException(
|
||||||
'Migration %d failed (%s) while running %s',
|
'Migration %d failed (%s) while running %s',
|
||||||
$this->version,
|
$this->version,
|
||||||
|
@ -92,7 +92,6 @@ class AssignRenderer
|
|||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterMatch) {
|
} elseif ($filter instanceof FilterMatch) {
|
||||||
if (strpos($expression, '*') === false) {
|
if (strpos($expression, '*') === false) {
|
||||||
return $this->renderEquals($column, $expression);
|
return $this->renderEquals($column, $expression);
|
||||||
@ -103,7 +102,6 @@ class AssignRenderer
|
|||||||
$column
|
$column
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterMatchNot) {
|
} elseif ($filter instanceof FilterMatchNot) {
|
||||||
if (strpos($expression, '*') === false) {
|
if (strpos($expression, '*') === false) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
@ -118,42 +116,36 @@ class AssignRenderer
|
|||||||
$column
|
$column
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterNotEqual) {
|
} elseif ($filter instanceof FilterNotEqual) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s != %s',
|
'%s != %s',
|
||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterEqualOrGreaterThan) {
|
} elseif ($filter instanceof FilterEqualOrGreaterThan) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s >= %s',
|
'%s >= %s',
|
||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterEqualOrLessThan) {
|
} elseif ($filter instanceof FilterEqualOrLessThan) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s <= %s',
|
'%s <= %s',
|
||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterGreaterThan) {
|
} elseif ($filter instanceof FilterGreaterThan) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s > %s',
|
'%s > %s',
|
||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($filter instanceof FilterLessThan) {
|
} elseif ($filter instanceof FilterLessThan) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s < %s',
|
'%s < %s',
|
||||||
$column,
|
$column,
|
||||||
$expression
|
$expression
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new QueryException(
|
throw new QueryException(
|
||||||
'Filter expression of type "%s" is not supported',
|
'Filter expression of type "%s" is not supported',
|
||||||
|
@ -61,8 +61,8 @@ class ExtensibleSet
|
|||||||
{
|
{
|
||||||
if (null === $set) {
|
if (null === $set) {
|
||||||
$this->reset();
|
$this->reset();
|
||||||
return $this;
|
|
||||||
|
|
||||||
|
return $this;
|
||||||
} elseif (is_array($set) || is_string($set)) {
|
} elseif (is_array($set) || is_string($set)) {
|
||||||
$this->reset();
|
$this->reset();
|
||||||
$this->override($set);
|
$this->override($set);
|
||||||
|
@ -457,7 +457,6 @@ class IcingaConfig
|
|||||||
ini_set('zend.enable_gc', 0);
|
ini_set('zend.enable_gc', 0);
|
||||||
|
|
||||||
if (! $this->connection->isPgsql() && $this->db->quote("1\0") !== '\'1\\0\'') {
|
if (! $this->connection->isPgsql() && $this->db->quote("1\0") !== '\'1\\0\'') {
|
||||||
|
|
||||||
throw new IcingaException(
|
throw new IcingaException(
|
||||||
'Refusing to render the configuration, your DB layer corrupts binary data.'
|
'Refusing to render the configuration, your DB layer corrupts binary data.'
|
||||||
. ' You might be affected by Zend Framework bug #655'
|
. ' You might be affected by Zend Framework bug #655'
|
||||||
|
@ -158,7 +158,6 @@ class IcingaConfigHelper
|
|||||||
|
|
||||||
// Prefix for toConfigString?
|
// Prefix for toConfigString?
|
||||||
return "{\n" . implode("\n", $vals) . "\n}";
|
return "{\n" . implode("\n", $vals) . "\n}";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function renderExpression($string)
|
public static function renderExpression($string)
|
||||||
|
@ -287,7 +287,6 @@ class Import
|
|||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($this->isEmpty()) {
|
if ($this->isEmpty()) {
|
||||||
$newRows = array();
|
$newRows = array();
|
||||||
$newProperties = array();
|
$newProperties = array();
|
||||||
|
@ -276,9 +276,7 @@ class Sync
|
|||||||
json_encode($row)
|
json_encode($row)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (! property_exists($row, $key)) {
|
if (! property_exists($row, $key)) {
|
||||||
throw new IcingaException(
|
throw new IcingaException(
|
||||||
'There is no key column "%s" in this row from "%s": %s',
|
'There is no key column "%s" in this row from "%s": %s',
|
||||||
@ -287,7 +285,6 @@ class Sync
|
|||||||
json_encode($row)
|
json_encode($row)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->rule->matches($row)) {
|
if (! $this->rule->matches($row)) {
|
||||||
@ -339,7 +336,6 @@ class Sync
|
|||||||
{
|
{
|
||||||
// TODO: Make object_type (template, object...) and object_name mandatory?
|
// TODO: Make object_type (template, object...) and object_name mandatory?
|
||||||
if ($this->rule->hasCombinedKey()) {
|
if ($this->rule->hasCombinedKey()) {
|
||||||
|
|
||||||
$this->objects = array();
|
$this->objects = array();
|
||||||
$destinationKeyPattern = $this->rule->getDestinationKeyPattern();
|
$destinationKeyPattern = $this->rule->getDestinationKeyPattern();
|
||||||
|
|
||||||
@ -347,7 +343,6 @@ class Sync
|
|||||||
$this->rule->object_type,
|
$this->rule->object_type,
|
||||||
$this->db
|
$this->db
|
||||||
) as $object) {
|
) as $object) {
|
||||||
|
|
||||||
if ($object instanceof IcingaService) {
|
if ($object instanceof IcingaService) {
|
||||||
if (strstr($destinationKeyPattern, '${host}') && $object->host_id === null) {
|
if (strstr($destinationKeyPattern, '${host}') && $object->host_id === null) {
|
||||||
continue;
|
continue;
|
||||||
@ -608,9 +603,9 @@ class Sync
|
|||||||
$this->run->set('duration_ms', (int) round(
|
$this->run->set('duration_ms', (int) round(
|
||||||
(microtime(true) - $this->runStartTime) * 1000
|
(microtime(true) - $this->runStartTime) * 1000
|
||||||
))->store();
|
))->store();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$dba->rollBack();
|
$dba->rollBack();
|
||||||
|
|
||||||
if ($object !== null && $object instanceof IcingaObject) {
|
if ($object !== null && $object instanceof IcingaObject) {
|
||||||
throw new IcingaException(
|
throw new IcingaException(
|
||||||
'Exception while syncing %s %s: %s',
|
'Exception while syncing %s %s: %s',
|
||||||
|
@ -114,7 +114,6 @@ class ConfigJob extends JobHook
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Ignore those errors, Icinga may be reloading
|
// Ignore those errors, Icinga may be reloading
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new IcingaException('Failed to deploy config "%s"', $checksum);
|
throw new IcingaException('Failed to deploy config "%s"', $checksum);
|
||||||
}
|
}
|
||||||
@ -129,7 +128,6 @@ class ConfigJob extends JobHook
|
|||||||
{
|
{
|
||||||
if ($this->isWithinGracePeriod()) {
|
if ($this->isWithinGracePeriod()) {
|
||||||
if ($deployment = $this->lastDeployment()) {
|
if ($deployment = $this->lastDeployment()) {
|
||||||
|
|
||||||
return $deployment->getDeploymentTimestamp()
|
return $deployment->getDeploymentTimestamp()
|
||||||
+ $this->getSetting('grace_period')
|
+ $this->getSetting('grace_period')
|
||||||
- time();
|
- time();
|
||||||
|
@ -112,7 +112,6 @@ class KickstartHelper
|
|||||||
protected function apiUser()
|
protected function apiUser()
|
||||||
{
|
{
|
||||||
if ($this->apiUser === null) {
|
if ($this->apiUser === null) {
|
||||||
|
|
||||||
$name = $this->getValue('username');
|
$name = $this->getValue('username');
|
||||||
|
|
||||||
$user = IcingaApiUser::create(array(
|
$user = IcingaApiUser::create(array(
|
||||||
@ -217,7 +216,6 @@ class KickstartHelper
|
|||||||
|
|
||||||
$endpoints = array();
|
$endpoints = array();
|
||||||
foreach ($this->api()->setDb($db)->getEndpointObjects() as $object) {
|
foreach ($this->api()->setDb($db)->getEndpointObjects() as $object) {
|
||||||
|
|
||||||
if ($object->object_name === $master) {
|
if ($object->object_name === $master) {
|
||||||
$apiuser = $this->apiUser();
|
$apiuser = $this->apiUser();
|
||||||
$apiuser->store();
|
$apiuser->store();
|
||||||
@ -257,7 +255,6 @@ class KickstartHelper
|
|||||||
try {
|
try {
|
||||||
$this->switchToDeploymentApi()->getStatus();
|
$this->switchToDeploymentApi()->getStatus();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'I was unable to re-establish a connection to the Endpoint "%s" (%s:%d).'
|
'I was unable to re-establish a connection to the Endpoint "%s" (%s:%d).'
|
||||||
. ' When reconnecting to the configured Endpoint (%s:%d) I get an error: %s'
|
. ' When reconnecting to the configured Endpoint (%s:%d) I get an error: %s'
|
||||||
|
@ -55,7 +55,6 @@ class IcingaHostGroup extends IcingaObjectGroup
|
|||||||
$file = $this->legacyZoneHostgroupFile($config);
|
$file = $this->legacyZoneHostgroupFile($config);
|
||||||
$this->properties['members'] = array();
|
$this->properties['members'] = array();
|
||||||
$file->addLegacyObject($this);
|
$file->addLegacyObject($this);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$allMembers = array();
|
$allMembers = array();
|
||||||
|
|
||||||
|
@ -151,7 +151,6 @@ class IcingaNotification extends IcingaObject
|
|||||||
c::renderString($this->getObjectName()),
|
c::renderString($this->getObjectName()),
|
||||||
ucfirst($to)
|
ucfirst($to)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return parent::renderObjectHeader();
|
return parent::renderObjectHeader();
|
||||||
}
|
}
|
||||||
|
@ -2378,7 +2378,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($p as $k => $v) {
|
foreach ($p as $k => $v) {
|
||||||
|
|
||||||
// Do not ship ids for IcingaObjects:
|
// Do not ship ids for IcingaObjects:
|
||||||
if ($resolveIds) {
|
if ($resolveIds) {
|
||||||
if ($k === 'id' && $this->hasProperty('object_name')) {
|
if ($k === 'id' && $this->hasProperty('object_name')) {
|
||||||
@ -2389,7 +2388,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
$relKey = substr($k, 0, -3);
|
$relKey = substr($k, 0, -3);
|
||||||
|
|
||||||
if ($this->hasRelation($relKey)) {
|
if ($this->hasRelation($relKey)) {
|
||||||
|
|
||||||
if ($this->hasUnresolvedRelatedProperty($k)) {
|
if ($this->hasUnresolvedRelatedProperty($k)) {
|
||||||
$v = $this->$relKey;
|
$v = $this->$relKey;
|
||||||
} elseif ($v !== null) {
|
} elseif ($v !== null) {
|
||||||
@ -2419,7 +2417,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
} else {
|
} else {
|
||||||
$props[$k] = $v;
|
$props[$k] = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$props[$k] = $v;
|
$props[$k] = $v;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,6 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
|
|||||||
$unset = array();
|
$unset = array();
|
||||||
|
|
||||||
foreach ($group as $k => $g) {
|
foreach ($group as $k => $g) {
|
||||||
|
|
||||||
if ($g instanceof $class) {
|
if ($g instanceof $class) {
|
||||||
$new[] = $g->object_name;
|
$new[] = $g->object_name;
|
||||||
} else {
|
} else {
|
||||||
@ -174,10 +173,9 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
|
|||||||
|
|
||||||
if ($group instanceof $class) {
|
if ($group instanceof $class) {
|
||||||
$this->groups[$group->object_name] = $group;
|
$this->groups[$group->object_name] = $group;
|
||||||
|
|
||||||
} elseif (is_string($group)) {
|
} elseif (is_string($group)) {
|
||||||
|
|
||||||
$connection = $this->object->getConnection();
|
$connection = $this->object->getConnection();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->groups[$group] = $class::load($group, $connection);
|
$this->groups[$group] = $class::load($group, $connection);
|
||||||
} catch (NotFoundError $e) {
|
} catch (NotFoundError $e) {
|
||||||
|
@ -118,8 +118,8 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
|
|||||||
{
|
{
|
||||||
$list = array();
|
$list = array();
|
||||||
$class = $this->getImportClass();
|
$class = $this->getImportClass();
|
||||||
foreach ($imports as $i) {
|
|
||||||
|
|
||||||
|
foreach ($imports as $i) {
|
||||||
if ($i instanceof $class) {
|
if ($i instanceof $class) {
|
||||||
$list[] = $i->object_name;
|
$list[] = $i->object_name;
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,7 +110,6 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
|
|||||||
$unset = array();
|
$unset = array();
|
||||||
|
|
||||||
foreach ($relation as $k => $ro) {
|
foreach ($relation as $k => $ro) {
|
||||||
|
|
||||||
if ($ro instanceof $class) {
|
if ($ro instanceof $class) {
|
||||||
$new[] = $ro->object_name;
|
$new[] = $ro->object_name;
|
||||||
} else {
|
} else {
|
||||||
@ -187,9 +186,7 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
|
|||||||
|
|
||||||
if ($relation instanceof $class) {
|
if ($relation instanceof $class) {
|
||||||
$this->relations[$relation->object_name] = $relation;
|
$this->relations[$relation->object_name] = $relation;
|
||||||
|
|
||||||
} elseif (is_string($relation)) {
|
} elseif (is_string($relation)) {
|
||||||
|
|
||||||
$connection = $this->object->getConnection();
|
$connection = $this->object->getConnection();
|
||||||
try {
|
try {
|
||||||
// Related services can only be objects, used by ServiceSets
|
// Related services can only be objects, used by ServiceSets
|
||||||
@ -202,7 +199,6 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
|
|||||||
$relation = $class::load($relation, $connection);
|
$relation = $class::load($relation, $connection);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
switch ($onError) {
|
switch ($onError) {
|
||||||
case 'autocreate':
|
case 'autocreate':
|
||||||
$relation = $class::create(array(
|
$relation = $class::create(array(
|
||||||
|
@ -260,8 +260,8 @@ class IcingaService extends IcingaObject
|
|||||||
{
|
{
|
||||||
if ($this->isApplyRule()
|
if ($this->isApplyRule()
|
||||||
&& !$this->hasBeenAssignedToHostTemplate()
|
&& !$this->hasBeenAssignedToHostTemplate()
|
||||||
&& $this->get('apply_for') !== null) {
|
&& $this->get('apply_for') !== null
|
||||||
|
) {
|
||||||
$name = $this->getObjectName();
|
$name = $this->getObjectName();
|
||||||
$extraName = '';
|
$extraName = '';
|
||||||
|
|
||||||
@ -280,6 +280,7 @@ class IcingaService extends IcingaObject
|
|||||||
$this->get('apply_for')
|
$this->get('apply_for')
|
||||||
) . $extraName;
|
) . $extraName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::renderObjectHeader();
|
return parent::renderObjectHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class IcingaServiceSet extends IcingaObject
|
|||||||
return sprintf($comment, $this->getObjectName());
|
return sprintf($comment, $this->getObjectName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function copyVarsToService(IcingaService $service)
|
public function copyVarsToService(IcingaService $service)
|
||||||
{
|
{
|
||||||
$serviceVars = $service->vars();
|
$serviceVars = $service->vars();
|
||||||
|
|
||||||
@ -208,7 +208,6 @@ class IcingaServiceSet extends IcingaObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
foreach ($this->getServiceObjects() as $service) {
|
foreach ($this->getServiceObjects() as $service) {
|
||||||
$service->set('object_type', 'object');
|
$service->set('object_type', 'object');
|
||||||
$service->set('host_id', $this->get('host_id'));
|
$service->set('host_id', $this->get('host_id'));
|
||||||
|
@ -86,7 +86,6 @@ class IcingaTemplateResolver
|
|||||||
$object = $this->object;
|
$object = $this->object;
|
||||||
|
|
||||||
if ($object->hasBeenLoadedFromDb()) {
|
if ($object->hasBeenLoadedFromDb()) {
|
||||||
|
|
||||||
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
|
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
|
||||||
return $this->listUnstoredParentIds();
|
return $this->listUnstoredParentIds();
|
||||||
}
|
}
|
||||||
@ -121,11 +120,9 @@ class IcingaTemplateResolver
|
|||||||
$this->requireTemplates();
|
$this->requireTemplates();
|
||||||
|
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
|
|
||||||
$object = $this->object;
|
$object = $this->object;
|
||||||
|
|
||||||
if ($object->hasBeenLoadedFromDb()) {
|
if ($object->hasBeenLoadedFromDb()) {
|
||||||
|
|
||||||
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
|
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
|
||||||
return $this->listUnstoredParentNames();
|
return $this->listUnstoredParentNames();
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,6 @@ class ImportSource extends DbObjectWithSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->last_error_message = null;
|
$this->last_error_message = null;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->import_state = 'failing';
|
$this->import_state = 'failing';
|
||||||
Benchmark::measure('Import failed for ' . $this->source_name);
|
Benchmark::measure('Import failed for ' . $this->source_name);
|
||||||
|
@ -154,7 +154,6 @@ class SyncRule extends DbObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hadChanges = true;
|
$hadChanges = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Benchmark::measure('No modifications for sync rule ' . $this->get('rule_name'));
|
Benchmark::measure('No modifications for sync rule ' . $this->get('rule_name'));
|
||||||
$this->set('sync_state', 'in-sync');
|
$this->set('sync_state', 'in-sync');
|
||||||
@ -255,7 +254,6 @@ class SyncRule extends DbObject
|
|||||||
public function hasCombinedKey()
|
public function hasCombinedKey()
|
||||||
{
|
{
|
||||||
if ($this->hasCombinedKey === null) {
|
if ($this->hasCombinedKey === null) {
|
||||||
|
|
||||||
$this->hasCombinedKey = false;
|
$this->hasCombinedKey = false;
|
||||||
|
|
||||||
// TODO: Move to Objects
|
// TODO: Move to Objects
|
||||||
@ -341,7 +339,6 @@ class SyncRule extends DbObject
|
|||||||
|
|
||||||
$this->destinationKeyPattern = '${list_id}!${entry_name}';
|
$this->destinationKeyPattern = '${list_id}!${entry_name}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ class StartupLogRenderer
|
|||||||
$markPattern = null;
|
$markPattern = null;
|
||||||
// len [stage] + 1
|
// len [stage] + 1
|
||||||
$markReplace = ' ^';
|
$markReplace = ' ^';
|
||||||
foreach (preg_split('/\n/', $log) as $line) {
|
|
||||||
|
|
||||||
|
foreach (preg_split('/\n/', $log) as $line) {
|
||||||
if (preg_match($sevPattern, $line, $m)) {
|
if (preg_match($sevPattern, $line, $m)) {
|
||||||
$severity = $m[1];
|
$severity = $m[1];
|
||||||
$line = preg_replace(
|
$line = preg_replace(
|
||||||
|
28
library/Director/Test/Bootstrap.php
Normal file
28
library/Director/Test/Bootstrap.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Test;
|
||||||
|
|
||||||
|
use Icinga\Application\Cli;
|
||||||
|
|
||||||
|
class Bootstrap
|
||||||
|
{
|
||||||
|
public static function cli($basedir = null)
|
||||||
|
{
|
||||||
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
if ($basedir === null) {
|
||||||
|
$basedir = dirname(dirname(dirname(__DIR__)));
|
||||||
|
}
|
||||||
|
$testsDir = $basedir . '/test';
|
||||||
|
require_once 'Icinga/Application/Cli.php';
|
||||||
|
|
||||||
|
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
||||||
|
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
||||||
|
} else {
|
||||||
|
$configDir = $testsDir . '/config';
|
||||||
|
}
|
||||||
|
|
||||||
|
Cli::start($testsDir, $configDir)
|
||||||
|
->getModuleManager()
|
||||||
|
->loadModule('director', $basedir);
|
||||||
|
}
|
||||||
|
}
|
@ -62,6 +62,5 @@ class TestSuiteStyle extends TestSuite
|
|||||||
echo $out ."\n";
|
echo $out ."\n";
|
||||||
echo file_get_contents($out);
|
echo file_get_contents($out);
|
||||||
unlink($out);
|
unlink($out);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,6 @@ abstract class ActionController extends Controller
|
|||||||
$filter = $filterEditor->getFilter();
|
$filter = $filterEditor->getFilter();
|
||||||
|
|
||||||
if ($filter->isEmpty()) {
|
if ($filter->isEmpty()) {
|
||||||
|
|
||||||
if ($this->params->get('modifyFilter')) {
|
if ($this->params->get('modifyFilter')) {
|
||||||
$this->view->addLink .= ' ' . $this->view->qlink(
|
$this->view->addLink .= ' ' . $this->view->qlink(
|
||||||
$this->translate('Show unfiltered'),
|
$this->translate('Show unfiltered'),
|
||||||
@ -287,9 +286,7 @@ abstract class ActionController extends Controller
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->view->addLink .= ' ' . $this->view->qlink(
|
$this->view->addLink .= ' ' . $this->view->qlink(
|
||||||
$this->shorten($filter, 32),
|
$this->shorten($filter, 32),
|
||||||
$this->getRequest()->getUrl()->with('modifyFilter', true),
|
$this->getRequest()->getUrl()->with('modifyFilter', true),
|
||||||
|
@ -282,7 +282,6 @@ abstract class ObjectController extends ActionController
|
|||||||
null,
|
null,
|
||||||
array('class' => 'icon-left-big')
|
array('class' => 'icon-left-big')
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->handleRequest();
|
$form->handleRequest();
|
||||||
|
@ -479,11 +479,10 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
{
|
{
|
||||||
$object = $this->object();
|
$object = $this->object();
|
||||||
if ($object->hasBeenModified()) {
|
if ($object->hasBeenModified()) {
|
||||||
|
|
||||||
if (! $object->hasBeenLoadedFromDb()) {
|
if (! $object->hasBeenLoadedFromDb()) {
|
||||||
|
|
||||||
$this->setHttpResponseCode(201);
|
$this->setHttpResponseCode(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = sprintf(
|
$msg = sprintf(
|
||||||
$object->hasBeenLoadedFromDb()
|
$object->hasBeenLoadedFromDb()
|
||||||
? $this->translate('The %s has successfully been stored')
|
? $this->translate('The %s has successfully been stored')
|
||||||
@ -603,7 +602,6 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
$post = $values = $this->getRequest()->getPost();
|
$post = $values = $this->getRequest()->getPost();
|
||||||
|
|
||||||
foreach ($post as $key => $value) {
|
foreach ($post as $key => $value) {
|
||||||
|
|
||||||
if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) {
|
if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) {
|
||||||
$values[$m[1]] = array_filter($values[$m[1]], 'strlen');
|
$values[$m[1]] = array_filter($values[$m[1]], 'strlen');
|
||||||
switch ($m[3]) {
|
switch ($m[3]) {
|
||||||
@ -779,7 +777,6 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
|
|
||||||
if (!$this->hasObject()) {
|
if (!$this->hasObject()) {
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
|
|
||||||
return $this->getSentValue($name, $default);
|
return $this->getSentValue($name, $default);
|
||||||
} else {
|
} else {
|
||||||
if ($this->valueIsEmpty($val = $this->getValue($name))) {
|
if ($this->valueIsEmpty($val = $this->getValue($name))) {
|
||||||
@ -1105,8 +1102,8 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
);
|
);
|
||||||
|
|
||||||
$periods = $this->db->enumTimeperiods();
|
$periods = $this->db->enumTimeperiods();
|
||||||
if (!empty($periods)) {
|
|
||||||
|
|
||||||
|
if (!empty($periods)) {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'select',
|
'select',
|
||||||
'check_period_id',
|
'check_period_id',
|
||||||
|
@ -61,7 +61,6 @@ class DataFilter extends FormElement
|
|||||||
} else {
|
} else {
|
||||||
$value = $this->arrayToFilter($value);
|
$value = $this->arrayToFilter($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$value = null;
|
$value = null;
|
||||||
// TODO: getFile, getLine
|
// TODO: getFile, getLine
|
||||||
|
@ -223,7 +223,6 @@ class IcingaObjectFieldLoader
|
|||||||
$filters = array();
|
$filters = array();
|
||||||
foreach ($this->fields as $key => $field) {
|
foreach ($this->fields as $key => $field) {
|
||||||
if ($filter = $field->var_filter) {
|
if ($filter = $field->var_filter) {
|
||||||
|
|
||||||
$filters[$key] = Filter::fromQueryString($filter);
|
$filters[$key] = Filter::fromQueryString($filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,8 +149,8 @@ abstract class QuickForm extends QuickBaseForm
|
|||||||
'Fieldset',
|
'Fieldset',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->addDisplayGroup($elements, $name, $options);
|
|
||||||
|
|
||||||
|
return $this->addDisplayGroup($elements, $name, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createIdElement()
|
protected function createIdElement()
|
||||||
|
@ -114,7 +114,6 @@ abstract class QuickTable implements Paginatable
|
|||||||
$firstCol = true;
|
$firstCol = true;
|
||||||
|
|
||||||
foreach ($this->getTitles() as $key => $title) {
|
foreach ($this->getTitles() as $key => $title) {
|
||||||
|
|
||||||
// Support missing columns
|
// Support missing columns
|
||||||
if (property_exists($row, $key)) {
|
if (property_exists($row, $key)) {
|
||||||
$val = $row->$key;
|
$val = $row->$key;
|
||||||
|
@ -1,39 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Icinga\Application\Cli;
|
use Icinga\Module\Director\Test\Bootstrap;
|
||||||
|
|
||||||
## Load Composer environment, if existing
|
|
||||||
call_user_func(function () {
|
|
||||||
$MODULE_HOME = dirname(dirname(__FILE__));
|
|
||||||
$composer_load = $MODULE_HOME . '/vendor/autoload.php';
|
|
||||||
if (file_exists($composer_load)) {
|
|
||||||
require_once $composer_load;
|
|
||||||
|
|
||||||
# include Icinga Web
|
|
||||||
ini_set(
|
|
||||||
'include_path',
|
|
||||||
$MODULE_HOME . '/vendor/icinga/icingaweb2/library'
|
|
||||||
. PATH_SEPARATOR . $MODULE_HOME . '/vendor/icinga/icingaweb2/library/vendor'
|
|
||||||
. PATH_SEPARATOR . ini_get('include_path')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
call_user_func(function () {
|
call_user_func(function () {
|
||||||
|
$basedir = dirname(__DIR__);
|
||||||
error_reporting(E_ALL | E_STRICT);
|
require_once $basedir . '/library/Director/Test/Bootstrap.php';
|
||||||
$testbase = __DIR__;
|
Bootstrap::cli($basedir);
|
||||||
$base = dirname($testbase);
|
|
||||||
|
|
||||||
require_once 'Icinga/Application/Cli.php';
|
|
||||||
|
|
||||||
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
|
||||||
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
|
||||||
} else {
|
|
||||||
$configDir = $testbase . '/config';
|
|
||||||
}
|
|
||||||
|
|
||||||
Cli::start($testbase, $configDir)
|
|
||||||
->getModuleManager()
|
|
||||||
->loadModule('director', $base);
|
|
||||||
});
|
});
|
||||||
|
@ -724,7 +724,6 @@ class IcingaHostTest extends BaseTestCase
|
|||||||
foreach (DirectorDatafield::loadAll($db, $query, 'id') as $datafield) {
|
foreach (DirectorDatafield::loadAll($db, $query, 'id') as $datafield) {
|
||||||
$datafield->delete();
|
$datafield->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user