tape: check digest on config update
This commit is contained in:
parent
50bf10ad56
commit
5ba83ed099
@ -6,6 +6,7 @@ use proxmox::api::{api, Router, RpcEnvironment};
|
|||||||
use crate::{
|
use crate::{
|
||||||
config,
|
config,
|
||||||
api2::types::{
|
api2::types::{
|
||||||
|
PROXMOX_CONFIG_DIGEST_SCHEMA,
|
||||||
CHANGER_ID_SCHEMA,
|
CHANGER_ID_SCHEMA,
|
||||||
LINUX_DRIVE_PATH_SCHEMA,
|
LINUX_DRIVE_PATH_SCHEMA,
|
||||||
DriveListEntry,
|
DriveListEntry,
|
||||||
@ -148,19 +149,29 @@ pub fn list_changers(
|
|||||||
schema: LINUX_DRIVE_PATH_SCHEMA,
|
schema: LINUX_DRIVE_PATH_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
digest: {
|
||||||
|
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Update a tape changer configuration
|
/// Update a tape changer configuration
|
||||||
pub fn update_changer(
|
pub fn update_changer(
|
||||||
name: String,
|
name: String,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
|
digest: Option<String>,
|
||||||
_param: Value,
|
_param: Value,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
let _lock = config::drive::lock()?;
|
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)?;
|
let mut data: ScsiTapeChanger = config.lookup("changer", &name)?;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use proxmox::api::{api, Router, RpcEnvironment};
|
|||||||
use crate::{
|
use crate::{
|
||||||
config,
|
config,
|
||||||
api2::types::{
|
api2::types::{
|
||||||
|
PROXMOX_CONFIG_DIGEST_SCHEMA,
|
||||||
DRIVE_ID_SCHEMA,
|
DRIVE_ID_SCHEMA,
|
||||||
CHANGER_ID_SCHEMA,
|
CHANGER_ID_SCHEMA,
|
||||||
LINUX_DRIVE_PATH_SCHEMA,
|
LINUX_DRIVE_PATH_SCHEMA,
|
||||||
@ -147,7 +148,11 @@ pub fn list_drives(
|
|||||||
schema: CHANGER_ID_SCHEMA,
|
schema: CHANGER_ID_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
},
|
digest: {
|
||||||
|
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Update a drive configuration
|
/// Update a drive configuration
|
||||||
@ -155,12 +160,18 @@ pub fn update_drive(
|
|||||||
name: String,
|
name: String,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
changer: Option<String>,
|
changer: Option<String>,
|
||||||
_param: Value,
|
digest: Option<String>,
|
||||||
|
_param: Value,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
let _lock = config::drive::lock()?;
|
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)?;
|
let mut data: LinuxTapeDrive = config.lookup("linux", &name)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user