This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(broker): fix wizard broker configuration with one peer retention (#…
…6959) * fix(broker): fix wizard broker configuration with one peer retention mode * enh(broker): add poller name in one peer retention configuration name Refs: #6910 #6978 #6987 * add comments * fix broker configuration methods * Remote server add multiple authorized master (#7063) * fix(remote-server): Update authorizedMaster value using enableRemote * enh(remote-server): authorize multiple master * fix syntax error * improve centcore debug * fix bam broker configuration on remote server * test(ut): fix unit tests of remote server * test(ut): update value of mocked constants
- Loading branch information
Showing
100 changed files
with
5,548 additions
and
4,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
namespace Centreon\Domain\Entity; | ||
|
||
/** | ||
* Entity to manage broker configuration table : cfg_centreonbroker_info | ||
*/ | ||
class CfgCentreonBrokerInfo | ||
{ | ||
const TABLE = 'cfg_centreonbroker_info'; | ||
|
||
/** | ||
* @var int the linked config id | ||
*/ | ||
private $configId; | ||
|
||
/** | ||
* @var string the config group (input, output, log...) | ||
*/ | ||
private $configGroup; | ||
|
||
/** | ||
* @var int the config group id (its order in flows listing) | ||
*/ | ||
private $configGroupId; | ||
|
||
/** | ||
* @var int the config group level (eg: categories) | ||
*/ | ||
private $configGroupLevel; | ||
|
||
/** | ||
* @var string the name of the linked field | ||
*/ | ||
private $configKey; | ||
|
||
/** | ||
* @var string the value of the linked field | ||
*/ | ||
private $configValue; | ||
|
||
public function __construct(string $configKey, string $configValue) | ||
{ | ||
$this->configKey = $configKey; | ||
$this->configValue = $configValue; | ||
} | ||
|
||
public function setConfigId(int $configId): void | ||
{ | ||
$this->configId = $configId; | ||
} | ||
|
||
public function getConfigId(): int | ||
{ | ||
return $this->configId; | ||
} | ||
|
||
public function setConfigGroup(string $configGroup): void | ||
{ | ||
$this->configGroup = $configGroup; | ||
} | ||
|
||
public function getConfigGroup(): string | ||
{ | ||
return $this->configGroup; | ||
} | ||
|
||
public function setConfigGroupId(int $configGroupId): void | ||
{ | ||
$this->configGroupId = $configGroupId; | ||
} | ||
|
||
public function getConfigGroupId(): int | ||
{ | ||
return $this->configGroupId; | ||
} | ||
|
||
public function setConfigGroupLevel(int $configGroupLevel): void | ||
{ | ||
$this->configGroupLevel = $configGroupLevel; | ||
} | ||
|
||
public function getConfigGroupLevel(): int | ||
{ | ||
return $this->configGroupLevel; | ||
} | ||
|
||
public function setConfigKey(string $configKey): void | ||
{ | ||
$this->configKey = $configKey; | ||
} | ||
|
||
public function getConfigKey(): string | ||
{ | ||
return $this->configKey; | ||
} | ||
|
||
public function setConfigValue(string $configValue): void | ||
{ | ||
$this->configValue = $configValue; | ||
} | ||
|
||
public function getConfigValue(): string | ||
{ | ||
return $this->configValue; | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
src/Centreon/Domain/Repository/CfgCentreonBorkerInfoRepository.php
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
src/Centreon/Domain/Repository/CfgCentreonBorkerRepository.php
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
src/Centreon/Domain/Repository/CfgCentreonBrokerInfoRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
namespace Centreon\Domain\Repository; | ||
|
||
use Centreon\Domain\Repository\Interfaces\CfgCentreonBrokerInfoInterface; | ||
use Centreon\Domain\Entity\CfgCentreonBrokerInfo; | ||
use Centreon\Infrastructure\CentreonLegacyDB\ServiceEntityRepository; | ||
|
||
/** | ||
* Repository to manage centreon broker flows configuration (input, output...) | ||
*/ | ||
class CfgCentreonBrokerInfoRepository extends ServiceEntityRepository implements CfgCentreonBrokerInfoInterface | ||
{ | ||
/** | ||
* Get new config group id by config id for a specific flow | ||
* once the config group is got from this method, it is possible to insert a new flow in the broker configuration | ||
* | ||
* @param int $configId the broker configuration id | ||
* @param string $flow the flow type : input, output, log... | ||
* @return int the new config group id | ||
*/ | ||
public function getNewConfigGroupId(int $configId, string $flow): int | ||
{ | ||
// if there is no config group for a specific flow, first one id is 0 | ||
$configGroupId = 0; | ||
|
||
$sql = 'SELECT MAX(config_group_id) as max_config_group_id ' | ||
. 'FROM cfg_centreonbroker_info cbi ' | ||
. 'WHERE config_id = :config_id ' | ||
. 'AND config_group = :config_group'; | ||
$stmt = $this->db->prepare($sql); | ||
$stmt->bindParam(':config_id', $configId, \PDO::PARAM_INT); | ||
$stmt->bindParam(':config_group', $flow, \PDO::PARAM_STR); | ||
$stmt->execute(); | ||
|
||
$row = $stmt->fetch(); | ||
if (!is_null($row['max_config_group_id'])) { | ||
// to get the new new config group id, we need to increment the max exsting one | ||
$configGroupId = $row['max_config_group_id'] + 1; | ||
} | ||
|
||
return $configGroupId; | ||
} | ||
|
||
/** | ||
* Insert broker configuration in database (table cfg_centreonbroker_info) | ||
* | ||
* @param CfgCentreonBrokerInfo $brokerInfoEntity the broker info entity | ||
*/ | ||
public function add(CfgCentreonBrokerInfo $brokerInfoEntity): void | ||
{ | ||
$sql = "INSERT INTO " . $brokerInfoEntity::TABLE . ' ' | ||
. '(config_id, config_group, config_group_id, config_key, config_value) ' | ||
. 'VALUES (:config_id, :config_group, :config_group_id, :config_key, :config_value)'; | ||
$stmt = $this->db->prepare($sql); | ||
$stmt->bindValue(':config_id', $brokerInfoEntity->getConfigId(), \PDO::PARAM_INT); | ||
$stmt->bindValue(':config_group', $brokerInfoEntity->getConfigGroup(), \PDO::PARAM_STR); | ||
$stmt->bindValue(':config_group_id', $brokerInfoEntity->getConfigGroupId(), \PDO::PARAM_INT); | ||
$stmt->bindValue(':config_key', $brokerInfoEntity->getConfigKey(), \PDO::PARAM_STR); | ||
$stmt->bindValue(':config_value', $brokerInfoEntity->getConfigValue(), \PDO::PARAM_STR); | ||
$stmt->execute(); | ||
} | ||
|
||
/** | ||
* Export | ||
* | ||
* @param int[] $pollerIds | ||
* @return array | ||
*/ | ||
public function export(array $pollerIds): array | ||
{ | ||
// prevent SQL exception | ||
if (!$pollerIds) { | ||
return []; | ||
} | ||
|
||
$ids = join(',', $pollerIds); | ||
|
||
$sql = <<<SQL | ||
SELECT t.* | ||
FROM cfg_centreonbroker_info AS t | ||
INNER JOIN cfg_centreonbroker AS cci ON cci.config_id = t.config_id | ||
WHERE cci.ns_nagios_server IN ({$ids}) | ||
SQL; | ||
|
||
$stmt = $this->db->prepare($sql); | ||
$stmt->execute(); | ||
|
||
$result = []; | ||
|
||
while ($row = $stmt->fetch()) { | ||
$result[] = $row; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
Oops, something went wrong.