cli: tape: rust format
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -22,7 +22,6 @@ use proxmox_backup::client_helpers::connect_to_localhost;
|
||||
)]
|
||||
/// Tape backup job list.
|
||||
fn list_tape_backup_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
//let info = &api2::config::tape_backup_job::API_METHOD_LIST_TAPE_BACKUP_JOBS;
|
||||
@ -62,7 +61,6 @@ fn list_tape_backup_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Resul
|
||||
)]
|
||||
/// 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(¶m);
|
||||
|
||||
let info = &api2::config::tape_backup_job::API_METHOD_READ_TAPE_BACKUP_JOB;
|
||||
@ -88,14 +86,15 @@ fn show_tape_backup_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result
|
||||
)]
|
||||
/// Run THape Backup Job
|
||||
async fn run_tape_backup_job(mut param: Value) -> Result<(), Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let id = param["id"].take().as_str().unwrap().to_string();
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
let result = client.post(&format!("api2/json/tape/backup/{}", id), Some(param)).await?;
|
||||
let result = client
|
||||
.post(&format!("api2/json/tape/backup/{}", id), Some(param))
|
||||
.await?;
|
||||
|
||||
view_task_result(&client, result, &output_format).await?;
|
||||
|
||||
@ -103,41 +102,45 @@ async fn run_tape_backup_job(mut param: Value) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
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)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_TAPE_BACKUP_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id)
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id),
|
||||
)
|
||||
.insert("run",
|
||||
CliCommand::new(&API_METHOD_RUN_TAPE_BACKUP_JOB)
|
||||
.insert(
|
||||
"run",
|
||||
CliCommand::new(&API_METHOD_RUN_TAPE_BACKUP_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id)
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id),
|
||||
)
|
||||
.insert("create",
|
||||
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_CREATE_TAPE_BACKUP_JOB)
|
||||
.insert(
|
||||
"create",
|
||||
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", 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)
|
||||
.completion_cb("drive", crate::complete_drive_name),
|
||||
)
|
||||
.insert("update",
|
||||
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_UPDATE_TAPE_BACKUP_JOB)
|
||||
.insert(
|
||||
"update",
|
||||
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", 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)
|
||||
.completion_cb("drive", crate::complete_drive_name),
|
||||
)
|
||||
.insert("remove",
|
||||
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_DELETE_TAPE_BACKUP_JOB)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::tape_backup_job::API_METHOD_DELETE_TAPE_BACKUP_JOB)
|
||||
.arg_param(&["id"])
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id)
|
||||
.completion_cb("id", pbs_config::tape_job::complete_tape_job_id),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
|
@ -5,22 +5,15 @@ use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
use proxmox_section_config::SectionConfigData;
|
||||
|
||||
use pbs_config::drive::{
|
||||
complete_drive_name,
|
||||
complete_changer_name,
|
||||
};
|
||||
use pbs_config::drive::{complete_changer_name, complete_drive_name};
|
||||
|
||||
use pbs_api_types::CHANGER_NAME_SCHEMA;
|
||||
|
||||
use pbs_tape::linux_list_drives::{complete_changer_path};
|
||||
use pbs_tape::linux_list_drives::complete_changer_path;
|
||||
|
||||
use proxmox_backup::{api2, tape::drive::media_changer};
|
||||
|
||||
pub fn lookup_changer_name(
|
||||
param: &Value,
|
||||
config: &SectionConfigData,
|
||||
) -> Result<String, Error> {
|
||||
|
||||
pub fn lookup_changer_name(param: &Value, config: &SectionConfigData) -> Result<String, Error> {
|
||||
if let Some(name) = param["name"].as_str() {
|
||||
return Ok(String::from(name));
|
||||
}
|
||||
@ -37,46 +30,47 @@ pub fn lookup_changer_name(
|
||||
}
|
||||
|
||||
pub fn changer_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("scan", CliCommand::new(&API_METHOD_SCAN_FOR_CHANGERS))
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_CHANGERS))
|
||||
.insert("config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.insert(
|
||||
"config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_changer_name)
|
||||
.completion_cb("name", complete_changer_name),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::changer::API_METHOD_DELETE_CHANGER)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_changer_name)
|
||||
.completion_cb("name", complete_changer_name),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::changer::API_METHOD_CREATE_CHANGER)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_drive_name)
|
||||
.completion_cb("path", complete_changer_path)
|
||||
.completion_cb("path", complete_changer_path),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::changer::API_METHOD_UPDATE_CHANGER)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_changer_name)
|
||||
.completion_cb("path", complete_changer_path)
|
||||
.completion_cb("path", complete_changer_path),
|
||||
)
|
||||
.insert("status",
|
||||
CliCommand::new(&API_METHOD_GET_STATUS)
|
||||
.insert(
|
||||
"status",
|
||||
CliCommand::new(&API_METHOD_GET_STATUS)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_changer_name)
|
||||
.completion_cb("name", complete_changer_name),
|
||||
)
|
||||
.insert("transfer",
|
||||
CliCommand::new(&API_METHOD_TRANSFER)
|
||||
.insert(
|
||||
"transfer",
|
||||
CliCommand::new(&API_METHOD_TRANSFER)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_changer_name)
|
||||
)
|
||||
;
|
||||
.completion_cb("name", complete_changer_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
@ -92,11 +86,7 @@ pub fn changer_commands() -> CommandLineInterface {
|
||||
},
|
||||
)]
|
||||
/// List changers
|
||||
fn list_changers(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn list_changers(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::changer::API_METHOD_LIST_CHANGERS;
|
||||
let mut data = match info.handler {
|
||||
@ -109,8 +99,7 @@ fn list_changers(
|
||||
.column(ColumnConfig::new("path"))
|
||||
.column(ColumnConfig::new("vendor"))
|
||||
.column(ColumnConfig::new("model"))
|
||||
.column(ColumnConfig::new("serial"))
|
||||
;
|
||||
.column(ColumnConfig::new("serial"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -128,11 +117,7 @@ fn list_changers(
|
||||
},
|
||||
)]
|
||||
/// Scan for SCSI tape changers
|
||||
fn scan_for_changers(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn scan_for_changers(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::API_METHOD_SCAN_CHANGERS;
|
||||
let mut data = match info.handler {
|
||||
@ -144,8 +129,7 @@ fn scan_for_changers(
|
||||
.column(ColumnConfig::new("path"))
|
||||
.column(ColumnConfig::new("vendor"))
|
||||
.column(ColumnConfig::new("model"))
|
||||
.column(ColumnConfig::new("serial"))
|
||||
;
|
||||
.column(ColumnConfig::new("serial"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -166,11 +150,7 @@ fn scan_for_changers(
|
||||
},
|
||||
)]
|
||||
/// Get tape changer configuration
|
||||
fn get_config(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn get_config(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::config::changer::API_METHOD_GET_CONFIG;
|
||||
let mut data = match info.handler {
|
||||
@ -181,8 +161,7 @@ fn get_config(
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("path"))
|
||||
.column(ColumnConfig::new("export-slots"))
|
||||
;
|
||||
.column(ColumnConfig::new("export-slots"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -210,11 +189,7 @@ fn get_config(
|
||||
},
|
||||
)]
|
||||
/// Get tape changer status
|
||||
async fn get_status(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
async fn get_status(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
param["name"] = lookup_changer_name(¶m, &config)?.into();
|
||||
@ -244,8 +219,7 @@ async fn get_status(
|
||||
.column(ColumnConfig::new("entry-kind"))
|
||||
.column(ColumnConfig::new("entry-id"))
|
||||
.column(ColumnConfig::new("label-text").renderer(render_label_text))
|
||||
.column(ColumnConfig::new("loaded-slot"))
|
||||
;
|
||||
.column(ColumnConfig::new("loaded-slot"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -273,11 +247,7 @@ async fn get_status(
|
||||
},
|
||||
)]
|
||||
/// Transfers media from one slot to another
|
||||
pub async fn transfer(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
pub async fn transfer(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
|
||||
param["name"] = lookup_changer_name(¶m, &config)?.into();
|
||||
|
@ -6,31 +6,27 @@ use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::DRIVE_NAME_SCHEMA;
|
||||
|
||||
use pbs_config::drive::{
|
||||
complete_drive_name,
|
||||
complete_changer_name,
|
||||
complete_lto_drive_name,
|
||||
};
|
||||
use pbs_config::drive::{complete_changer_name, complete_drive_name, complete_lto_drive_name};
|
||||
|
||||
use pbs_tape::linux_list_drives::{complete_drive_path};
|
||||
use pbs_tape::linux_list_drives::complete_drive_path;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
pub fn drive_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("scan", CliCommand::new(&API_METHOD_SCAN_FOR_DRIVES))
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_DRIVES))
|
||||
.insert("config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.insert(
|
||||
"config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_lto_drive_name)
|
||||
.completion_cb("name", complete_lto_drive_name),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::drive::API_METHOD_DELETE_DRIVE)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_lto_drive_name)
|
||||
.completion_cb("name", complete_lto_drive_name),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
@ -38,7 +34,7 @@ pub fn drive_commands() -> CommandLineInterface {
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_drive_name)
|
||||
.completion_cb("path", complete_drive_path)
|
||||
.completion_cb("changer", complete_changer_name)
|
||||
.completion_cb("changer", complete_changer_name),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
@ -46,9 +42,8 @@ pub fn drive_commands() -> CommandLineInterface {
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_lto_drive_name)
|
||||
.completion_cb("path", complete_drive_path)
|
||||
.completion_cb("changer", complete_changer_name)
|
||||
)
|
||||
;
|
||||
.completion_cb("changer", complete_changer_name),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
@ -64,11 +59,7 @@ pub fn drive_commands() -> CommandLineInterface {
|
||||
},
|
||||
)]
|
||||
/// List drives
|
||||
fn list_drives(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn list_drives(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::drive::API_METHOD_LIST_DRIVES;
|
||||
let mut data = match info.handler {
|
||||
@ -82,8 +73,7 @@ fn list_drives(
|
||||
.column(ColumnConfig::new("changer"))
|
||||
.column(ColumnConfig::new("vendor"))
|
||||
.column(ColumnConfig::new("model"))
|
||||
.column(ColumnConfig::new("serial"))
|
||||
;
|
||||
.column(ColumnConfig::new("serial"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -101,11 +91,7 @@ fn list_drives(
|
||||
}
|
||||
)]
|
||||
/// Scan for drives
|
||||
fn scan_for_drives(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn scan_for_drives(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::API_METHOD_SCAN_DRIVES;
|
||||
let mut data = match info.handler {
|
||||
@ -117,15 +103,13 @@ fn scan_for_drives(
|
||||
.column(ColumnConfig::new("path"))
|
||||
.column(ColumnConfig::new("vendor"))
|
||||
.column(ColumnConfig::new("model"))
|
||||
.column(ColumnConfig::new("serial"))
|
||||
;
|
||||
.column(ColumnConfig::new("serial"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -140,11 +124,7 @@ fn scan_for_drives(
|
||||
},
|
||||
)]
|
||||
/// Get pool configuration
|
||||
fn get_config(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn get_config(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::config::drive::API_METHOD_GET_CONFIG;
|
||||
let mut data = match info.handler {
|
||||
@ -156,8 +136,7 @@ fn get_config(
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("path"))
|
||||
.column(ColumnConfig::new("changer"))
|
||||
.column(ColumnConfig::new("changer-drivenum"))
|
||||
;
|
||||
.column(ColumnConfig::new("changer-drivenum"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
|
@ -6,53 +6,45 @@ use proxmox_schema::{api, param_bail};
|
||||
use proxmox_sys::linux::tty;
|
||||
|
||||
use pbs_api_types::{
|
||||
Fingerprint, Kdf, DRIVE_NAME_SCHEMA, TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
||||
PASSWORD_HINT_SCHEMA,
|
||||
Fingerprint, Kdf, DRIVE_NAME_SCHEMA, PASSWORD_HINT_SCHEMA,
|
||||
TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
||||
};
|
||||
|
||||
use pbs_datastore::paperkey::{PaperkeyFormat, generate_paper_key};
|
||||
use pbs_config::tape_encryption_keys::{load_key_configs,complete_key_fingerprint};
|
||||
use pbs_config::key_config::KeyConfig;
|
||||
use pbs_config::tape_encryption_keys::{complete_key_fingerprint, load_key_configs};
|
||||
use pbs_datastore::paperkey::{generate_paper_key, PaperkeyFormat};
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
pub fn encryption_key_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_KEYS))
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&API_METHOD_CREATE_KEY)
|
||||
)
|
||||
.insert("create", CliCommand::new(&API_METHOD_CREATE_KEY))
|
||||
.insert(
|
||||
"change-passphrase",
|
||||
CliCommand::new(&API_METHOD_CHANGE_PASSPHRASE)
|
||||
.arg_param(&["fingerprint"])
|
||||
.completion_cb("fingerprint", complete_key_fingerprint)
|
||||
.completion_cb("fingerprint", complete_key_fingerprint),
|
||||
)
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_KEY)
|
||||
.arg_param(&["fingerprint"])
|
||||
.completion_cb("fingerprint", complete_key_fingerprint)
|
||||
.completion_cb("fingerprint", complete_key_fingerprint),
|
||||
)
|
||||
.insert(
|
||||
"paperkey",
|
||||
CliCommand::new(&API_METHOD_PAPER_KEY)
|
||||
.arg_param(&["fingerprint"])
|
||||
.completion_cb("fingerprint", complete_key_fingerprint)
|
||||
)
|
||||
.insert(
|
||||
"restore",
|
||||
CliCommand::new(&API_METHOD_RESTORE_KEY)
|
||||
.completion_cb("fingerprint", complete_key_fingerprint),
|
||||
)
|
||||
.insert("restore", CliCommand::new(&API_METHOD_RESTORE_KEY))
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::tape_encryption_keys::API_METHOD_DELETE_KEY)
|
||||
.arg_param(&["fingerprint"])
|
||||
.completion_cb("fingerprint", complete_key_fingerprint)
|
||||
)
|
||||
;
|
||||
.completion_cb("fingerprint", complete_key_fingerprint),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
@ -82,7 +74,6 @@ fn paper_key(
|
||||
subject: Option<String>,
|
||||
output_format: Option<PaperkeyFormat>,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let (config_map, _digest) = load_key_configs()?;
|
||||
|
||||
let key_config = match config_map.get(&fingerprint) {
|
||||
@ -109,11 +100,7 @@ fn paper_key(
|
||||
},
|
||||
)]
|
||||
/// Print the encryption key's metadata.
|
||||
fn show_key(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn show_key(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::tape_encryption_keys::API_METHOD_READ_KEY;
|
||||
@ -162,7 +149,6 @@ fn change_passphrase(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
if !tty::stdin_isatty() {
|
||||
bail!("unable to change passphrase - no tty");
|
||||
}
|
||||
@ -288,11 +274,7 @@ async fn restore_key(
|
||||
},
|
||||
)]
|
||||
/// Create key (read password from stdin)
|
||||
fn create_key(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn create_key(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
if !tty::stdin_isatty() {
|
||||
bail!("no password input mechanism available");
|
||||
}
|
||||
@ -312,7 +294,6 @@ fn create_key(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -324,11 +305,7 @@ fn create_key(
|
||||
},
|
||||
)]
|
||||
/// List keys
|
||||
fn list_keys(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn list_keys(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::config::tape_encryption_keys::API_METHOD_LIST_KEYS;
|
||||
let mut data = match info.handler {
|
||||
@ -338,8 +315,7 @@ fn list_keys(
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("fingerprint"))
|
||||
.column(ColumnConfig::new("hint"))
|
||||
;
|
||||
.column(ColumnConfig::new("hint"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
|
@ -1,39 +1,34 @@
|
||||
use anyhow::{Error};
|
||||
use anyhow::Error;
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::{
|
||||
MEDIA_POOL_NAME_SCHEMA, CHANGER_NAME_SCHEMA, MediaStatus, MediaListEntry,
|
||||
MediaContentListFilter,
|
||||
MediaContentListFilter, MediaListEntry, MediaStatus, CHANGER_NAME_SCHEMA,
|
||||
MEDIA_POOL_NAME_SCHEMA,
|
||||
};
|
||||
use pbs_config::drive::complete_changer_name;
|
||||
use pbs_config::media_pool::complete_pool_name;
|
||||
|
||||
use proxmox_backup::{
|
||||
api2,
|
||||
tape::{
|
||||
complete_media_label_text,
|
||||
complete_media_uuid,
|
||||
complete_media_set_uuid,
|
||||
},
|
||||
tape::{complete_media_label_text, complete_media_set_uuid, complete_media_uuid},
|
||||
};
|
||||
|
||||
pub fn media_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert(
|
||||
"list",
|
||||
CliCommand::new(&API_METHOD_LIST_MEDIA)
|
||||
.completion_cb("pool", complete_pool_name)
|
||||
.completion_cb("update-status-changer", complete_changer_name)
|
||||
.completion_cb("update-status-changer", complete_changer_name),
|
||||
)
|
||||
.insert(
|
||||
"destroy",
|
||||
CliCommand::new(&api2::tape::media::API_METHOD_DESTROY_MEDIA)
|
||||
.arg_param(&["label-text"])
|
||||
.completion_cb("label-text", complete_media_label_text)
|
||||
.completion_cb("label-text", complete_media_label_text),
|
||||
)
|
||||
.insert(
|
||||
"content",
|
||||
@ -41,9 +36,8 @@ pub fn media_commands() -> CommandLineInterface {
|
||||
.completion_cb("pool", complete_pool_name)
|
||||
.completion_cb("label-text", complete_media_label_text)
|
||||
.completion_cb("media", complete_media_uuid)
|
||||
.completion_cb("media-set", complete_media_set_uuid)
|
||||
)
|
||||
;
|
||||
.completion_cb("media-set", complete_media_set_uuid),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
@ -74,11 +68,7 @@ pub fn media_commands() -> CommandLineInterface {
|
||||
},
|
||||
)]
|
||||
/// List pool media
|
||||
async fn list_media(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
async fn list_media(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::media::API_METHOD_LIST_MEDIA;
|
||||
let mut data = match info.handler {
|
||||
@ -89,17 +79,17 @@ async fn list_media(
|
||||
fn render_status(_value: &Value, record: &Value) -> Result<String, Error> {
|
||||
let record: MediaListEntry = serde_json::from_value(record.clone())?;
|
||||
Ok(match record.status {
|
||||
MediaStatus::Damaged | MediaStatus::Retired => {
|
||||
serde_json::to_value(&record.status)?
|
||||
.as_str().unwrap()
|
||||
.to_string()
|
||||
}
|
||||
MediaStatus::Damaged | MediaStatus::Retired => serde_json::to_value(&record.status)?
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
_ => {
|
||||
if record.expired {
|
||||
String::from("expired")
|
||||
} else {
|
||||
serde_json::to_value(&record.status)?
|
||||
.as_str().unwrap()
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
@ -127,8 +117,7 @@ async fn list_media(
|
||||
.column(ColumnConfig::new("location"))
|
||||
.column(ColumnConfig::new("catalog").renderer(catalog_status))
|
||||
.column(ColumnConfig::new("uuid"))
|
||||
.column(ColumnConfig::new("media-set-uuid"))
|
||||
;
|
||||
.column(ColumnConfig::new("media-set-uuid"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -150,11 +139,7 @@ async fn list_media(
|
||||
},
|
||||
)]
|
||||
/// List media content
|
||||
fn list_content(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn list_content(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::tape::media::API_METHOD_LIST_CONTENT;
|
||||
let mut data = match info.handler {
|
||||
@ -174,11 +159,9 @@ fn list_content(
|
||||
.column(ColumnConfig::new("seq-nr"))
|
||||
.column(ColumnConfig::new("store"))
|
||||
.column(ColumnConfig::new("snapshot"))
|
||||
.column(ColumnConfig::new("media-set-uuid"))
|
||||
;
|
||||
.column(ColumnConfig::new("media-set-uuid"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
Ok(())
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{Error};
|
||||
use anyhow::Error;
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
@ -11,35 +11,34 @@ use pbs_config::tape_encryption_keys::complete_key_fingerprint;
|
||||
use proxmox_backup::api2;
|
||||
|
||||
pub fn pool_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_POOLS))
|
||||
.insert("config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.insert(
|
||||
"config",
|
||||
CliCommand::new(&API_METHOD_GET_CONFIG)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_pool_name)
|
||||
.completion_cb("name", complete_pool_name),
|
||||
)
|
||||
.insert(
|
||||
"remove",
|
||||
CliCommand::new(&api2::config::media_pool::API_METHOD_DELETE_POOL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_pool_name)
|
||||
.completion_cb("name", complete_pool_name),
|
||||
)
|
||||
.insert(
|
||||
"create",
|
||||
CliCommand::new(&api2::config::media_pool::API_METHOD_CREATE_POOL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_pool_name)
|
||||
.completion_cb("encrypt", complete_key_fingerprint)
|
||||
.completion_cb("encrypt", complete_key_fingerprint),
|
||||
)
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::config::media_pool::API_METHOD_UPDATE_POOL)
|
||||
.arg_param(&["name"])
|
||||
.completion_cb("name", complete_pool_name)
|
||||
.completion_cb("encrypt", complete_key_fingerprint)
|
||||
)
|
||||
;
|
||||
.completion_cb("encrypt", complete_key_fingerprint),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
@ -55,11 +54,7 @@ pub fn pool_commands() -> CommandLineInterface {
|
||||
},
|
||||
)]
|
||||
/// List media pool
|
||||
fn list_pools(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn list_pools(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::config::media_pool::API_METHOD_LIST_POOLS;
|
||||
let mut data = match info.handler {
|
||||
@ -80,8 +75,7 @@ fn list_pools(
|
||||
.column(ColumnConfig::new("allocation"))
|
||||
.column(ColumnConfig::new("retention"))
|
||||
.column(ColumnConfig::new("template"))
|
||||
.column(ColumnConfig::new("encrypt").renderer(render_encryption))
|
||||
;
|
||||
.column(ColumnConfig::new("encrypt").renderer(render_encryption));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
@ -102,11 +96,7 @@ fn list_pools(
|
||||
},
|
||||
)]
|
||||
/// Get media pool configuration
|
||||
fn get_config(
|
||||
param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
fn get_config(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
let info = &api2::config::media_pool::API_METHOD_GET_CONFIG;
|
||||
let mut data = match info.handler {
|
||||
@ -119,8 +109,7 @@ fn get_config(
|
||||
.column(ColumnConfig::new("allocation"))
|
||||
.column(ColumnConfig::new("retention"))
|
||||
.column(ColumnConfig::new("template"))
|
||||
.column(ColumnConfig::new("encrypt"))
|
||||
;
|
||||
.column(ColumnConfig::new("encrypt"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
|
Reference in New Issue
Block a user