icingaweb2/modules/monitoring/test/php/testlib/datasource/strategies/PDOInsertionStrategy.php

304 lines
12 KiB
PHP
Raw Normal View History

<?php
2013-07-18 17:15:32 +02:00
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Test\Monitoring\Testlib\Datasource\Strategies;
use \Test\Monitoring\Testlib\DataSource\TestFixture;
2013-07-18 17:15:32 +02:00
/**
* TestFixture insertion implementation for PDO based backends
*
* This class allows to create the actual IDO databases from TestFixture
* classes using PDO.
*
*/
class PDOInsertionStrategy
{
/**
* Points to the (icinga) objectId of the next inserted object
* @var int
*/
private $objectId = 0;
2013-07-18 17:15:32 +02:00
/**
* The fixture that is being inserted by this object
* @var TestFixture
*/
private $fixture;
2013-07-18 17:15:32 +02:00
/**
* The database (PDO) connection to use for inserting
* @var \PDO
*/
private $connection;
2013-07-18 17:15:32 +02:00
/**
* The date format that will be used for inserting
* date values, see @link http://php.net/manual/en/function.date.php
* for possible values
*
* @var string
*/
public $datetimeFormat = "U";
2013-07-18 17:15:32 +02:00
/**
* @see InsertionStrategy::setConnection
*
* @param \PDO $connection The PDO connection to use
*/
public function setConnection($connection) {
$this->connection = $connection;
}
2013-07-18 17:15:32 +02:00
/**
* Insert the provided @see TestFixture into this database
*
* @param TestFixture $fixture The fixture to insert into the database
*/
public function insert(TestFixture $fixture)
{
$this->fixture = $fixture;
$this->insertContacts();
$this->insertHosts();
$this->insertServices();
$this->insertComments();
$this->insertHostgroups();
$this->insertServicegroups();
}
2013-07-18 17:15:32 +02:00
/**
* Insert all hosts from the current fixture into the IDO Database
*
* This method updates the icinga_objects, icinga_hosts, icinga_hoststatus
* and icinga_customvariablestatus tables with the host values provided
* by the internal fixture (@see PDOInsertStrategy::insert)
*
*/
private function insertHosts()
{
Merge branch 'feature/service-detail-view-4181' of ssh://git.icinga.org/icinga2-web Conflicts: library/Icinga/Application/Logger.php library/Icinga/Application/Web.php library/Icinga/Authentication/Backend/LdapUserBackend.php library/Icinga/Authentication/Credentials.php library/Icinga/Authentication/Manager.php library/Icinga/Authentication/PhpSession.php library/Icinga/Authentication/Session.php library/Icinga/Authentication/User.php library/Icinga/Authentication/UserBackend.php library/Icinga/Backend/AbstractBackend.php library/Icinga/Backend/DataView/ObjectRemappingView.php library/Icinga/Backend/Query.php library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php library/Icinga/Backend/Statusdat/HostlistQuery.php library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php library/Icinga/Backend/Statusdat/ServicelistQuery.php library/Icinga/Exception/ConfigurationError.php library/Icinga/Exception/MissingParameterException.php library/Icinga/Exception/NotImplementedError.php library/Icinga/Exception/ProgrammingError.php library/Icinga/Exception/SystemPermissionException.php library/Icinga/Protocol/AbstractQuery.php library/Icinga/Protocol/Commandpipe/Acknowledgement.php library/Icinga/Protocol/Commandpipe/CommandPipe.php library/Icinga/Protocol/Commandpipe/Comment.php library/Icinga/Protocol/Commandpipe/Downtime.php library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php library/Icinga/Protocol/Commandpipe/IComment.php library/Icinga/Protocol/Commandpipe/PropertyModifier.php library/Icinga/Protocol/Ldap/Connection.php library/Icinga/Protocol/Ldap/Exception.php library/Icinga/Protocol/Ldap/LdapUtils.php library/Icinga/Protocol/Ldap/Node.php library/Icinga/Protocol/Ldap/Query.php library/Icinga/Protocol/Ldap/Root.php library/Icinga/Protocol/Statusdat/Exception/ParsingException.php library/Icinga/Protocol/Statusdat/IReader.php library/Icinga/Protocol/Statusdat/ObjectContainer.php library/Icinga/Protocol/Statusdat/Parser.php library/Icinga/Protocol/Statusdat/Query.php library/Icinga/Protocol/Statusdat/Query/Expression.php library/Icinga/Protocol/Statusdat/Query/Group.php library/Icinga/Protocol/Statusdat/Query/IQueryPart.php library/Icinga/Protocol/Statusdat/Reader.php library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php library/Icinga/Protocol/Statusdat/View/AccessorStrategy.php library/Icinga/Web/ActionController.php library/Icinga/Web/Form.php library/Icinga/Web/Hook/Configuration/ConfigurationTab.php library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php library/Icinga/Web/Hook/Grapher.php library/Icinga/Web/Hook/Toptray.php library/Icinga/Web/ModuleActionController.php library/Icinga/Web/Notification.php library/Icinga/Web/Paginator/Adapter/QueryAdapter.php library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php library/Icinga/Web/Widget.php modules/monitoring/application/views/helpers/MonitoringCommands.php modules/monitoring/application/views/helpers/MonitoringFlags.php modules/monitoring/application/views/helpers/MonitoringProperties.php modules/monitoring/application/views/scripts/show/components/comments.phtml modules/monitoring/application/views/scripts/show/components/downtime.phtml modules/monitoring/application/views/scripts/show/components/flags.phtml modules/monitoring/application/views/scripts/show/components/properties.phtml modules/monitoring/application/views/scripts/show/header.phtml modules/monitoring/application/views/scripts/show/host.phtml modules/monitoring/application/views/scripts/show/service.phtml modules/monitoring/library/Monitoring/Backend/AbstractBackend.php modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat.php modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/StatusdatServiceView.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php modules/monitoring/library/Monitoring/Command/Meta.php modules/monitoring/library/Monitoring/View/DowntimeView.php modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php modules/monitoring/test/php/library/Command/MetaTest.php
2013-07-23 16:32:00 +02:00
$hosts = $this->fixture->getHosts();
$insertObjectQuery = $this->connection->prepare(
'INSERT INTO icinga_objects (object_id, objecttype_id, name1, is_active) VALUES (?, 1, ?, 1);'
);
$insertHostQuery = $this->connection->prepare(
'INSERT INTO icinga_hosts ('.
'host_id, alias, display_name, address, host_object_id, '.
'icon_image, notes_url, action_url'.
') VALUES (?, ?, ?, ?, ?, ?, ?, ?);'
);
$insertContactQuery = $this->connection->prepare(
'INSERT INTO icinga_host_contacts (host_id, contact_object_id) VALUES (?, ?);'
);
$insertHostStatusQuery = $this->connection->prepare(
'INSERT INTO icinga_hoststatus'.
2013-07-18 14:53:47 +02:00
'(host_object_id, current_state, last_check, last_state_change, notifications_enabled, '.
'active_checks_enabled, passive_checks_enabled, is_flapping, scheduled_downtime_depth,'.
'output, long_output, '.
'problem_has_been_acknowledged, has_been_checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
);
$insertCVQuery = $this->connection->prepare(
'INSERT INTO icinga_customvariablestatus'.
'(object_id, varname, varvalue) VALUES (?, ?, ?)'
);
foreach($hosts as &$host) {
$flags = $host["flags"];
$insertObjectQuery->execute(array($this->objectId, $host["name"]));
$insertHostQuery->execute(array(
2013-07-18 14:53:47 +02:00
$this->objectId, $host["name"]." alias", $host["name"], $host["address"], $this->objectId,
$host["icon_image"], $host["notes_url"], $host["action_url"]
));
$insertHostStatusQuery->execute(array(
2013-07-18 14:53:47 +02:00
$this->objectId, $host["state"], date($this->datetimeFormat, $flags->time),
date($this->datetimeFormat, $flags->time), $flags->notifications, $flags->active_checks,
$flags->passive_checks, $flags->flapping, $flags->in_downtime, "Plugin output for host ".$host["name"],
"Long plugin output for host ".$host["name"], $flags->acknowledged, $flags->is_pending == 0
));
foreach($host["contacts"] as $contact) {
$insertContactQuery->execute(array($this->objectId, $contact["object_id"]));
}
foreach($host["customvariables"] as $cvName=>$cvValue) {
$insertCVQuery->execute(array($this->objectId, $cvName, $cvValue));
}
$host["object_id"] = $this->objectId;
$this->objectId++;
}
}
2013-07-18 17:15:32 +02:00
/**
* Insert all services from the provided fixture into the IDO database
*
* This method updates the icinga_objects, icinga_services, icinga_servicestatus,
* icinga_service_contacts, icinga_customvariablestatus
*/
private function insertServices()
{
$services = $this->fixture->getServices();
$insertObjectQuery = $this->connection->prepare(
'INSERT INTO icinga_objects (object_id, objecttype_id, name1, name2, is_active) VALUES (?, 2, ?, ?, 1);'
);
$insertServiceQuery = $this->connection->prepare(
'INSERT INTO icinga_services ('.
'service_id, host_object_id, service_object_id, display_name, '.
'icon_image, notes_url, action_url'.
') VALUES (?, ?, ?, ?, ?, ?, ?)'
);
$insertServiceStatusQuery = $this->connection->prepare(
'INSERT INTO icinga_servicestatus'.
2013-07-18 14:53:47 +02:00
'(service_object_id, current_state, last_check, last_state_change, notifications_enabled, '.
'active_checks_enabled, passive_checks_enabled, is_flapping, scheduled_downtime_depth,'.
'output, long_output, '.
'problem_has_been_acknowledged, has_been_checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) '
);
$insertContactQuery = $this->connection->prepare(
'INSERT INTO icinga_service_contacts (host_id, contact_object_id) VALUES (?, ?);'
);
$insertCVQuery = $this->connection->prepare(
2013-07-18 17:15:32 +02:00
'INSERT INTO icinga_customvariablestatus '.
'(object_id, varname, varvalue) VALUES (?, ?, ?)'
);
foreach($services as &$service) {
$flags = $service["flags"];
$insertObjectQuery->execute(array($this->objectId, $service["host"]["name"], $service["name"]));
$insertServiceQuery->execute(array(
$this->objectId, $service['host']['object_id'], $this->objectId, $service['name'],
$service["icon_image"], $service["notes_url"], $service["action_url"]
));
$insertServiceStatusQuery->execute(array(
2013-07-18 14:53:47 +02:00
$this->objectId, $service["state"], date($this->datetimeFormat, $flags->time),
date($this->datetimeFormat, $flags->time), $flags->notifications, $flags->active_checks,
$flags->passive_checks, $flags->flapping, $flags->in_downtime, "Plugin output for service ".$service["name"],
"Long plugin output for service ".$service["name"], $flags->acknowledged,
$flags->is_pending == 0 ? '1' : '0'
2013-07-18 14:53:47 +02:00
));
foreach($service["contacts"] as $contact) {
$insertContactQuery->execute(array($this->objectId, $contact["object_id"]));
}
foreach($service["customvariables"] as $cvName=>$cvValue) {
$insertCVQuery->execute(array($this->objectId, $cvName, $cvValue));
}
$service["object_id"] = $this->objectId;
$this->objectId++;
}
}
2013-07-18 17:15:32 +02:00
/**
* Insert the contacts provided by the fixture into the database
*
* This method updates the icinga_objects and icinga_contacts tables
* according to the provided fixture
*/
private function insertContacts()
{
$insertObjectQuery = $this->connection->prepare(
'INSERT INTO icinga_objects (object_id, objecttype_id, name1) VALUES (?, 10, ?);'
);
$insertContactQuery = $this->connection->prepare(
'INSERT INTO icinga_contacts (contact_object_id, alias) VALUES (?, ?);'
);
Merge branch 'feature/service-detail-view-4181' of ssh://git.icinga.org/icinga2-web Conflicts: library/Icinga/Application/Logger.php library/Icinga/Application/Web.php library/Icinga/Authentication/Backend/LdapUserBackend.php library/Icinga/Authentication/Credentials.php library/Icinga/Authentication/Manager.php library/Icinga/Authentication/PhpSession.php library/Icinga/Authentication/Session.php library/Icinga/Authentication/User.php library/Icinga/Authentication/UserBackend.php library/Icinga/Backend/AbstractBackend.php library/Icinga/Backend/DataView/ObjectRemappingView.php library/Icinga/Backend/Query.php library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php library/Icinga/Backend/Statusdat/HostlistQuery.php library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php library/Icinga/Backend/Statusdat/ServicelistQuery.php library/Icinga/Exception/ConfigurationError.php library/Icinga/Exception/MissingParameterException.php library/Icinga/Exception/NotImplementedError.php library/Icinga/Exception/ProgrammingError.php library/Icinga/Exception/SystemPermissionException.php library/Icinga/Protocol/AbstractQuery.php library/Icinga/Protocol/Commandpipe/Acknowledgement.php library/Icinga/Protocol/Commandpipe/CommandPipe.php library/Icinga/Protocol/Commandpipe/Comment.php library/Icinga/Protocol/Commandpipe/Downtime.php library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php library/Icinga/Protocol/Commandpipe/IComment.php library/Icinga/Protocol/Commandpipe/PropertyModifier.php library/Icinga/Protocol/Ldap/Connection.php library/Icinga/Protocol/Ldap/Exception.php library/Icinga/Protocol/Ldap/LdapUtils.php library/Icinga/Protocol/Ldap/Node.php library/Icinga/Protocol/Ldap/Query.php library/Icinga/Protocol/Ldap/Root.php library/Icinga/Protocol/Statusdat/Exception/ParsingException.php library/Icinga/Protocol/Statusdat/IReader.php library/Icinga/Protocol/Statusdat/ObjectContainer.php library/Icinga/Protocol/Statusdat/Parser.php library/Icinga/Protocol/Statusdat/Query.php library/Icinga/Protocol/Statusdat/Query/Expression.php library/Icinga/Protocol/Statusdat/Query/Group.php library/Icinga/Protocol/Statusdat/Query/IQueryPart.php library/Icinga/Protocol/Statusdat/Reader.php library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php library/Icinga/Protocol/Statusdat/View/AccessorStrategy.php library/Icinga/Web/ActionController.php library/Icinga/Web/Form.php library/Icinga/Web/Hook/Configuration/ConfigurationTab.php library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php library/Icinga/Web/Hook/Grapher.php library/Icinga/Web/Hook/Toptray.php library/Icinga/Web/ModuleActionController.php library/Icinga/Web/Notification.php library/Icinga/Web/Paginator/Adapter/QueryAdapter.php library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php library/Icinga/Web/Widget.php modules/monitoring/application/views/helpers/MonitoringCommands.php modules/monitoring/application/views/helpers/MonitoringFlags.php modules/monitoring/application/views/helpers/MonitoringProperties.php modules/monitoring/application/views/scripts/show/components/comments.phtml modules/monitoring/application/views/scripts/show/components/downtime.phtml modules/monitoring/application/views/scripts/show/components/flags.phtml modules/monitoring/application/views/scripts/show/components/properties.phtml modules/monitoring/application/views/scripts/show/header.phtml modules/monitoring/application/views/scripts/show/host.phtml modules/monitoring/application/views/scripts/show/service.phtml modules/monitoring/library/Monitoring/Backend/AbstractBackend.php modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat.php modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/StatusdatServiceView.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php modules/monitoring/library/Monitoring/Command/Meta.php modules/monitoring/library/Monitoring/View/DowntimeView.php modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php modules/monitoring/test/php/library/Command/MetaTest.php
2013-07-23 16:32:00 +02:00
$contacts = $this->fixture->getContacts();
foreach($contacts as &$contact) {
$insertObjectQuery->execute($this->objectId, $contact["alias"]);
$insertContactQuery->execute($this->objectId, $contact["alias"]);
$contact["object_id"] = $this->objectId;
$this->objectId++;
}
}
2013-07-18 17:15:32 +02:00
/**
* Insert comments provided by the fixture into the IDO database
*
* This method updates the icinga_comments table according to the provided
* fixture
*/
private function insertComments()
2013-07-18 14:53:47 +02:00
{ $comment_id=0;
$insertCommentsQuery = $this->connection->prepare(
2013-07-18 14:53:47 +02:00
'INSERT INTO icinga_comments (object_id, comment_type, internal_comment_id, author_name, comment_data)'.
' VALUES (?, ?, ?, ?, ?);'
);
Merge branch 'feature/service-detail-view-4181' of ssh://git.icinga.org/icinga2-web Conflicts: library/Icinga/Application/Logger.php library/Icinga/Application/Web.php library/Icinga/Authentication/Backend/LdapUserBackend.php library/Icinga/Authentication/Credentials.php library/Icinga/Authentication/Manager.php library/Icinga/Authentication/PhpSession.php library/Icinga/Authentication/Session.php library/Icinga/Authentication/User.php library/Icinga/Authentication/UserBackend.php library/Icinga/Backend/AbstractBackend.php library/Icinga/Backend/DataView/ObjectRemappingView.php library/Icinga/Backend/Query.php library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php library/Icinga/Backend/Statusdat/HostlistQuery.php library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php library/Icinga/Backend/Statusdat/ServicelistQuery.php library/Icinga/Exception/ConfigurationError.php library/Icinga/Exception/MissingParameterException.php library/Icinga/Exception/NotImplementedError.php library/Icinga/Exception/ProgrammingError.php library/Icinga/Exception/SystemPermissionException.php library/Icinga/Protocol/AbstractQuery.php library/Icinga/Protocol/Commandpipe/Acknowledgement.php library/Icinga/Protocol/Commandpipe/CommandPipe.php library/Icinga/Protocol/Commandpipe/Comment.php library/Icinga/Protocol/Commandpipe/Downtime.php library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php library/Icinga/Protocol/Commandpipe/IComment.php library/Icinga/Protocol/Commandpipe/PropertyModifier.php library/Icinga/Protocol/Ldap/Connection.php library/Icinga/Protocol/Ldap/Exception.php library/Icinga/Protocol/Ldap/LdapUtils.php library/Icinga/Protocol/Ldap/Node.php library/Icinga/Protocol/Ldap/Query.php library/Icinga/Protocol/Ldap/Root.php library/Icinga/Protocol/Statusdat/Exception/ParsingException.php library/Icinga/Protocol/Statusdat/IReader.php library/Icinga/Protocol/Statusdat/ObjectContainer.php library/Icinga/Protocol/Statusdat/Parser.php library/Icinga/Protocol/Statusdat/Query.php library/Icinga/Protocol/Statusdat/Query/Expression.php library/Icinga/Protocol/Statusdat/Query/Group.php library/Icinga/Protocol/Statusdat/Query/IQueryPart.php library/Icinga/Protocol/Statusdat/Reader.php library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php library/Icinga/Protocol/Statusdat/View/AccessorStrategy.php library/Icinga/Web/ActionController.php library/Icinga/Web/Form.php library/Icinga/Web/Hook/Configuration/ConfigurationTab.php library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php library/Icinga/Web/Hook/Grapher.php library/Icinga/Web/Hook/Toptray.php library/Icinga/Web/ModuleActionController.php library/Icinga/Web/Notification.php library/Icinga/Web/Paginator/Adapter/QueryAdapter.php library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php library/Icinga/Web/Widget.php modules/monitoring/application/views/helpers/MonitoringCommands.php modules/monitoring/application/views/helpers/MonitoringFlags.php modules/monitoring/application/views/helpers/MonitoringProperties.php modules/monitoring/application/views/scripts/show/components/comments.phtml modules/monitoring/application/views/scripts/show/components/downtime.phtml modules/monitoring/application/views/scripts/show/components/flags.phtml modules/monitoring/application/views/scripts/show/components/properties.phtml modules/monitoring/application/views/scripts/show/header.phtml modules/monitoring/application/views/scripts/show/host.phtml modules/monitoring/application/views/scripts/show/service.phtml modules/monitoring/library/Monitoring/Backend/AbstractBackend.php modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat.php modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/StatusdatServiceView.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php modules/monitoring/library/Monitoring/Command/Meta.php modules/monitoring/library/Monitoring/View/DowntimeView.php modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php modules/monitoring/test/php/library/Command/MetaTest.php
2013-07-23 16:32:00 +02:00
$comments = $this->fixture->getComments();
foreach ($comments as $comment) {
if (isset($comment["host"])) {
$type = 1;
$object_id = $comment["host"]["object_id"];
} elseif (isset($comment["service"])) {
$type = 2;
$object_id = $comment["service"]["object_id"];
}
2013-07-18 14:53:47 +02:00
$insertCommentsQuery->execute(array(
$object_id, $type, $comment_id++, $comment["author"], $comment["text"]
));
}
}
2013-07-18 17:15:32 +02:00
/**
* Insert hostgroups from the provided fixture into the IDO database
*
* This method updates the icinga_objects, icinga_hostgroups and icinga_hostgroup_members
* table with the values provide by the fixture
*/
private function insertHostgroups()
{
$insertObjectQuery = $this->connection->prepare(
'INSERT INTO icinga_objects (object_id, objecttype_id, name1) VALUES (?, 3, ?)'
);
$insertHostgroupQuery = $this->connection->prepare(
'INSERT INTO icinga_hostgroups (hostgroup_id, hostgroup_object_id, alias) VALUES (?, ?, ?)'
);
$insertHostgroupMemberQuery = $this->connection->prepare(
'INSERT INTO icinga_hostgroup_members (hostgroup_id, host_object_id) VALUES (?, ?)'
);
Merge branch 'feature/service-detail-view-4181' of ssh://git.icinga.org/icinga2-web Conflicts: library/Icinga/Application/Logger.php library/Icinga/Application/Web.php library/Icinga/Authentication/Backend/LdapUserBackend.php library/Icinga/Authentication/Credentials.php library/Icinga/Authentication/Manager.php library/Icinga/Authentication/PhpSession.php library/Icinga/Authentication/Session.php library/Icinga/Authentication/User.php library/Icinga/Authentication/UserBackend.php library/Icinga/Backend/AbstractBackend.php library/Icinga/Backend/DataView/ObjectRemappingView.php library/Icinga/Backend/Query.php library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php library/Icinga/Backend/Statusdat/HostlistQuery.php library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php library/Icinga/Backend/Statusdat/ServicelistQuery.php library/Icinga/Exception/ConfigurationError.php library/Icinga/Exception/MissingParameterException.php library/Icinga/Exception/NotImplementedError.php library/Icinga/Exception/ProgrammingError.php library/Icinga/Exception/SystemPermissionException.php library/Icinga/Protocol/AbstractQuery.php library/Icinga/Protocol/Commandpipe/Acknowledgement.php library/Icinga/Protocol/Commandpipe/CommandPipe.php library/Icinga/Protocol/Commandpipe/Comment.php library/Icinga/Protocol/Commandpipe/Downtime.php library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php library/Icinga/Protocol/Commandpipe/IComment.php library/Icinga/Protocol/Commandpipe/PropertyModifier.php library/Icinga/Protocol/Ldap/Connection.php library/Icinga/Protocol/Ldap/Exception.php library/Icinga/Protocol/Ldap/LdapUtils.php library/Icinga/Protocol/Ldap/Node.php library/Icinga/Protocol/Ldap/Query.php library/Icinga/Protocol/Ldap/Root.php library/Icinga/Protocol/Statusdat/Exception/ParsingException.php library/Icinga/Protocol/Statusdat/IReader.php library/Icinga/Protocol/Statusdat/ObjectContainer.php library/Icinga/Protocol/Statusdat/Parser.php library/Icinga/Protocol/Statusdat/Query.php library/Icinga/Protocol/Statusdat/Query/Expression.php library/Icinga/Protocol/Statusdat/Query/Group.php library/Icinga/Protocol/Statusdat/Query/IQueryPart.php library/Icinga/Protocol/Statusdat/Reader.php library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php library/Icinga/Protocol/Statusdat/View/AccessorStrategy.php library/Icinga/Web/ActionController.php library/Icinga/Web/Form.php library/Icinga/Web/Hook/Configuration/ConfigurationTab.php library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php library/Icinga/Web/Hook/Grapher.php library/Icinga/Web/Hook/Toptray.php library/Icinga/Web/ModuleActionController.php library/Icinga/Web/Notification.php library/Icinga/Web/Paginator/Adapter/QueryAdapter.php library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php library/Icinga/Web/Widget.php modules/monitoring/application/views/helpers/MonitoringCommands.php modules/monitoring/application/views/helpers/MonitoringFlags.php modules/monitoring/application/views/helpers/MonitoringProperties.php modules/monitoring/application/views/scripts/show/components/comments.phtml modules/monitoring/application/views/scripts/show/components/downtime.phtml modules/monitoring/application/views/scripts/show/components/flags.phtml modules/monitoring/application/views/scripts/show/components/properties.phtml modules/monitoring/application/views/scripts/show/header.phtml modules/monitoring/application/views/scripts/show/host.phtml modules/monitoring/application/views/scripts/show/service.phtml modules/monitoring/library/Monitoring/Backend/AbstractBackend.php modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat.php modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/StatusdatServiceView.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php modules/monitoring/library/Monitoring/Command/Meta.php modules/monitoring/library/Monitoring/View/DowntimeView.php modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php modules/monitoring/test/php/library/Command/MetaTest.php
2013-07-23 16:32:00 +02:00
$hostgroups = $this->fixture->getHostgroups();
foreach ($hostgroups as &$hostgroup) {
$insertObjectQuery->execute(array($this->objectId, $hostgroup["name"]));
$insertHostgroupQuery->execute(array($this->objectId, $this->objectId, $hostgroup["name"]));
foreach ($hostgroup["members"] as $member) {
$insertHostgroupMemberQuery->execute(array($this->objectId, $member["object_id"]));
}
$this->objectId++;
}
}
2013-07-18 17:15:32 +02:00
/**
* Insert servicegroups from the provided fixture into the IDO database
*
* This method updates the icinga_objects, icinga_servicegroups and icinga_servicegroup_members
* table with the values provide by the fixture
*/
private function insertServicegroups()
{
$insertObjectQuery = $this->connection->prepare(
'INSERT INTO icinga_objects (object_id, objecttype_id, name1) VALUES (?, 4, ?)'
);
$insertServicegroupQuery = $this->connection->prepare(
'INSERT INTO icinga_servicegroups (servicegroup_id, servicegroup_object_id, alias) VALUES (?, ?, ?)'
);
$insertServicegroupMemberQuery = $this->connection->prepare(
'INSERT INTO icinga_servicegroup_members (servicegroup_id, service_object_id) VALUES (?, ?)'
);
Merge branch 'feature/service-detail-view-4181' of ssh://git.icinga.org/icinga2-web Conflicts: library/Icinga/Application/Logger.php library/Icinga/Application/Web.php library/Icinga/Authentication/Backend/LdapUserBackend.php library/Icinga/Authentication/Credentials.php library/Icinga/Authentication/Manager.php library/Icinga/Authentication/PhpSession.php library/Icinga/Authentication/Session.php library/Icinga/Authentication/User.php library/Icinga/Authentication/UserBackend.php library/Icinga/Backend/AbstractBackend.php library/Icinga/Backend/DataView/ObjectRemappingView.php library/Icinga/Backend/Query.php library/Icinga/Backend/Statusdat/DataView/StatusdatHostView.php library/Icinga/Backend/Statusdat/HostgroupsummaryQuery.php library/Icinga/Backend/Statusdat/HostlistQuery.php library/Icinga/Backend/Statusdat/ServicegroupsummaryQuery.php library/Icinga/Backend/Statusdat/ServicelistQuery.php library/Icinga/Exception/ConfigurationError.php library/Icinga/Exception/MissingParameterException.php library/Icinga/Exception/NotImplementedError.php library/Icinga/Exception/ProgrammingError.php library/Icinga/Exception/SystemPermissionException.php library/Icinga/Protocol/AbstractQuery.php library/Icinga/Protocol/Commandpipe/Acknowledgement.php library/Icinga/Protocol/Commandpipe/CommandPipe.php library/Icinga/Protocol/Commandpipe/Comment.php library/Icinga/Protocol/Commandpipe/Downtime.php library/Icinga/Protocol/Commandpipe/Exception/InvalidCommandException.php library/Icinga/Protocol/Commandpipe/IComment.php library/Icinga/Protocol/Commandpipe/PropertyModifier.php library/Icinga/Protocol/Ldap/Connection.php library/Icinga/Protocol/Ldap/Exception.php library/Icinga/Protocol/Ldap/LdapUtils.php library/Icinga/Protocol/Ldap/Node.php library/Icinga/Protocol/Ldap/Query.php library/Icinga/Protocol/Ldap/Root.php library/Icinga/Protocol/Statusdat/Exception/ParsingException.php library/Icinga/Protocol/Statusdat/IReader.php library/Icinga/Protocol/Statusdat/ObjectContainer.php library/Icinga/Protocol/Statusdat/Parser.php library/Icinga/Protocol/Statusdat/Query.php library/Icinga/Protocol/Statusdat/Query/Expression.php library/Icinga/Protocol/Statusdat/Query/Group.php library/Icinga/Protocol/Statusdat/Query/IQueryPart.php library/Icinga/Protocol/Statusdat/Reader.php library/Icinga/Protocol/Statusdat/RuntimeStateContainer.php library/Icinga/Protocol/Statusdat/View/AccessorStrategy.php library/Icinga/Web/ActionController.php library/Icinga/Web/Form.php library/Icinga/Web/Hook/Configuration/ConfigurationTab.php library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php library/Icinga/Web/Hook/Grapher.php library/Icinga/Web/Hook/Toptray.php library/Icinga/Web/ModuleActionController.php library/Icinga/Web/Notification.php library/Icinga/Web/Paginator/Adapter/QueryAdapter.php library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php library/Icinga/Web/Widget.php modules/monitoring/application/views/helpers/MonitoringCommands.php modules/monitoring/application/views/helpers/MonitoringFlags.php modules/monitoring/application/views/helpers/MonitoringProperties.php modules/monitoring/application/views/scripts/show/components/comments.phtml modules/monitoring/application/views/scripts/show/components/downtime.phtml modules/monitoring/application/views/scripts/show/components/flags.phtml modules/monitoring/application/views/scripts/show/components/properties.phtml modules/monitoring/application/views/scripts/show/header.phtml modules/monitoring/application/views/scripts/show/host.phtml modules/monitoring/application/views/scripts/show/service.phtml modules/monitoring/library/Monitoring/Backend/AbstractBackend.php modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat.php modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/StatusdatServiceView.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/GroupsummaryQuery.php modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php modules/monitoring/library/Monitoring/Command/Meta.php modules/monitoring/library/Monitoring/View/DowntimeView.php modules/monitoring/test/php/application/views/helpers/MonitoringCommandsTest.php modules/monitoring/test/php/application/views/helpers/MonitoringPropertiesTest.php modules/monitoring/test/php/library/Command/MetaTest.php
2013-07-23 16:32:00 +02:00
$servicegroups = $this->fixture->getServicegroups();
foreach ($servicegroups as &$servicegroup) {
$insertObjectQuery->execute(array($this->objectId, $servicegroup["name"]));
$insertServicegroupQuery->execute(array($this->objectId, $this->objectId, $servicegroup["name"]));
foreach ($servicegroup["members"] as $member) {
$insertServicegroupMemberQuery->execute(array($this->objectId, $member["object_id"]));
}
$this->objectId++;
}
}
}