tape: implement format/erase
This commit is contained in:
@ -409,7 +409,7 @@ fn eod(param: Value) -> Result<(), Error> {
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Erase media
|
||||
/// Erase media (from current position)
|
||||
fn erase(fast: Option<bool>, param: Value) -> Result<(), Error> {
|
||||
|
||||
let mut handle = get_tape_handle(¶m)?;
|
||||
@ -418,6 +418,35 @@ fn erase(fast: Option<bool>, param: Value) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_NAME_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
device: {
|
||||
schema: LTO_DRIVE_PATH_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
fast: {
|
||||
description: "Use fast erase.",
|
||||
type: bool,
|
||||
optional: true,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Format media, single partition
|
||||
fn format(fast: Option<bool>, param: Value) -> Result<(), Error> {
|
||||
|
||||
let mut handle = get_tape_handle(¶m)?;
|
||||
handle.format_media(fast.unwrap_or(true))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -800,6 +829,7 @@ fn main() -> Result<(), Error> {
|
||||
.insert("eject", std_cmd(&API_METHOD_EJECT))
|
||||
.insert("eod", std_cmd(&API_METHOD_EOD))
|
||||
.insert("erase", std_cmd(&API_METHOD_ERASE))
|
||||
.insert("format", std_cmd(&API_METHOD_FORMAT))
|
||||
.insert("fsf", std_cmd(&API_METHOD_FSF).arg_param(&["count"]))
|
||||
.insert("fsfm", std_cmd(&API_METHOD_FSFM).arg_param(&["count"]))
|
||||
.insert("fsr", std_cmd(&API_METHOD_FSR).arg_param(&["count"]))
|
||||
|
@ -115,8 +115,8 @@ pub fn extract_drive_name(
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Erase media
|
||||
async fn erase_media(mut param: Value) -> Result<(), Error> {
|
||||
/// Format media
|
||||
async fn format_media(mut param: Value) -> Result<(), Error> {
|
||||
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
@ -126,7 +126,7 @@ async fn erase_media(mut param: Value) -> Result<(), Error> {
|
||||
|
||||
let mut client = connect_to_localhost()?;
|
||||
|
||||
let path = format!("api2/json/tape/drive/{}/erase-media", drive);
|
||||
let path = format!("api2/json/tape/drive/{}/format-media", drive);
|
||||
let result = client.post(&path, Some(param)).await?;
|
||||
|
||||
view_task_result(&mut client, result, &output_format).await?;
|
||||
@ -992,8 +992,8 @@ fn main() {
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"erase",
|
||||
CliCommand::new(&API_METHOD_ERASE_MEDIA)
|
||||
"format",
|
||||
CliCommand::new(&API_METHOD_FORMAT_MEDIA)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
|
Reference in New Issue
Block a user