tape: proxmox-tape - use api for erase-media and rewind
This commit is contained in:
parent
1a0eb86344
commit
eb1dfb02b5
|
@ -1181,7 +1181,7 @@ pub const SUBDIRS: SubdirMap = &sorted!([
|
||||||
(
|
(
|
||||||
"erase-media",
|
"erase-media",
|
||||||
&Router::new()
|
&Router::new()
|
||||||
.put(&API_METHOD_ERASE_MEDIA)
|
.post(&API_METHOD_ERASE_MEDIA)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"inventory",
|
"inventory",
|
||||||
|
@ -1222,7 +1222,7 @@ pub const SUBDIRS: SubdirMap = &sorted!([
|
||||||
(
|
(
|
||||||
"rewind",
|
"rewind",
|
||||||
&Router::new()
|
&Router::new()
|
||||||
.put(&API_METHOD_REWIND)
|
.post(&API_METHOD_REWIND)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"status",
|
"status",
|
||||||
|
|
|
@ -138,27 +138,28 @@ pub fn lookup_drive_name(
|
||||||
optional: true,
|
optional: true,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Erase media
|
/// Erase media
|
||||||
async fn erase_media(
|
async fn erase_media(param: Value) -> Result<(), Error> {
|
||||||
mut param: Value,
|
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
let output_format = get_output_format(¶m);
|
||||||
) -> Result<(), Error> {
|
|
||||||
|
|
||||||
let (config, _digest) = config::drive::config()?;
|
let (config, _digest) = config::drive::config()?;
|
||||||
|
|
||||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
let drive = lookup_drive_name(¶m, &config)?;
|
||||||
|
|
||||||
let info = &api2::tape::drive::API_METHOD_ERASE_MEDIA;
|
let mut client = connect_to_localhost()?;
|
||||||
|
|
||||||
let result = match info.handler {
|
let path = format!("api2/json/tape/drive/{}/erase-media", drive);
|
||||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
let result = client.post(&path, Some(param)).await?;
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
wait_for_local_worker(result.as_str().unwrap()).await?;
|
view_task_result(client, result, &output_format).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -170,27 +171,28 @@ async fn erase_media(
|
||||||
schema: DRIVE_NAME_SCHEMA,
|
schema: DRIVE_NAME_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Rewind tape
|
/// Rewind tape
|
||||||
async fn rewind(
|
async fn rewind(param: Value) -> Result<(), Error> {
|
||||||
mut param: Value,
|
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
let output_format = get_output_format(¶m);
|
||||||
) -> Result<(), Error> {
|
|
||||||
|
|
||||||
let (config, _digest) = config::drive::config()?;
|
let (config, _digest) = config::drive::config()?;
|
||||||
|
|
||||||
param["drive"] = lookup_drive_name(¶m, &config)?.into();
|
let drive = lookup_drive_name(¶m, &config)?;
|
||||||
|
|
||||||
let info = &api2::tape::drive::API_METHOD_REWIND;
|
let mut client = connect_to_localhost()?;
|
||||||
|
|
||||||
let result = match info.handler {
|
let path = format!("api2/json/tape/drive/{}/rewind", drive);
|
||||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
let result = client.post(&path, Some(param)).await?;
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
wait_for_local_worker(result.as_str().unwrap()).await?;
|
view_task_result(client, result, &output_format).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue