tape: remove drive from pool config
This commit is contained in:
parent
83b8949a98
commit
9883b54cba
@ -11,7 +11,6 @@ use proxmox::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api2::types::{
|
api2::types::{
|
||||||
DRIVE_NAME_SCHEMA,
|
|
||||||
MEDIA_POOL_NAME_SCHEMA,
|
MEDIA_POOL_NAME_SCHEMA,
|
||||||
MEDIA_SET_NAMING_TEMPLATE_SCHEMA,
|
MEDIA_SET_NAMING_TEMPLATE_SCHEMA,
|
||||||
MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
||||||
@ -19,12 +18,7 @@ use crate::{
|
|||||||
TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
||||||
MediaPoolConfig,
|
MediaPoolConfig,
|
||||||
},
|
},
|
||||||
config::{
|
config,
|
||||||
self,
|
|
||||||
drive::{
|
|
||||||
check_drive_exists,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
@ -34,9 +28,6 @@ use crate::{
|
|||||||
name: {
|
name: {
|
||||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
drive: {
|
|
||||||
schema: DRIVE_NAME_SCHEMA,
|
|
||||||
},
|
|
||||||
allocation: {
|
allocation: {
|
||||||
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -59,7 +50,6 @@ use crate::{
|
|||||||
/// Create a new media pool
|
/// Create a new media pool
|
||||||
pub fn create_pool(
|
pub fn create_pool(
|
||||||
name: String,
|
name: String,
|
||||||
drive: String,
|
|
||||||
allocation: Option<String>,
|
allocation: Option<String>,
|
||||||
retention: Option<String>,
|
retention: Option<String>,
|
||||||
template: Option<String>,
|
template: Option<String>,
|
||||||
@ -74,12 +64,8 @@ pub fn create_pool(
|
|||||||
bail!("Media pool '{}' already exists", name);
|
bail!("Media pool '{}' already exists", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (drive_config, _) = config::drive::config()?;
|
|
||||||
check_drive_exists(&drive_config, &drive)?;
|
|
||||||
|
|
||||||
let item = MediaPoolConfig {
|
let item = MediaPoolConfig {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
drive,
|
|
||||||
allocation,
|
allocation,
|
||||||
retention,
|
retention,
|
||||||
template,
|
template,
|
||||||
@ -160,10 +146,6 @@ pub enum DeletableProperty {
|
|||||||
name: {
|
name: {
|
||||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
drive: {
|
|
||||||
schema: DRIVE_NAME_SCHEMA,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
allocation: {
|
allocation: {
|
||||||
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -194,7 +176,6 @@ pub enum DeletableProperty {
|
|||||||
/// Update media pool settings
|
/// Update media pool settings
|
||||||
pub fn update_pool(
|
pub fn update_pool(
|
||||||
name: String,
|
name: String,
|
||||||
drive: Option<String>,
|
|
||||||
allocation: Option<String>,
|
allocation: Option<String>,
|
||||||
retention: Option<String>,
|
retention: Option<String>,
|
||||||
template: Option<String>,
|
template: Option<String>,
|
||||||
@ -219,7 +200,6 @@ pub fn update_pool(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(drive) = drive { data.drive = drive; }
|
|
||||||
if allocation.is_some() { data.allocation = allocation; }
|
if allocation.is_some() { data.allocation = allocation; }
|
||||||
if retention.is_some() { data.retention = retention; }
|
if retention.is_some() { data.retention = retention; }
|
||||||
if template.is_some() { data.template = template; }
|
if template.is_some() { data.template = template; }
|
||||||
|
@ -28,6 +28,7 @@ use crate::{
|
|||||||
Authid,
|
Authid,
|
||||||
DATASTORE_SCHEMA,
|
DATASTORE_SCHEMA,
|
||||||
MEDIA_POOL_NAME_SCHEMA,
|
MEDIA_POOL_NAME_SCHEMA,
|
||||||
|
DRIVE_NAME_SCHEMA,
|
||||||
UPID_SCHEMA,
|
UPID_SCHEMA,
|
||||||
MediaPoolConfig,
|
MediaPoolConfig,
|
||||||
},
|
},
|
||||||
@ -53,6 +54,9 @@ use crate::{
|
|||||||
pool: {
|
pool: {
|
||||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
|
drive: {
|
||||||
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
|
},
|
||||||
"eject-media": {
|
"eject-media": {
|
||||||
description: "Eject media upon job completion.",
|
description: "Eject media upon job completion.",
|
||||||
type: bool,
|
type: bool,
|
||||||
@ -73,6 +77,7 @@ use crate::{
|
|||||||
pub fn backup(
|
pub fn backup(
|
||||||
store: String,
|
store: String,
|
||||||
pool: String,
|
pool: String,
|
||||||
|
drive: String,
|
||||||
eject_media: Option<bool>,
|
eject_media: Option<bool>,
|
||||||
export_media_set: Option<bool>,
|
export_media_set: Option<bool>,
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
@ -87,7 +92,7 @@ pub fn backup(
|
|||||||
|
|
||||||
let (drive_config, _digest) = config::drive::config()?;
|
let (drive_config, _digest) = config::drive::config()?;
|
||||||
// early check before starting worker
|
// early check before starting worker
|
||||||
check_drive_exists(&drive_config, &pool_config.drive)?;
|
check_drive_exists(&drive_config, &drive)?;
|
||||||
|
|
||||||
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
||||||
|
|
||||||
@ -100,7 +105,7 @@ pub fn backup(
|
|||||||
auth_id,
|
auth_id,
|
||||||
to_stdout,
|
to_stdout,
|
||||||
move |worker| {
|
move |worker| {
|
||||||
backup_worker(&worker, datastore, &pool_config, eject_media, export_media_set)?;
|
backup_worker(&worker, datastore, &drive, &pool_config, eject_media, export_media_set)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
)?;
|
)?;
|
||||||
@ -115,6 +120,7 @@ pub const ROUTER: Router = Router::new()
|
|||||||
fn backup_worker(
|
fn backup_worker(
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
datastore: Arc<DataStore>,
|
datastore: Arc<DataStore>,
|
||||||
|
drive: &str,
|
||||||
pool_config: &MediaPoolConfig,
|
pool_config: &MediaPoolConfig,
|
||||||
eject_media: bool,
|
eject_media: bool,
|
||||||
export_media_set: bool,
|
export_media_set: bool,
|
||||||
@ -125,13 +131,13 @@ fn backup_worker(
|
|||||||
let _lock = MediaPool::lock(status_path, &pool_config.name)?;
|
let _lock = MediaPool::lock(status_path, &pool_config.name)?;
|
||||||
|
|
||||||
task_log!(worker, "update media online status");
|
task_log!(worker, "update media online status");
|
||||||
let has_changer = update_media_online_status(&pool_config.drive)?;
|
let has_changer = update_media_online_status(drive)?;
|
||||||
|
|
||||||
let use_offline_media = !has_changer;
|
let use_offline_media = !has_changer;
|
||||||
|
|
||||||
let pool = MediaPool::with_config(status_path, &pool_config, use_offline_media)?;
|
let pool = MediaPool::with_config(status_path, &pool_config, use_offline_media)?;
|
||||||
|
|
||||||
let mut pool_writer = PoolWriter::new(pool, &pool_config.drive)?;
|
let mut pool_writer = PoolWriter::new(pool, drive)?;
|
||||||
|
|
||||||
let mut group_list = BackupInfo::list_backup_groups(&datastore.base_path())?;
|
let mut group_list = BackupInfo::list_backup_groups(&datastore.base_path())?;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ use crate::{
|
|||||||
tools::compute_file_csum,
|
tools::compute_file_csum,
|
||||||
api2::types::{
|
api2::types::{
|
||||||
DATASTORE_SCHEMA,
|
DATASTORE_SCHEMA,
|
||||||
|
DRIVE_NAME_SCHEMA,
|
||||||
UPID_SCHEMA,
|
UPID_SCHEMA,
|
||||||
Authid,
|
Authid,
|
||||||
MediaPoolConfig,
|
MediaPoolConfig,
|
||||||
@ -82,6 +83,9 @@ pub const ROUTER: Router = Router::new()
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
drive: {
|
||||||
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
|
},
|
||||||
"media-set": {
|
"media-set": {
|
||||||
description: "Media set UUID.",
|
description: "Media set UUID.",
|
||||||
type: String,
|
type: String,
|
||||||
@ -95,6 +99,7 @@ pub const ROUTER: Router = Router::new()
|
|||||||
/// Restore data from media-set
|
/// Restore data from media-set
|
||||||
pub fn restore(
|
pub fn restore(
|
||||||
store: String,
|
store: String,
|
||||||
|
drive: String,
|
||||||
media_set: String,
|
media_set: String,
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
@ -110,12 +115,13 @@ pub fn restore(
|
|||||||
|
|
||||||
let pool = inventory.lookup_media_set_pool(&media_set_uuid)?;
|
let pool = inventory.lookup_media_set_pool(&media_set_uuid)?;
|
||||||
|
|
||||||
|
// check if pool exists
|
||||||
let (config, _digest) = config::media_pool::config()?;
|
let (config, _digest) = config::media_pool::config()?;
|
||||||
let pool_config: MediaPoolConfig = config.lookup("pool", &pool)?;
|
let _pool_config: MediaPoolConfig = config.lookup("pool", &pool)?;
|
||||||
|
|
||||||
let (drive_config, _digest) = config::drive::config()?;
|
let (drive_config, _digest) = config::drive::config()?;
|
||||||
// early check before starting worker
|
// early check before starting worker
|
||||||
check_drive_exists(&drive_config, &pool_config.drive)?;
|
check_drive_exists(&drive_config, &drive)?;
|
||||||
|
|
||||||
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
||||||
|
|
||||||
@ -153,8 +159,6 @@ pub fn restore(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let drive = &pool_config.drive;
|
|
||||||
|
|
||||||
worker.log(format!("Restore mediaset '{}'", media_set));
|
worker.log(format!("Restore mediaset '{}'", media_set));
|
||||||
if let Some(fingerprint) = encryption_key_fingerprint {
|
if let Some(fingerprint) = encryption_key_fingerprint {
|
||||||
worker.log(format!("Encryption key fingerprint: {}", fingerprint));
|
worker.log(format!("Encryption key fingerprint: {}", fingerprint));
|
||||||
@ -175,7 +179,7 @@ pub fn restore(
|
|||||||
&worker,
|
&worker,
|
||||||
media_id,
|
media_id,
|
||||||
&drive_config,
|
&drive_config,
|
||||||
drive,
|
&drive,
|
||||||
&datastore,
|
&datastore,
|
||||||
&auth_id,
|
&auth_id,
|
||||||
)?;
|
)?;
|
||||||
|
@ -21,7 +21,6 @@ use crate::{
|
|||||||
parse_calendar_event,
|
parse_calendar_event,
|
||||||
},
|
},
|
||||||
api2::types::{
|
api2::types::{
|
||||||
DRIVE_NAME_SCHEMA,
|
|
||||||
PROXMOX_SAFE_ID_FORMAT,
|
PROXMOX_SAFE_ID_FORMAT,
|
||||||
SINGLE_LINE_COMMENT_FORMAT,
|
SINGLE_LINE_COMMENT_FORMAT,
|
||||||
TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
||||||
@ -116,9 +115,6 @@ impl std::str::FromStr for RetentionPolicy {
|
|||||||
name: {
|
name: {
|
||||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
drive: {
|
|
||||||
schema: DRIVE_NAME_SCHEMA,
|
|
||||||
},
|
|
||||||
allocation: {
|
allocation: {
|
||||||
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
schema: MEDIA_SET_ALLOCATION_POLICY_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -142,8 +138,6 @@ impl std::str::FromStr for RetentionPolicy {
|
|||||||
pub struct MediaPoolConfig {
|
pub struct MediaPoolConfig {
|
||||||
/// The pool name
|
/// The pool name
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// The associated drive
|
|
||||||
pub drive: String,
|
|
||||||
/// Media Set allocation policy
|
/// Media Set allocation policy
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub allocation: Option<String>,
|
pub allocation: Option<String>,
|
||||||
|
@ -765,6 +765,10 @@ async fn clean_drive(param: Value) -> Result<(), Error> {
|
|||||||
pool: {
|
pool: {
|
||||||
schema: MEDIA_POOL_NAME_SCHEMA,
|
schema: MEDIA_POOL_NAME_SCHEMA,
|
||||||
},
|
},
|
||||||
|
drive: {
|
||||||
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
"eject-media": {
|
"eject-media": {
|
||||||
description: "Eject media upon job completion.",
|
description: "Eject media upon job completion.",
|
||||||
type: bool,
|
type: bool,
|
||||||
@ -783,10 +787,14 @@ async fn clean_drive(param: Value) -> Result<(), Error> {
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Backup datastore to tape media pool
|
/// Backup datastore to tape media pool
|
||||||
async fn backup(param: Value) -> Result<(), Error> {
|
async fn backup(mut param: Value) -> Result<(), Error> {
|
||||||
|
|
||||||
let output_format = get_output_format(¶m);
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let (config, _digest) = config::drive::config()?;
|
||||||
|
|
||||||
|
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||||
|
|
||||||
let mut client = connect_to_localhost()?;
|
let mut client = connect_to_localhost()?;
|
||||||
|
|
||||||
let result = client.post("api2/json/tape/backup", Some(param)).await?;
|
let result = client.post("api2/json/tape/backup", Some(param)).await?;
|
||||||
@ -802,6 +810,10 @@ async fn backup(param: Value) -> Result<(), Error> {
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
drive: {
|
||||||
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
"media-set": {
|
"media-set": {
|
||||||
description: "Media set UUID.",
|
description: "Media set UUID.",
|
||||||
type: String,
|
type: String,
|
||||||
@ -814,10 +826,14 @@ async fn backup(param: Value) -> Result<(), Error> {
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Restore data from media-set
|
/// Restore data from media-set
|
||||||
async fn restore(param: Value) -> Result<(), Error> {
|
async fn restore(mut param: Value) -> Result<(), Error> {
|
||||||
|
|
||||||
let output_format = get_output_format(¶m);
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let (config, _digest) = config::drive::config()?;
|
||||||
|
|
||||||
|
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||||
|
|
||||||
let mut client = connect_to_localhost()?;
|
let mut client = connect_to_localhost()?;
|
||||||
|
|
||||||
let result = client.post("api2/json/tape/restore", Some(param)).await?;
|
let result = client.post("api2/json/tape/restore", Some(param)).await?;
|
||||||
|
@ -18,9 +18,6 @@ use proxmox_backup::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
config::{
|
config::{
|
||||||
drive::{
|
|
||||||
complete_drive_name,
|
|
||||||
},
|
|
||||||
media_pool::{
|
media_pool::{
|
||||||
complete_pool_name,
|
complete_pool_name,
|
||||||
},
|
},
|
||||||
@ -50,7 +47,6 @@ pub fn pool_commands() -> CommandLineInterface {
|
|||||||
CliCommand::new(&api2::config::media_pool::API_METHOD_CREATE_POOL)
|
CliCommand::new(&api2::config::media_pool::API_METHOD_CREATE_POOL)
|
||||||
.arg_param(&["name"])
|
.arg_param(&["name"])
|
||||||
.completion_cb("name", complete_pool_name)
|
.completion_cb("name", complete_pool_name)
|
||||||
.completion_cb("drive", complete_drive_name)
|
|
||||||
.completion_cb("encrypt", complete_key_fingerprint)
|
.completion_cb("encrypt", complete_key_fingerprint)
|
||||||
)
|
)
|
||||||
.insert(
|
.insert(
|
||||||
@ -58,7 +54,6 @@ pub fn pool_commands() -> CommandLineInterface {
|
|||||||
CliCommand::new(&api2::config::media_pool::API_METHOD_UPDATE_POOL)
|
CliCommand::new(&api2::config::media_pool::API_METHOD_UPDATE_POOL)
|
||||||
.arg_param(&["name"])
|
.arg_param(&["name"])
|
||||||
.completion_cb("name", complete_pool_name)
|
.completion_cb("name", complete_pool_name)
|
||||||
.completion_cb("drive", complete_drive_name)
|
|
||||||
.completion_cb("encrypt", complete_key_fingerprint)
|
.completion_cb("encrypt", complete_key_fingerprint)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
@ -99,7 +94,6 @@ fn list_pools(
|
|||||||
|
|
||||||
let options = default_table_format_options()
|
let options = default_table_format_options()
|
||||||
.column(ColumnConfig::new("name"))
|
.column(ColumnConfig::new("name"))
|
||||||
.column(ColumnConfig::new("drive"))
|
|
||||||
.column(ColumnConfig::new("allocation"))
|
.column(ColumnConfig::new("allocation"))
|
||||||
.column(ColumnConfig::new("retention"))
|
.column(ColumnConfig::new("retention"))
|
||||||
.column(ColumnConfig::new("template"))
|
.column(ColumnConfig::new("template"))
|
||||||
|
Loading…
Reference in New Issue
Block a user