tape: add restore code, implement catalog api/command
This commit is contained in:
@ -632,6 +632,52 @@ async fn backup(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
drive: {
|
||||
schema: DRIVE_NAME_SCHEMA,
|
||||
optional: true,
|
||||
},
|
||||
force: {
|
||||
description: "Force overriding existing index.",
|
||||
type: bool,
|
||||
optional: true,
|
||||
},
|
||||
verbose: {
|
||||
description: "Verbose mode - log all found chunks.",
|
||||
type: bool,
|
||||
optional: true,
|
||||
},
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
)]
|
||||
/// Scan media and record content
|
||||
async fn catalog_media(
|
||||
mut param: Value,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
|
||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
||||
|
||||
let info = &api2::tape::drive::API_METHOD_CATALOG_MEDIA;
|
||||
|
||||
let result = match info.handler {
|
||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
wait_for_local_worker(result.as_str().unwrap()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
@ -688,6 +734,11 @@ fn main() {
|
||||
CliCommand::new(&API_METHOD_READ_LABEL)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"catalog",
|
||||
CliCommand::new(&API_METHOD_CATALOG_MEDIA)
|
||||
.completion_cb("drive", complete_drive_name)
|
||||
)
|
||||
.insert(
|
||||
"cartridge-memory",
|
||||
CliCommand::new(&API_METHOD_CARTRIDGE_MEMORY)
|
||||
|
Reference in New Issue
Block a user