tape: add media state database

This commit is contained in:
Dietmar Maurer
2020-12-09 10:16:01 +01:00
parent eaff09f483
commit cafd51bf42
8 changed files with 465 additions and 10 deletions

View File

@ -1,3 +1,5 @@
use std::path::Path;
use anyhow::Error;
use serde_json::Value;
@ -14,9 +16,14 @@ use crate::{
MtxEntryKind,
},
tape::{
TAPE_STATUS_DIR,
ElementStatus,
OnlineStatusMap,
Inventory,
MediaStateDatabase,
linux_tape_changer_list,
mtx_status,
mtx_status_to_online_set,
mtx_transfer,
},
};
@ -47,8 +54,7 @@ pub fn get_status(name: String) -> Result<Vec<MtxStatusEntry>, Error> {
let status = mtx_status(&data.path)?;
/* todo: update persistent state
let state_path = Path::new(MEDIA_POOL_STATUS_DIR);
let state_path = Path::new(TAPE_STATUS_DIR);
let inventory = Inventory::load(state_path)?;
let mut map = OnlineStatusMap::new(&config)?;
@ -57,7 +63,6 @@ pub fn get_status(name: String) -> Result<Vec<MtxStatusEntry>, Error> {
let mut state_db = MediaStateDatabase::load(state_path)?;
state_db.update_online_status(&map)?;
*/
let mut list = Vec::new();

View File

@ -0,0 +1,21 @@
use ::serde::{Deserialize, Serialize};
use proxmox::api::api;
#[api()]
/// Media status
#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
/// Media Status
pub enum MediaStatus {
/// Media is ready to be written
Writable,
/// Media is full (contains data)
Full,
/// Media is marked as unknown, needs rescan
Unknown,
/// Media is marked as damaged
Damaged,
/// Media is marked as retired
Retired,
}

View File

@ -8,3 +8,6 @@ pub use drive::*;
mod media_pool;
pub use media_pool::*;
mod media_status;
pub use media_status::*;