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

feat(api): implement endpoint to update centreon web #11391

Merged
merged 15 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"symfony/framework-bundle": "5.4.*",
"symfony/http-client": "5.4.*",
"symfony/http-kernel": "5.4.*",
"symfony/lock": "5.4.*",
"symfony/maker-bundle": "^1.11",
"symfony/monolog-bundle": "^3.7",
"symfony/options-resolver": "5.4.*",
Expand Down
83 changes: 81 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions config/packages/Centreon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,42 @@ services:
class: Core\Infrastructure\Platform\Repository\FileReadPlatformRepository
arguments: ['%centreon_etc_path%', '%centreon_install_path%']

Core\Platform\Application\Validator\RequirementValidatorsInterface:
class: Core\Platform\Infrastructure\Validator\RequirementValidators
arguments:
$requirementValidators: !tagged_iterator 'platform.requirement.validators'

Core\Platform\Infrastructure\Validator\RequirementValidators\DatabaseRequirementValidator:
arguments:
$dbRequirementValidators: !tagged_iterator 'platform.requirement.database.validators'

Core\Platform\Infrastructure\Validator\RequirementValidators\PhpRequirementValidator:
arguments:
$requiredPhpVersion: '%required_php_version%'

Core\Platform\Infrastructure\Validator\RequirementValidators\DatabaseRequirementValidators\MariaDbRequirementValidator:
arguments:
$requiredMariaDbMinVersion: '%required_mariadb_min_version%'

Core\Platform\Application\Repository\ReadVersionRepositoryInterface:
class: Core\Platform\Infrastructure\Repository\DbReadVersionRepository
public: true

Core\Platform\Application\Repository\ReadUpdateRepositoryInterface:
class: Core\Platform\Infrastructure\Repository\FsReadUpdateRepository
arguments:
$installDir: '%centreon_install_path%'
public: true

Core\Platform\Application\Repository\UpdateLockerRepositoryInterface:
class: Core\Platform\Infrastructure\Repository\SymfonyUpdateLockerRepository
public: true

Core\Platform\Application\Repository\WriteUpdateRepositoryInterface:
class: Core\Platform\Infrastructure\Repository\DbWriteUpdateRepository
arguments: ['%centreon_var_lib%', '%centreon_install_path%']
public: true

# Monitoring resources
_instanceof:
Centreon\Infrastructure\Monitoring\Resource\Provider\ProviderInterface:
Expand All @@ -235,6 +271,10 @@ services:
tags: ['authentication.provider.responses']
Core\Security\Infrastructure\Api\FindProviderConfigurations\ProviderPresenter\ProviderPresenterInterface:
tags: ['authentication.provider.presenters']
Core\Platform\Application\Validator\RequirementValidatorInterface:
tags: ['platform.requirement.validators']
Core\Platform\Infrastructure\Validator\RequirementValidators\DatabaseRequirementValidatorInterface:
tags: ['platform.requirement.database.validators']

Centreon\Domain\Monitoring\Interfaces\ResourceRepositoryInterface:
factory: ['@Centreon\Infrastructure\Monitoring\Resource\ResourceRepositoryFactory', 'createResourceRepository']
Expand Down
6 changes: 6 additions & 0 deletions config/routes/Centreon/platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ centreon_application_platform_getversion:
controller: 'Centreon\Application\Controller\PlatformController::getVersions'
condition: "request.attributes.get('version') >= 21.10"

centreon_application_platform_updateversions:
methods: PATCH
path: /platform/updates
controller: 'Core\Platform\Infrastructure\Api\UpdateVersions\UpdateVersionsController'
condition: "request.attributes.get('version') >= 22.04"

centreon_application_platformtopology_addplatformtotopology:
methods: POST
path: /platform/topology
Expand Down
5 changes: 5 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ parameters:
media_path: "img/media"
redirect_default_page: "/monitoring/resources"
session_expiration_delay: 120
required_php_version: "%env(_CENTREON_PHP_VERSION_)%"
required_mariadb_min_version: "%env(_CENTREON_MARIA_DB_MIN_VERSION_)%"

services:
# Default configuration for services in *this* file
Expand Down Expand Up @@ -66,6 +68,9 @@ services:
decorates: router
arguments: ['@.inner']

Symfony\Component\Finder\Finder:
shared: false


# Security
Security\Domain\Authentication\Interfaces\AuthenticationRepositoryInterface:
Expand Down
2 changes: 2 additions & 0 deletions doc/API/centreon-api-v22.10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3582,6 +3582,8 @@ paths:
moduleName:
type: object
$ref: '#/components/schemas/Platform.Versions'
/platform/updates:
$ref: "./v22.10/Administration/updates.yaml"
/platform/installation/status:
get:
tags:
Expand Down
30 changes: 30 additions & 0 deletions doc/API/v22.10/Administration/updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
patch:
tags:
- Platform
summary: "Update Centreon web"
description: |
Update Centreon web component
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
components:
type: array
items:
type: object
properties:
name:
type: string
enum: [ centreon-web ]
responses:
204:
description: "Platform updated"
404:
description: "Updates not found"
500:
$ref: "../../centreon-api-v22.10.yaml#/components/responses/InternalServerError"
...
42 changes: 42 additions & 0 deletions lang/fr_FR.UTF-8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -16916,3 +16916,45 @@ msgstr "Une erreur s'est produite lors de la récupération des catégories d'h

msgid "Warning, maximum size exceeded for input '%s' (max: %d), it will be truncated upon saving"
msgstr "Attention, taille maximale dépassée pour le champ '%s' (max: %d), il sera tronqué à l'enregistrement"

msgid "Update already in progress"
msgstr "Une mise à jour est déjà en cours"

msgid "An error occurred when retrieving current version"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Une erreur s'est produite lors de la récupération de la version actuelle"

msgid "Cannot retrieve current version"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "La version actuelle n'a pas pu être trouvée"
kduret marked this conversation as resolved.
Show resolved Hide resolved

msgid "An error occurred when getting available updates"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Une erreur s'est produite lors de la récupération des mises à jour disponibles"

msgid "An error occurred when applying update %s (%s)"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Une erreur s'est produite lors de l'application de la mise à jour %s (%s)"

msgid "Error while locking update process"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Erreur lors du verrouillage du processus de mise à jour"

msgid "Error while unlocking update process"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Erreur lors du déverrouillage du processus de mise à jour"

msgid "An error occurred when applying post update actions"
msgstr "Une erreur s'est produite lors de l'application des actions postérieures à la mise à jour"

msgid "Updates not found"
msgstr "Les mises à jour n'ont pas été trouvées"

msgid "PHP version %s required (%s installed)"
msgstr "La version %s de PHP est requise (%s installée)"

msgid "PHP extension %s not loaded"
msgstr "L'extension %s de PHP n'est pas chargée"

msgid "Error when getting database version"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Erreur lors de la récupération de la version de la base de données"

msgid "Cannot retrieve database version information"
kduret marked this conversation as resolved.
Show resolved Hide resolved
msgstr "Les informations de version de la base de données n'ont pas pu être trouvées"
kduret marked this conversation as resolved.
Show resolved Hide resolved

msgid "MariaDB version %s required (%s installed)"
msgstr "La version %s de MariaDB est requise (%s installée)"
10 changes: 10 additions & 0 deletions src/Centreon/Infrastructure/DatabaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@ public function setStorageDbName(string $storageDbName)
{
$this->storageDbName = $storageDbName;
}

/**
* switch connection to another database
*
* @param string $dbName
*/
public function switchToDb(string $dbName): void
{
$this->query('use ' . $dbName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class AbstractRepositoryDRB
protected function translateDbName(string $request): string
{
return str_replace(
array(':dbstg', ':db'),
array($this->db->getStorageDbName(), $this->db->getCentreonDbName()),
[':dbstg', ':db'],
[$this->db->getStorageDbName(), $this->db->getCentreonDbName()],
$request
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : contact@centreon.com
*
*/
declare(strict_types=1);

namespace Core\Platform\Application\Repository;

interface ReadUpdateRepositoryInterface
{
/**
* Get ordered available updates
*
* @param string $currentVersion
* @return string[]
*/
public function findOrderedAvailableUpdates(string $currentVersion): array;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : contact@centreon.com
*
*/
declare(strict_types=1);

namespace Core\Platform\Application\Repository;

interface ReadVersionRepositoryInterface
{
/**
* Get current version
*
* @return string|null
*/
public function findCurrentVersion(): ?string;
}
Loading