move media_pool config to pbs_config workspace
This commit is contained in:
parent
68149b9045
commit
aad2d162ab
|
@ -1,5 +1,6 @@
|
|||
pub mod domains;
|
||||
pub mod drive;
|
||||
pub mod media_pool;
|
||||
pub mod remote;
|
||||
|
||||
use anyhow::{format_err, Error};
|
||||
|
|
|
@ -22,14 +22,9 @@ use proxmox::{
|
|||
},
|
||||
};
|
||||
|
||||
use pbs_config::{open_backup_lockfile, BackupLockGuard};
|
||||
use pbs_api_types::{MEDIA_POOL_NAME_SCHEMA, MediaPoolConfig};
|
||||
|
||||
use crate::{
|
||||
api2::types::{
|
||||
MEDIA_POOL_NAME_SCHEMA,
|
||||
MediaPoolConfig,
|
||||
},
|
||||
};
|
||||
use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
|
||||
|
||||
lazy_static! {
|
||||
/// Static [`SectionConfig`] to access parser/writer functions.
|
||||
|
@ -73,7 +68,7 @@ pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
|||
/// Save the configuration file
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(MEDIA_POOL_CFG_FILENAME, &config)?;
|
||||
pbs_config::replace_backup_config(MEDIA_POOL_CFG_FILENAME, raw.as_bytes())
|
||||
replace_backup_config(MEDIA_POOL_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
// shell completion helper
|
|
@ -10,15 +10,15 @@ use proxmox::{
|
|||
},
|
||||
};
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid,
|
||||
MEDIA_POOL_NAME_SCHEMA,
|
||||
MediaPoolConfig,
|
||||
MediaPoolConfigUpdater,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
api2::types::{
|
||||
Authid,
|
||||
MEDIA_POOL_NAME_SCHEMA,
|
||||
MediaPoolConfig,
|
||||
MediaPoolConfigUpdater,
|
||||
},
|
||||
config::{
|
||||
self,
|
||||
cached_user_info::CachedUserInfo,
|
||||
acl::{
|
||||
PRIV_TAPE_AUDIT,
|
||||
|
@ -46,9 +46,9 @@ pub fn create_pool(
|
|||
config: MediaPoolConfig,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let _lock = config::media_pool::lock()?;
|
||||
let _lock = pbs_config::media_pool::lock()?;
|
||||
|
||||
let (mut section_config, _digest) = config::media_pool::config()?;
|
||||
let (mut section_config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
if section_config.sections.get(&config.name).is_some() {
|
||||
bail!("Media pool '{}' already exists", config.name);
|
||||
|
@ -56,7 +56,7 @@ pub fn create_pool(
|
|||
|
||||
section_config.set_data(&config.name, "pool", &config)?;
|
||||
|
||||
config::media_pool::save_config(§ion_config)?;
|
||||
pbs_config::media_pool::save_config(§ion_config)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ pub fn list_pools(
|
|||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, digest) = config::media_pool::config()?;
|
||||
let (config, digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let list = config.convert_to_typed_array::<MediaPoolConfig>("pool")?;
|
||||
|
||||
|
@ -116,7 +116,7 @@ pub fn list_pools(
|
|||
/// Get media pool configuration
|
||||
pub fn get_config(name: String) -> Result<MediaPoolConfig, Error> {
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let data: MediaPoolConfig = config.lookup("pool", &name)?;
|
||||
|
||||
|
@ -172,9 +172,9 @@ pub fn update_pool(
|
|||
delete: Option<Vec<DeletableProperty>>,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let _lock = config::media_pool::lock()?;
|
||||
let _lock = pbs_config::media_pool::lock()?;
|
||||
|
||||
let (mut config, _digest) = config::media_pool::config()?;
|
||||
let (mut config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let mut data: MediaPoolConfig = config.lookup("pool", &name)?;
|
||||
|
||||
|
@ -206,7 +206,7 @@ pub fn update_pool(
|
|||
|
||||
config.set_data(&name, "pool", &data)?;
|
||||
|
||||
config::media_pool::save_config(&config)?;
|
||||
pbs_config::media_pool::save_config(&config)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -227,16 +227,16 @@ pub fn update_pool(
|
|||
/// Delete a media pool configuration
|
||||
pub fn delete_pool(name: String) -> Result<(), Error> {
|
||||
|
||||
let _lock = config::media_pool::lock()?;
|
||||
let _lock = pbs_config::media_pool::lock()?;
|
||||
|
||||
let (mut config, _digest) = config::media_pool::config()?;
|
||||
let (mut config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
match config.sections.get(&name) {
|
||||
Some(_) => { config.sections.remove(&name); },
|
||||
None => bail!("delete pool '{}' failed - no such pool", name),
|
||||
}
|
||||
|
||||
config::media_pool::save_config(&config)?;
|
||||
pbs_config::media_pool::save_config(&config)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn list_tape_backup_jobs(
|
|||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (job_config, digest) = config::tape_job::config()?;
|
||||
let (pool_config, _pool_digest) = config::media_pool::config()?;
|
||||
let (pool_config, _pool_digest) = pbs_config::media_pool::config()?;
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
let job_list_iter = job_config
|
||||
|
@ -191,7 +191,7 @@ pub fn do_tape_backup_job(
|
|||
|
||||
let datastore = DataStore::lookup_datastore(&setup.store)?;
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?;
|
||||
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
@ -370,7 +370,7 @@ pub fn backup(
|
|||
|
||||
let datastore = DataStore::lookup_datastore(&setup.store)?;
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?;
|
||||
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
|
|
@ -514,7 +514,7 @@ pub fn label_media(
|
|||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
if let Some(ref pool) = pool {
|
||||
let (pool_config, _digest) = config::media_pool::config()?;
|
||||
let (pool_config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
if pool_config.sections.get(pool).is_none() {
|
||||
bail!("no such pool ('{}')", pool);
|
||||
|
@ -1029,7 +1029,7 @@ pub fn barcode_label_media(
|
|||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
if let Some(ref pool) = pool {
|
||||
let (pool_config, _digest) = config::media_pool::config()?;
|
||||
let (pool_config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
if pool_config.sections.get(pool).is_none() {
|
||||
bail!("no such pool ('{}')", pool);
|
||||
|
|
|
@ -18,13 +18,12 @@ use pbs_api_types::{
|
|||
|
||||
use crate::{
|
||||
config::{
|
||||
self,
|
||||
cached_user_info::CachedUserInfo,
|
||||
acl::{
|
||||
PRIV_TAPE_AUDIT,
|
||||
},
|
||||
},
|
||||
tape::{
|
||||
tape::{
|
||||
TAPE_STATUS_DIR,
|
||||
Inventory,
|
||||
MediaPool,
|
||||
|
@ -54,7 +53,7 @@ pub async fn list_media_sets(
|
|||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let status_path = Path::new(TAPE_STATUS_DIR);
|
||||
|
||||
|
@ -143,7 +142,7 @@ pub async fn list_media(
|
|||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let status_path = Path::new(TAPE_STATUS_DIR);
|
||||
|
||||
|
@ -410,7 +409,7 @@ pub fn list_content(
|
|||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let (config, _digest) = pbs_config::media_pool::config()?;
|
||||
|
||||
let status_path = Path::new(TAPE_STATUS_DIR);
|
||||
let inventory = Inventory::load(status_path)?;
|
||||
|
|
|
@ -61,7 +61,7 @@ fn main() -> Result<(), Error> {
|
|||
"remote.cfg" => dump_section_config(&pbs_config::remote::CONFIG),
|
||||
"sync.cfg" => dump_section_config(&config::sync::CONFIG),
|
||||
"verification.cfg" => dump_section_config(&config::verify::CONFIG),
|
||||
"media-pool.cfg" => dump_section_config(&config::media_pool::CONFIG),
|
||||
"media-pool.cfg" => dump_section_config(&pbs_config::media_pool::CONFIG),
|
||||
"config::acl::Role" => dump_enum_properties(&config::acl::Role::API_SCHEMA)?,
|
||||
_ => bail!("docgen: got unknown type"),
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@ use pbs_tools::format::{
|
|||
};
|
||||
|
||||
use pbs_config::drive::complete_drive_name;
|
||||
use pbs_config::media_pool::complete_pool_name;
|
||||
|
||||
use proxmox_backup::{
|
||||
api2::{
|
||||
|
@ -39,7 +40,6 @@ use proxmox_backup::{
|
|||
},
|
||||
config::{
|
||||
datastore::complete_datastore_name,
|
||||
media_pool::complete_pool_name,
|
||||
},
|
||||
tape::{
|
||||
BlockReadError,
|
||||
|
|
|
@ -125,7 +125,7 @@ pub fn backup_job_commands() -> CommandLineInterface {
|
|||
.completion_cb("id", 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("pool", config::media_pool::complete_pool_name)
|
||||
.completion_cb("pool", pbs_config::media_pool::complete_pool_name)
|
||||
.completion_cb("drive", crate::complete_drive_name)
|
||||
)
|
||||
.insert("update",
|
||||
|
@ -134,7 +134,7 @@ pub fn backup_job_commands() -> CommandLineInterface {
|
|||
.completion_cb("id", 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("pool", config::media_pool::complete_pool_name)
|
||||
.completion_cb("pool", pbs_config::media_pool::complete_pool_name)
|
||||
.completion_cb("drive", crate::complete_drive_name)
|
||||
)
|
||||
.insert("remove",
|
||||
|
|
|
@ -15,6 +15,7 @@ use pbs_api_types::{
|
|||
MediaContentListFilter,
|
||||
};
|
||||
use pbs_config::drive::complete_changer_name;
|
||||
use pbs_config::media_pool::complete_pool_name;
|
||||
|
||||
use proxmox_backup::{
|
||||
api2,
|
||||
|
@ -23,9 +24,6 @@ use proxmox_backup::{
|
|||
complete_media_uuid,
|
||||
complete_media_set_uuid,
|
||||
},
|
||||
config::{
|
||||
media_pool::complete_pool_name,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn media_commands() -> CommandLineInterface {
|
||||
|
|
|
@ -10,6 +10,8 @@ use proxmox::{
|
|||
},
|
||||
};
|
||||
|
||||
use pbs_config::media_pool::complete_pool_name;
|
||||
|
||||
use proxmox_backup::{
|
||||
api2::{
|
||||
self,
|
||||
|
@ -18,9 +20,6 @@ use proxmox_backup::{
|
|||
},
|
||||
},
|
||||
config::{
|
||||
media_pool::{
|
||||
complete_pool_name,
|
||||
},
|
||||
tape_encryption_keys:: {
|
||||
complete_key_fingerprint,
|
||||
},
|
||||
|
|
|
@ -25,7 +25,6 @@ pub mod tfa;
|
|||
pub mod token_shadow;
|
||||
pub mod user;
|
||||
pub mod verify;
|
||||
pub mod media_pool;
|
||||
pub mod tape_encryption_keys;
|
||||
pub mod tape_job;
|
||||
|
||||
|
|
Loading…
Reference in New Issue