move drive config to pbs_config workspace
Also moved the tape type definitions to pbs_api_types.
This commit is contained in:
@ -123,7 +123,7 @@ pub fn list_tape_backup_jobs(
|
||||
|
||||
let (job_config, digest) = config::tape_job::config()?;
|
||||
let (pool_config, _pool_digest) = config::media_pool::config()?;
|
||||
let (drive_config, _digest) = config::drive::config()?;
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
let job_list_iter = job_config
|
||||
.convert_to_typed_array("backup")?
|
||||
@ -194,7 +194,7 @@ pub fn do_tape_backup_job(
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?;
|
||||
|
||||
let (drive_config, _digest) = config::drive::config()?;
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
// for scheduled jobs we acquire the lock later in the worker
|
||||
let drive_lock = if schedule.is_some() {
|
||||
@ -373,7 +373,7 @@ pub fn backup(
|
||||
let (config, _digest) = config::media_pool::config()?;
|
||||
let pool_config: MediaPoolConfig = config.lookup("pool", &setup.pool)?;
|
||||
|
||||
let (drive_config, _digest) = config::drive::config()?;
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
// early check/lock before starting worker
|
||||
let drive_lock = lock_tape_device(&drive_config, &setup.drive)?;
|
||||
@ -578,7 +578,7 @@ fn backup_worker(
|
||||
// Try to update the the media online status
|
||||
fn update_media_online_status(drive: &str) -> Result<Option<String>, Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
if let Ok(Some((mut changer, changer_name))) = media_changer(&config, drive) {
|
||||
|
||||
|
@ -9,7 +9,6 @@ use proxmox::list_subdirs_api_method;
|
||||
|
||||
use crate::{
|
||||
config::{
|
||||
self,
|
||||
cached_user_info::CachedUserInfo,
|
||||
acl::{
|
||||
PRIV_TAPE_AUDIT,
|
||||
@ -71,7 +70,7 @@ pub async fn get_status(
|
||||
cache: bool,
|
||||
) -> Result<Vec<MtxStatusEntry>, Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
let mut changer_config: ScsiTapeChanger = config.lookup("changer", &name)?;
|
||||
|
||||
@ -171,7 +170,7 @@ pub async fn transfer(
|
||||
to: u64,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
let mut changer_config: ScsiTapeChanger = config.lookup("changer", &name)?;
|
||||
|
||||
@ -205,7 +204,7 @@ pub fn list_changers(
|
||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
let linux_changers = linux_tape_changer_list();
|
||||
|
||||
|
@ -75,6 +75,7 @@ use crate::{
|
||||
TapeDriver,
|
||||
LtoTapeHandle,
|
||||
open_lto_tape_device,
|
||||
open_lto_tape_drive,
|
||||
media_changer,
|
||||
required_media_changer,
|
||||
open_drive,
|
||||
@ -101,7 +102,7 @@ where
|
||||
+ FnOnce(Arc<WorkerTask>, SectionConfigData) -> Result<(), Error>,
|
||||
{
|
||||
// early check/lock before starting worker
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
let lock_guard = lock_tape_device(&config, &drive)?;
|
||||
|
||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
@ -125,7 +126,7 @@ where
|
||||
R: Send + 'static,
|
||||
{
|
||||
// early check/lock before starting worker
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
let lock_guard = lock_tape_device(&config, &drive)?;
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let _lock_guard = lock_guard;
|
||||
@ -1140,7 +1141,7 @@ pub async fn cartridge_memory(drive: String) -> Result<Vec<MamAttribute>, Error>
|
||||
"reading cartridge memory".to_string(),
|
||||
move |config| {
|
||||
let drive_config: LtoTapeDrive = config.lookup("lto", &drive)?;
|
||||
let mut handle = drive_config.open()?;
|
||||
let mut handle = open_lto_tape_drive(&drive_config)?;
|
||||
|
||||
handle.cartridge_memory()
|
||||
}
|
||||
@ -1170,7 +1171,7 @@ pub async fn volume_statistics(drive: String) -> Result<Lp17VolumeStatistics, Er
|
||||
"reading volume statistics".to_string(),
|
||||
move |config| {
|
||||
let drive_config: LtoTapeDrive = config.lookup("lto", &drive)?;
|
||||
let mut handle = drive_config.open()?;
|
||||
let mut handle = open_lto_tape_drive(&drive_config)?;
|
||||
|
||||
handle.volume_statistics()
|
||||
}
|
||||
@ -1376,7 +1377,7 @@ pub fn list_drives(
|
||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let (config, _) = config::drive::config()?;
|
||||
let (config, _) = pbs_config::drive::config()?;
|
||||
|
||||
let lto_drives = lto_tape_device_list();
|
||||
|
||||
|
@ -2,7 +2,6 @@ use std::path::Path;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use proxmox::{
|
||||
api::{api, Router, SubdirMap, RpcEnvironment, Permission},
|
||||
@ -11,6 +10,11 @@ use proxmox::{
|
||||
};
|
||||
|
||||
use pbs_datastore::backup_info::BackupDir;
|
||||
use pbs_api_types::{
|
||||
MEDIA_POOL_NAME_SCHEMA, MEDIA_LABEL_SCHEMA, MEDIA_UUID_SCHEMA, CHANGER_NAME_SCHEMA,
|
||||
VAULT_NAME_SCHEMA, Authid, MediaPoolConfig, MediaListEntry, MediaSetListEntry,
|
||||
MediaStatus, MediaContentEntry, MediaContentListFilter,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
config::{
|
||||
@ -20,23 +24,7 @@ use crate::{
|
||||
PRIV_TAPE_AUDIT,
|
||||
},
|
||||
},
|
||||
api2::types::{
|
||||
Authid,
|
||||
BACKUP_ID_SCHEMA,
|
||||
BACKUP_TYPE_SCHEMA,
|
||||
MEDIA_POOL_NAME_SCHEMA,
|
||||
MEDIA_LABEL_SCHEMA,
|
||||
MEDIA_UUID_SCHEMA,
|
||||
MEDIA_SET_UUID_SCHEMA,
|
||||
CHANGER_NAME_SCHEMA,
|
||||
MediaPoolConfig,
|
||||
MediaListEntry,
|
||||
MediaSetListEntry,
|
||||
MediaStatus,
|
||||
MediaContentEntry,
|
||||
VAULT_NAME_SCHEMA,
|
||||
},
|
||||
tape::{
|
||||
tape::{
|
||||
TAPE_STATUS_DIR,
|
||||
Inventory,
|
||||
MediaPool,
|
||||
@ -393,46 +381,6 @@ pub fn destroy_media(label_text: String, force: Option<bool>,) -> Result<(), Err
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
pool: {
|
||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"label-text": {
|
||||
schema: MEDIA_LABEL_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"media": {
|
||||
schema: MEDIA_UUID_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"media-set": {
|
||||
schema: MEDIA_SET_UUID_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"backup-type": {
|
||||
schema: BACKUP_TYPE_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
"backup-id": {
|
||||
schema: BACKUP_ID_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
)]
|
||||
#[derive(Serialize,Deserialize)]
|
||||
#[serde(rename_all="kebab-case")]
|
||||
/// Content list filter parameters
|
||||
pub struct MediaContentListFilter {
|
||||
pub pool: Option<String>,
|
||||
pub label_text: Option<String>,
|
||||
pub media: Option<Uuid>,
|
||||
pub media_set: Option<Uuid>,
|
||||
pub backup_type: Option<String>,
|
||||
pub backup_id: Option<String>,
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
|
@ -49,7 +49,6 @@ use crate::{
|
||||
TAPE_RESTORE_SNAPSHOT_SCHEMA,
|
||||
},
|
||||
config::{
|
||||
self,
|
||||
cached_user_info::CachedUserInfo,
|
||||
acl::{
|
||||
PRIV_DATASTORE_BACKUP,
|
||||
@ -271,7 +270,7 @@ pub fn restore(
|
||||
bail!("no permissions on /tape/pool/{}", pool);
|
||||
}
|
||||
|
||||
let (drive_config, _digest) = config::drive::config()?;
|
||||
let (drive_config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
// early check/lock before starting worker
|
||||
let drive_lock = lock_tape_device(&drive_config, &drive)?;
|
||||
|
Reference in New Issue
Block a user