[pbs-devel] [PATCH v3 proxmox-backup 08/10] add check_repositories_call
Fabian Ebner
f.ebner at proxmox.com
Mon Mar 22 12:59:43 CET 2021
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
No changes from v2.
src/api2/node/apt.rs | 53 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs
index 4dad2e73..22e43340 100644
--- a/src/api2/node/apt.rs
+++ b/src/api2/node/apt.rs
@@ -6,7 +6,7 @@ use proxmox::list_subdirs_api_method;
use proxmox::api::{api, RpcEnvironment, RpcEnvironmentType, Permission};
use proxmox::api::router::{Router, SubdirMap};
-use proxmox_apt::types::APTRepository;
+use proxmox_apt::types::{APTRepository, APTRepositoryWarning};
use crate::server::WorkerTask;
use crate::tools::{apt, http, subscription};
@@ -352,6 +352,56 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
Ok(packages)
}
+#[api(
+ input: {
+ properties: {
+ node: {
+ schema: NODE_SCHEMA,
+ },
+ },
+ },
+ returns: {
+ description: "Warnings for APT repositories and status of Proxmox repositories.",
+ properties: {
+ warnings: {
+ description: "Warnings for APT repositories.",
+ type: Array,
+ items: {
+ type: APTRepositoryWarning,
+ },
+ },
+ enterprise: {
+ description: "Whether the enterprise repository is enabled.",
+ type: Boolean,
+ },
+ nosubscription: {
+ description: "Whether the no-subscription repository is enabled.",
+ type: Boolean,
+ },
+ },
+ },
+ access: {
+ permission: &Permission::Privilege(&[], PRIV_SYS_AUDIT, false),
+ },
+)]
+/// Check APT repository configuration.
+pub fn check_repositories() -> Result<Value, Error> {
+ let repos = proxmox_apt::repositories::repositories()?;
+
+ let warnings = proxmox_apt::repositories::check_repositories(&repos);
+
+ let enterprise_enabled =
+ proxmox_apt::repositories::enterprise_repository_enabled(&repos, "pbs");
+ let no_subscription_enabled =
+ proxmox_apt::repositories::no_subscription_repository_enabled(&repos, "pbs");
+
+ Ok(json!({
+ "warnings": warnings,
+ "enterprise": enterprise_enabled,
+ "nosubscription": no_subscription_enabled
+ }))
+}
+
#[api(
input: {
properties: {
@@ -378,6 +428,7 @@ pub fn get_repositories() -> Result<Vec<APTRepository>, Error> {
const SUBDIRS: SubdirMap = &[
("changelog", &Router::new().get(&API_METHOD_APT_GET_CHANGELOG)),
+ ("checkrepositories", &Router::new().get(&API_METHOD_CHECK_REPOSITORIES)),
("repositories", &Router::new().get(&API_METHOD_GET_REPOSITORIES)),
("update", &Router::new()
.get(&API_METHOD_APT_UPDATE_AVAILABLE)
--
2.20.1
More information about the pbs-devel
mailing list