[pbs-devel] [PATCH proxmox-backup 26/26] api: mark all removable datastores as 'unplugged' after restart
Hannes Laimer
h.laimer at proxmox.com
Tue Jul 5 15:08:34 CEST 2022
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
src/bin/proxmox-backup-api.rs | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs
index dda4b638..9614a6ea 100644
--- a/src/bin/proxmox-backup-api.rs
+++ b/src/bin/proxmox-backup-api.rs
@@ -8,6 +8,7 @@ use http::HeaderMap;
use http::Response;
use hyper::{Body, Method, StatusCode};
+use pbs_api_types::{DataStoreConfig, MaintenanceMode, MaintenanceType};
use proxmox_lang::try_block;
use proxmox_router::{RpcEnvironmentType, UserInformation};
use proxmox_sys::fs::CreateOptions;
@@ -159,6 +160,7 @@ async fn run() -> Result<(), Error> {
proxmox_rest_server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
let init_result: Result<(), Error> = try_block!({
+ mark_removable_datastores_unplugged()?;
proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
commando_sock.spawn()?;
proxmox_rest_server::catch_shutdown_signal()?;
@@ -178,3 +180,16 @@ async fn run() -> Result<(), Error> {
Ok(())
}
+
+fn mark_removable_datastores_unplugged() -> Result<(), Error> {
+ let (mut config, _digest) = pbs_config::datastore::config()?;
+ let list: Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
+ for mut datastore in list {
+ if datastore.removable {
+ datastore.set_maintenance_mode(MaintenanceMode::new(MaintenanceType::Unplugged, None));
+ config.set_data(&datastore.name, "datastore", &datastore)?;
+ }
+ }
+ pbs_config::datastore::save_config(&config)?;
+ Ok(())
+}
--
2.30.2
More information about the pbs-devel
mailing list