tape: check digest on config update

This commit is contained in:
Dietmar Maurer 2020-12-08 11:24:38 +01:00
parent 50bf10ad56
commit 5ba83ed099
2 changed files with 27 additions and 5 deletions

View File

@ -6,6 +6,7 @@ use proxmox::api::{api, Router, RpcEnvironment};
use crate::{
config,
api2::types::{
PROXMOX_CONFIG_DIGEST_SCHEMA,
CHANGER_ID_SCHEMA,
LINUX_DRIVE_PATH_SCHEMA,
DriveListEntry,
@ -148,6 +149,10 @@ pub fn list_changers(
schema: LINUX_DRIVE_PATH_SCHEMA,
optional: true,
},
digest: {
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
optional: true,
},
},
},
)]
@ -155,12 +160,18 @@ pub fn list_changers(
pub fn update_changer(
name: String,
path: Option<String>,
digest: Option<String>,
_param: Value,
) -> Result<(), Error> {
let _lock = config::drive::lock()?;
let (mut config, _digest) = config::drive::config()?;
let (mut config, expected_digest) = config::drive::config()?;
if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?;
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
}
let mut data: ScsiTapeChanger = config.lookup("changer", &name)?;

View File

@ -6,6 +6,7 @@ use proxmox::api::{api, Router, RpcEnvironment};
use crate::{
config,
api2::types::{
PROXMOX_CONFIG_DIGEST_SCHEMA,
DRIVE_ID_SCHEMA,
CHANGER_ID_SCHEMA,
LINUX_DRIVE_PATH_SCHEMA,
@ -147,6 +148,10 @@ pub fn list_drives(
schema: CHANGER_ID_SCHEMA,
optional: true,
},
digest: {
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
optional: true,
},
},
},
)]
@ -155,12 +160,18 @@ pub fn update_drive(
name: String,
path: Option<String>,
changer: Option<String>,
digest: Option<String>,
_param: Value,
) -> Result<(), Error> {
let _lock = config::drive::lock()?;
let (mut config, _digest) = config::drive::config()?;
let (mut config, expected_digest) = config::drive::config()?;
if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?;
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
}
let mut data: LinuxTapeDrive = config.lookup("linux", &name)?;