Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
enh(resources): remove resource status repository switch possibility (#…
Browse files Browse the repository at this point in the history
…11354)

* enh(resources): remove resource status repository switch possibility

* try to fix tests

* Rename service for acknowledgement

* Remove console statement

Co-authored-by: Tom Darneix <tomdar87@outlook.com>
  • Loading branch information
adr-mo and Thebarda authored Jul 19, 2022
1 parent caddc81 commit fde2603
Show file tree
Hide file tree
Showing 32 changed files with 39 additions and 2,520 deletions.
33 changes: 4 additions & 29 deletions config/packages/Centreon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ parameters:
debug_log_file: '%log_path%/centreon-web.log'
env(DEBUG_LEVEL): !php/const Monolog\Logger::NOTICE
curl.timeout: 60
resource.status.repository.legacy: 'legacy'
env(APP_RESOURCE_STATUS_REPOSITORY_MODE): '%resource.status.repository.legacy%'
resource.status.repository: '%env(APP_RESOURCE_STATUS_REPOSITORY_MODE)%'
debug_level: "%env(int:DEBUG_LEVEL)%"
env(DEBUG_CONTACT): null

Expand Down Expand Up @@ -225,11 +222,6 @@ services:

# Monitoring resources
_instanceof:
Centreon\Infrastructure\Monitoring\Resource\Provider\ProviderInterface:
tags: ['monitoring.resource.providers']
calls:
- method: setSqlRequestTranslator
arguments: ['@sqlRequestTranslator']
Core\Infrastructure\RealTime\Hypermedia\HypermediaProviderInterface:
tags: ['realtime.hypermedia']
Core\Security\Application\ProviderConfiguration\Repository\ReadProviderConfigurationsRepositoryInterface:
Expand All @@ -239,14 +231,10 @@ services:
Core\Security\Infrastructure\Api\FindProviderConfigurations\ProviderPresenter\ProviderPresenterInterface:
tags: ['authentication.provider.presenters']

Centreon\Domain\Monitoring\Interfaces\ResourceRepositoryInterface:
factory: ['@Centreon\Infrastructure\Monitoring\Resource\ResourceRepositoryFactory', 'createResourceRepository']

Centreon\Infrastructure\Monitoring\Resource\ResourceRepositoryFactory:
class: Centreon\Infrastructure\Monitoring\Resource\ResourceRepositoryFactory
arguments: ['@=parameter("resource.status.repository") === parameter("resource.status.repository.legacy")
? service("Centreon\\Infrastructure\\Monitoring\\Resource\\ResourceRepositoryRDB")
: service("Centreon\\Infrastructure\\Monitoring\\Resource\\DbReadResourceRepository")']
Core\Resources\Application\Repository\ReadResourceRepositoryInterface:
class: Core\Resources\Infrastructure\Repository\DbReadResourceRepository
arguments:
$sqlRequestTranslator: '@sqlRequestTranslator'

Core\Security\Application\UseCase\FindProviderConfigurations\FindProviderConfigurations:
arguments:
Expand All @@ -256,19 +244,6 @@ services:
Core\Security\Infrastructure\Api\FindProviderConfigurations\FindProviderConfigurationsPresenter:
arguments: [!tagged_iterator 'authentication.provider.presenters']


Centreon\Infrastructure\Monitoring\Resource\ResourceRepositoryRDB:
calls:
- method: setSqlRequestTranslator
arguments: ['@sqlRequestTranslator']
- method: setProviders
arguments: [!tagged_iterator 'monitoring.resource.providers']

Centreon\Infrastructure\Monitoring\Resource\DbReadResourceRepository:
calls:
- method: setSqlRequestTranslator
arguments: ['@sqlRequestTranslator']

Core\Infrastructure\RealTime\Hypermedia\HypermediaCreator:
class: Core\Infrastructure\RealTime\Hypermedia\HypermediaCreator
calls:
Expand Down
5 changes: 0 additions & 5 deletions lang/fr_FR.UTF-8/LC_MESSAGES/help.po
Original file line number Diff line number Diff line change
Expand Up @@ -7215,11 +7215,6 @@ msgstr ""
msgid "Expected TLS certificate common name (CN) - leave blank if unsure."
msgstr "Champ common name (CN) attendu dans le certificat TLS - laisser vide en cas de doute"

msgid "Mode used to retrieve information displayed in Resource Status page."
"The optimized mode will only be available and functional when using the BBDO 3.0.0 protocol for the collect engine."
msgstr "Mode utilisé pour récupérer les données affichées dans la page Resource Status."
"Le mode optimisé pourra être utilisé et fonctionnel que si le moteur de supervision utilise le protocole BBDO 3.0.0"

msgid "Poller Configuration Actions / Poller Management"
msgstr "Actions de configuration du collecteur / Gestion du collecteur"

Expand Down
16 changes: 0 additions & 16 deletions lang/fr_FR.UTF-8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -16856,22 +16856,6 @@ msgstr "Vous n'êtes pas autorisé à accéder aux groupes de contacts"
msgid "Error while searching for the host template %d"
msgstr "Erreur lors de la recherche du modèle d'hôte %d"

#: www/include/Administration/parameters/DB-Func.php
msgid "Could not change resource status mode."
msgstr "Le mode pour Resource Status n'a pas pu être changé"

#: www/include/Administration/parameters/DB-Func.php
msgid "Reason: error when updating PHP environment file"
msgstr "Raison: erreur lors de la mise à jour du fichier PHP d'environnement"

#: www/include/Administration/parameters/DB-Func.php
msgid "Reason: PHP environment file is not writable"
msgstr "Raison: le fichier PHP d'environnement n'est pas éditable"

#: www/include/Administration/parameters/engine/form.php
msgid "Resource Status mod"
msgstr "Mode pour Resource Status"

msgid "This section allows you to give authorizations in order to link an imported user to an access group."
msgstr "Cette section vous permet de donner des autorisations afin de lier un utilisateur importé à un groupe d'accès."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,83 +22,11 @@

namespace Centreon\Domain\Monitoring\Interfaces;

use Centreon\Domain\Monitoring\Interfaces\ResourceRepositoryInterface;
use Centreon\Domain\Monitoring\ResourceFilter;
use Centreon\Domain\Monitoring\Resource as ResourceEntity;
use Centreon\Domain\Monitoring\Exception\ResourceException;

interface ResourceServiceInterface
{
public const TYPE_SERVICE = 'service';
public const TYPE_HOST = 'host';

/**
* List of all types
*/
public const TYPES = [
self::TYPE_HOST,
self::TYPE_SERVICE,
];

/**
* Non-ok status in hard state , not acknowledged & not in downtime
*/
public const STATE_UNHANDLED_PROBLEMS = 'unhandled_problems';

/**
* Non-ok status in hard state
*/
public const STATE_RESOURCES_PROBLEMS = 'resources_problems';

/**
* Resources in downtime
*/
public const STATE_IN_DOWNTIME = 'in_downtime';

/**
* Acknowledged resources
*/
public const STATE_ACKNOWLEDGED = 'acknowledged';

/**
* All status & resources
*/
public const STATE_ALL = 'all';

/**
* List of all states
*/
public const STATES = [
self::STATE_UNHANDLED_PROBLEMS,
self::STATE_RESOURCES_PROBLEMS,
self::STATE_IN_DOWNTIME,
self::STATE_ACKNOWLEDGED,
self::STATE_ALL,
];

public const STATUS_OK = 'OK';
public const STATUS_UP = 'UP';
public const STATUS_WARNING = 'WARNING';
public const STATUS_DOWN = 'DOWN';
public const STATUS_CRITICAL = 'CRITICAL';
public const STATUS_UNREACHABLE = 'UNREACHABLE';
public const STATUS_UNKNOWN = 'UNKNOWN';
public const STATUS_PENDING = 'PENDING';

/**
* List of all types
*/
public const STATUSES = [
self::STATUS_OK,
self::STATUS_UP,
self::STATUS_WARNING,
self::STATUS_DOWN,
self::STATUS_CRITICAL,
self::STATUS_UNREACHABLE,
self::STATUS_UNKNOWN,
self::STATUS_PENDING,
];

/**
* Find all resources.
*
Expand Down
28 changes: 5 additions & 23 deletions src/Centreon/Domain/Monitoring/ResourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
use Centreon\Domain\Monitoring\Exception\ResourceException;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Centreon\Domain\Monitoring\Interfaces\ResourceServiceInterface;
use Centreon\Domain\Monitoring\Interfaces\ResourceRepositoryInterface;
use Core\Security\Application\Repository\ReadAccessGroupRepositoryInterface;
use Centreon\Domain\Monitoring\Interfaces\MonitoringRepositoryInterface;
use Core\Resources\Application\Repository\ReadResourceRepositoryInterface;

/**
* Service manage the resources in real-time monitoring : hosts and services.
Expand All @@ -41,34 +41,16 @@
*/
class ResourceService extends AbstractCentreonService implements ResourceServiceInterface
{
/**
* @var ResourceRepositoryInterface
*/
private $resourceRepository;

/**
* @var MonitoringRepositoryInterface
*/
private $monitoringRepository;

/**
* @var ReadAccessGroupRepositoryInterface
*/
private $accessGroupRepository;

/**
* @param MonitoringRepositoryInterface $monitoringRepository ,
* @param ReadAccessGroupRepositoryInterface $accessGroupRepository
* @param ResourceRepositoryInterface $resourceRepository
* @param ReadResourceRepositoryInterface $resourceRepository
*/
public function __construct(
MonitoringRepositoryInterface $monitoringRepository,
ReadAccessGroupRepositoryInterface $accessGroupRepository,
ResourceRepositoryInterface $resourceRepository
private MonitoringRepositoryInterface $monitoringRepository,
private ReadAccessGroupRepositoryInterface $accessGroupRepository,
private ReadResourceRepositoryInterface $resourceRepository
) {
$this->monitoringRepository = $monitoringRepository;
$this->accessGroupRepository = $accessGroupRepository;
$this->resourceRepository = $resourceRepository;
}

/**
Expand Down
Loading

0 comments on commit fde2603

Please sign in to comment.