tape: add tape backup job configuration

This commit is contained in:
Dietmar Maurer
2021-02-14 10:32:33 +01:00
parent c724dc3892
commit be327dbccd
7 changed files with 459 additions and 0 deletions

View File

@ -0,0 +1,112 @@
use anyhow::Error;
use serde_json::Value;
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
use proxmox_backup::{
config,
api2::{
self,
types::*,
},
};
#[api(
input: {
properties: {
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
}
}
)]
/// Tape backup job list.
fn list_tape_backup_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
let output_format = get_output_format(&param);
let info = &api2::config::tape_backup_job::API_METHOD_LIST_TAPE_BACKUP_JOBS;
let mut data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
let options = default_table_format_options()
.column(ColumnConfig::new("id"))
.column(ColumnConfig::new("store"))
.column(ColumnConfig::new("pool"))
.column(ColumnConfig::new("drive"))
.column(ColumnConfig::new("schedule"))
.column(ColumnConfig::new("comment"));
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
Ok(Value::Null)
}
#[api(
input: {
properties: {
id: {
schema: JOB_ID_SCHEMA,
},
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
}
}
)]
/// Show tape backup job configuration
fn show_tape_backup_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
let output_format = get_output_format(&param);
let info = &api2::config::tape_backup_job::API_METHOD_READ_TAPE_BACKUP_JOB;
let mut data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
let options = default_table_format_options();
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
Ok(Value::Null)
}
pub fn backup_job_commands() -> CommandLineInterface {
let cmd_def = CliCommandMap::new()
.insert("list", CliCommand::new(&API_METHOD_LIST_TAPE_BACKUP_JOBS))
.insert("show",
CliCommand::new(&API_METHOD_SHOW_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.completion_cb("id", config::tape_job::complete_tape_job_id)
)
.insert("create",
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_CREATE_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.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("drive", crate::complete_drive_name)
)
.insert("update",
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_UPDATE_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.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("drive", crate::complete_drive_name)
)
.insert("remove",
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_DELETE_TAPE_BACKUP_JOB)
.arg_param(&["id"])
.completion_cb("id", config::tape_job::complete_tape_job_id)
);
cmd_def.into()
}

View File

@ -12,3 +12,6 @@ pub use media::*;
mod encryption_key;
pub use encryption_key::*;
mod backup_job;
pub use backup_job::*;