move datastore config to pbs_config workspace

This commit is contained in:
Dietmar Maurer
2021-09-10 08:40:58 +02:00
parent ba3d7e19fb
commit e7d4be9d85
24 changed files with 311 additions and 342 deletions

View File

@ -27,7 +27,7 @@ use proxmox::{
use pbs_api_types::PRIVILEGES;
use proxmox_backup::{api2, config};
use proxmox_backup::api2;
fn get_args() -> (String, Vec<String>) {
@ -50,7 +50,7 @@ fn main() -> Result<(), Error> {
for arg in args.iter() {
let text = match arg.as_ref() {
"apidata.js" => generate_api_tree(),
"datastore.cfg" => dump_section_config(&config::datastore::CONFIG),
"datastore.cfg" => dump_section_config(&pbs_config::datastore::CONFIG),
"tape.cfg" => dump_section_config(&pbs_config::drive::CONFIG),
"tape-job.cfg" => dump_section_config(&pbs_config::tape_job::CONFIG),
"user.cfg" => dump_section_config(&pbs_config::user::CONFIG),

View File

@ -89,12 +89,12 @@ fn garbage_collection_commands() -> CommandLineInterface {
.insert("status",
CliCommand::new(&API_METHOD_GARBAGE_COLLECTION_STATUS)
.arg_param(&["store"])
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
)
.insert("start",
CliCommand::new(&API_METHOD_START_GARBAGE_COLLECTION)
.arg_param(&["store"])
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
);
cmd_def.into()
@ -379,7 +379,7 @@ fn main() {
"pull",
CliCommand::new(&API_METHOD_PULL_DATASTORE)
.arg_param(&["remote", "remote-store", "local-store"])
.completion_cb("local-store", config::datastore::complete_datastore_name)
.completion_cb("local-store", pbs_config::datastore::complete_datastore_name)
.completion_cb("remote", pbs_config::remote::complete_remote_name)
.completion_cb("remote-store", complete_remote_datastore_name)
)
@ -387,7 +387,7 @@ fn main() {
"verify",
CliCommand::new(&API_METHOD_VERIFY)
.arg_param(&["store"])
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
)
.insert("report",
CliCommand::new(&API_METHOD_REPORT)

View File

@ -32,7 +32,9 @@ use pbs_buildcfg::configdir;
use pbs_systemd::time::{compute_next_event, parse_calendar_event};
use pbs_tools::logrotate::LogRotate;
use pbs_api_types::{Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig};
use pbs_api_types::{Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig, DataStoreConfig};
use pbs_datastore::prune::PruneOptions;
use proxmox_backup::server;
use proxmox_backup::auth_helpers::*;
use proxmox_backup::tools::{
@ -45,6 +47,7 @@ use proxmox_backup::tools::{
},
};
use proxmox_backup::api2::pull::do_sync_job;
use proxmox_backup::api2::tape::backup::do_tape_backup_job;
use proxmox_backup::server::do_verification_job;
@ -374,14 +377,7 @@ async fn schedule_tasks() -> Result<(), Error> {
async fn schedule_datastore_garbage_collection() {
use proxmox_backup::config::{
datastore::{
self,
DataStoreConfig,
},
};
let config = match datastore::config() {
let config = match pbs_config::datastore::config() {
Err(err) => {
eprintln!("unable to read datastore config - {}", err);
return;
@ -459,15 +455,7 @@ async fn schedule_datastore_garbage_collection() {
async fn schedule_datastore_prune() {
use pbs_datastore::prune::PruneOptions;
use proxmox_backup::{
config::datastore::{
self,
DataStoreConfig,
},
};
let config = match datastore::config() {
let config = match pbs_config::datastore::config() {
Err(err) => {
eprintln!("unable to read datastore config - {}", err);
return;
@ -765,8 +753,6 @@ fn rrd_update_derive(name: &str, value: f64, save: bool) {
async fn generate_host_stats(save: bool) {
use proxmox::sys::linux::procfs::{
read_meminfo, read_proc_stat, read_proc_net_dev, read_loadavg};
use proxmox_backup::config::datastore;
pbs_runtime::block_in_place(move || {
@ -823,9 +809,9 @@ async fn generate_host_stats(save: bool) {
gather_disk_stats(disk_manager.clone(), Path::new("/"), "host", save);
match datastore::config() {
match pbs_config::datastore::config() {
Ok((config, _)) => {
let datastore_list: Vec<datastore::DataStoreConfig> =
let datastore_list: Vec<DataStoreConfig> =
config.convert_to_typed_array("datastore").unwrap_or_default();
for config in datastore_list {

View File

@ -23,6 +23,7 @@ use pbs_tools::format::{
use pbs_config::drive::complete_drive_name;
use pbs_config::media_pool::complete_pool_name;
use pbs_config::datastore::complete_datastore_name;
use proxmox_backup::{
api2::{
@ -38,9 +39,6 @@ use proxmox_backup::{
TAPE_RESTORE_SNAPSHOT_SCHEMA,
},
},
config::{
datastore::complete_datastore_name,
},
tape::{
BlockReadError,
drive::{

View File

@ -3,7 +3,6 @@ use serde_json::Value;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::config;
use proxmox_backup::api2;
#[api(
@ -61,7 +60,7 @@ pub fn acl_commands() -> CommandLineInterface {
CliCommand::new(&api2::access::acl::API_METHOD_UPDATE_ACL)
.arg_param(&["path", "role"])
.completion_cb("auth-id", pbs_config::user::complete_authid)
.completion_cb("path", config::datastore::complete_acl_path)
.completion_cb("path", pbs_config::datastore::complete_acl_path)
);

View File

@ -4,10 +4,9 @@ use serde_json::Value;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use pbs_client::{connect_to_localhost, view_task_result};
use pbs_api_types::{DataStoreConfig, DATASTORE_SCHEMA};
use proxmox_backup::config;
use proxmox_backup::api2::{self, types::* };
use proxmox_backup::config::datastore::DataStoreConfig;
use proxmox_backup::api2;
#[api(
input: {
@ -106,7 +105,7 @@ pub fn datastore_commands() -> CommandLineInterface {
.insert("show",
CliCommand::new(&API_METHOD_SHOW_DATASTORE)
.arg_param(&["name"])
.completion_cb("name", config::datastore::complete_datastore_name)
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
)
.insert("create",
CliCommand::new(&API_METHOD_CREATE_DATASTORE)
@ -115,14 +114,14 @@ pub fn datastore_commands() -> CommandLineInterface {
.insert("update",
CliCommand::new(&api2::config::datastore::API_METHOD_UPDATE_DATASTORE)
.arg_param(&["name"])
.completion_cb("name", config::datastore::complete_datastore_name)
.completion_cb("gc-schedule", config::datastore::complete_calendar_event)
.completion_cb("prune-schedule", config::datastore::complete_calendar_event)
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
.completion_cb("gc-schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("prune-schedule", pbs_config::datastore::complete_calendar_event)
)
.insert("remove",
CliCommand::new(&api2::config::datastore::API_METHOD_DELETE_DATASTORE)
.arg_param(&["name"])
.completion_cb("name", config::datastore::complete_datastore_name)
.completion_cb("name", pbs_config::datastore::complete_datastore_name)
);
cmd_def.into()

View File

@ -3,8 +3,9 @@ use serde_json::Value;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::config;
use proxmox_backup::api2::{self, types::* };
use pbs_api_types::JOB_ID_SCHEMA;
use proxmox_backup::api2;
#[api(
input: {
@ -83,8 +84,8 @@ pub fn sync_job_commands() -> CommandLineInterface {
CliCommand::new(&api2::config::sync::API_METHOD_CREATE_SYNC_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
.completion_cb("remote", pbs_config::remote::complete_remote_name)
.completion_cb("remote-store", crate::complete_remote_datastore_name)
)
@ -92,8 +93,8 @@ pub fn sync_job_commands() -> CommandLineInterface {
CliCommand::new(&api2::config::sync::API_METHOD_UPDATE_SYNC_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::sync::complete_sync_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
.completion_cb("remote-store", crate::complete_remote_datastore_name)
)
.insert("remove",

View File

@ -5,9 +5,9 @@ use std::collections::HashMap;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::config;
use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Userid};
use proxmox_backup::api2;
use proxmox_backup::api2::types::{ACL_PATH_SCHEMA, Authid, Userid};
fn render_expire(value: &Value, _record: &Value) -> Result<String, Error> {
let never = String::from("never");
@ -213,7 +213,7 @@ pub fn user_commands() -> CommandLineInterface {
CliCommand::new(&&API_METHOD_LIST_PERMISSIONS)
.arg_param(&["auth-id"])
.completion_cb("auth-id", pbs_config::user::complete_authid)
.completion_cb("path", config::datastore::complete_acl_path)
.completion_cb("path", pbs_config::datastore::complete_acl_path)
);
cmd_def.into()

View File

@ -3,8 +3,9 @@ use serde_json::Value;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::config;
use proxmox_backup::api2::{self, types::* };
use pbs_api_types::JOB_ID_SCHEMA;
use proxmox_backup::api2;
#[api(
input: {
@ -83,15 +84,15 @@ pub fn verify_job_commands() -> CommandLineInterface {
CliCommand::new(&api2::config::verify::API_METHOD_CREATE_VERIFICATION_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
)
.insert("update",
CliCommand::new(&api2::config::verify::API_METHOD_UPDATE_VERIFICATION_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::verify::complete_verification_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
.completion_cb("remote-store", crate::complete_remote_datastore_name)
)
.insert("remove",

View File

@ -6,10 +6,7 @@ use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use pbs_api_types::JOB_ID_SCHEMA;
use pbs_client::{connect_to_localhost, view_task_result};
use proxmox_backup::{
config,
api2,
};
use proxmox_backup::api2;
#[api(
input: {
@ -121,8 +118,8 @@ pub fn backup_job_commands() -> CommandLineInterface {
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_CREATE_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
.completion_cb("pool", pbs_config::media_pool::complete_pool_name)
.completion_cb("drive", crate::complete_drive_name)
)
@ -130,8 +127,8 @@ pub fn backup_job_commands() -> CommandLineInterface {
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_UPDATE_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id)
.completion_cb("schedule", config::datastore::complete_calendar_event)
.completion_cb("store", config::datastore::complete_datastore_name)
.completion_cb("schedule", pbs_config::datastore::complete_calendar_event)
.completion_cb("store", pbs_config::datastore::complete_datastore_name)
.completion_cb("pool", pbs_config::media_pool::complete_pool_name)
.completion_cb("drive", crate::complete_drive_name)
)