tape: rename DriveLabel to MediaLabel
This commit is contained in:
parent
410611b4f2
commit
a78348acbb
|
@ -50,7 +50,7 @@ use crate::{
|
||||||
media_changer,
|
media_changer,
|
||||||
update_changer_online_status,
|
update_changer_online_status,
|
||||||
file_formats::{
|
file_formats::{
|
||||||
DriveLabel,
|
MediaLabel,
|
||||||
MediaSetLabel,
|
MediaSetLabel,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -356,7 +356,7 @@ pub fn label_media(
|
||||||
}
|
}
|
||||||
|
|
||||||
let ctime = proxmox::tools::time::epoch_i64();
|
let ctime = proxmox::tools::time::epoch_i64();
|
||||||
let label = DriveLabel {
|
let label = MediaLabel {
|
||||||
changer_id: changer_id.to_string(),
|
changer_id: changer_id.to_string(),
|
||||||
uuid: Uuid::generate(),
|
uuid: Uuid::generate(),
|
||||||
ctime,
|
ctime,
|
||||||
|
@ -372,7 +372,7 @@ pub fn label_media(
|
||||||
fn write_media_label(
|
fn write_media_label(
|
||||||
worker: Arc<WorkerTask>,
|
worker: Arc<WorkerTask>,
|
||||||
drive: &mut Box<dyn TapeDriver>,
|
drive: &mut Box<dyn TapeDriver>,
|
||||||
label: DriveLabel,
|
label: MediaLabel,
|
||||||
pool: Option<String>,
|
pool: Option<String>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ fn barcode_label_media_worker(
|
||||||
}
|
}
|
||||||
|
|
||||||
let ctime = proxmox::tools::time::epoch_i64();
|
let ctime = proxmox::tools::time::epoch_i64();
|
||||||
let label = DriveLabel {
|
let label = MediaLabel {
|
||||||
changer_id: changer_id.to_string(),
|
changer_id: changer_id.to_string(),
|
||||||
uuid: Uuid::generate(),
|
uuid: Uuid::generate(),
|
||||||
ctime,
|
ctime,
|
||||||
|
|
|
@ -21,9 +21,9 @@ use crate::{
|
||||||
TapeWrite,
|
TapeWrite,
|
||||||
TapeRead,
|
TapeRead,
|
||||||
file_formats::{
|
file_formats::{
|
||||||
PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0,
|
PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0,
|
||||||
PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
|
PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
|
||||||
DriveLabel,
|
MediaLabel,
|
||||||
MediaSetLabel,
|
MediaSetLabel,
|
||||||
MediaContentHeader,
|
MediaContentHeader,
|
||||||
},
|
},
|
||||||
|
@ -36,7 +36,7 @@ use crate::{
|
||||||
|
|
||||||
#[derive(Serialize,Deserialize)]
|
#[derive(Serialize,Deserialize)]
|
||||||
pub struct MediaLabelInfo {
|
pub struct MediaLabelInfo {
|
||||||
pub label: DriveLabel,
|
pub label: MediaLabel,
|
||||||
pub label_uuid: Uuid,
|
pub label_uuid: Uuid,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub media_set_label: Option<(MediaSetLabel, Uuid)>
|
pub media_set_label: Option<(MediaSetLabel, Uuid)>
|
||||||
|
@ -71,7 +71,7 @@ pub trait TapeDriver {
|
||||||
/// Write label to tape (erase tape content)
|
/// Write label to tape (erase tape content)
|
||||||
///
|
///
|
||||||
/// This returns the MediaContentHeader uuid (not the media uuid).
|
/// This returns the MediaContentHeader uuid (not the media uuid).
|
||||||
fn label_tape(&mut self, label: &DriveLabel) -> Result<Uuid, Error> {
|
fn label_tape(&mut self, label: &MediaLabel) -> Result<Uuid, Error> {
|
||||||
|
|
||||||
self.rewind()?;
|
self.rewind()?;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ pub trait TapeDriver {
|
||||||
|
|
||||||
let raw = serde_json::to_string_pretty(&serde_json::to_value(&label)?)?;
|
let raw = serde_json::to_string_pretty(&serde_json::to_value(&label)?)?;
|
||||||
|
|
||||||
let header = MediaContentHeader::new(PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, raw.len() as u32);
|
let header = MediaContentHeader::new(PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, raw.len() as u32);
|
||||||
let content_uuid = header.content_uuid();
|
let content_uuid = header.content_uuid();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -112,10 +112,10 @@ pub trait TapeDriver {
|
||||||
};
|
};
|
||||||
|
|
||||||
let header: MediaContentHeader = unsafe { reader.read_le_value()? };
|
let header: MediaContentHeader = unsafe { reader.read_le_value()? };
|
||||||
header.check(PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, 1, 64*1024)?;
|
header.check(PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, 1, 64*1024)?;
|
||||||
let data = reader.read_exact_allocated(header.size as usize)?;
|
let data = reader.read_exact_allocated(header.size as usize)?;
|
||||||
|
|
||||||
let label: DriveLabel = serde_json::from_slice(&data)
|
let label: MediaLabel = serde_json::from_slice(&data)
|
||||||
.map_err(|err| format_err!("unable to parse drive label - {}", err))?;
|
.map_err(|err| format_err!("unable to parse drive label - {}", err))?;
|
||||||
|
|
||||||
// make sure we read the EOF marker
|
// make sure we read the EOF marker
|
||||||
|
@ -235,7 +235,7 @@ pub fn open_drive(
|
||||||
pub fn request_and_load_media(
|
pub fn request_and_load_media(
|
||||||
config: &SectionConfigData,
|
config: &SectionConfigData,
|
||||||
drive: &str,
|
drive: &str,
|
||||||
label: &DriveLabel,
|
label: &MediaLabel,
|
||||||
) -> Result<(
|
) -> Result<(
|
||||||
Box<dyn TapeDriver>,
|
Box<dyn TapeDriver>,
|
||||||
MediaLabelInfo,
|
MediaLabelInfo,
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub const PROXMOX_TAPE_BLOCK_HEADER_MAGIC_1_0: [u8; 8] = [220, 189, 175, 202, 23
|
||||||
// openssl::sha::sha256(b"Proxmox Backup Content Header v1.0")[0..8];
|
// openssl::sha::sha256(b"Proxmox Backup Content Header v1.0")[0..8];
|
||||||
pub const PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0: [u8; 8] = [99, 238, 20, 159, 205, 242, 155, 12];
|
pub const PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0: [u8; 8] = [99, 238, 20, 159, 205, 242, 155, 12];
|
||||||
// openssl::sha::sha256(b"Proxmox Backup Tape Label v1.0")[0..8];
|
// openssl::sha::sha256(b"Proxmox Backup Tape Label v1.0")[0..8];
|
||||||
pub const PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0: [u8; 8] = [42, 5, 191, 60, 176, 48, 170, 57];
|
pub const PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0: [u8; 8] = [42, 5, 191, 60, 176, 48, 170, 57];
|
||||||
// openssl::sha::sha256(b"Proxmox Backup MediaSet Label v1.0")
|
// openssl::sha::sha256(b"Proxmox Backup MediaSet Label v1.0")
|
||||||
pub const PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0: [u8; 8] = [8, 96, 99, 249, 47, 151, 83, 216];
|
pub const PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0: [u8; 8] = [8, 96, 99, 249, 47, 151, 83, 216];
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ lazy_static::lazy_static!{
|
||||||
/// Map content Uuid to human readable names.
|
/// Map content Uuid to human readable names.
|
||||||
pub static ref PROXMOX_BACKUP_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = {
|
pub static ref PROXMOX_BACKUP_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = {
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
map.insert(&PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, "Proxmox Backup Tape Label v1.0");
|
map.insert(&PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, "Proxmox Backup Tape Label v1.0");
|
||||||
map.insert(&PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0, "Proxmox Backup MediaSet Label v1.0");
|
map.insert(&PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0, "Proxmox Backup MediaSet Label v1.0");
|
||||||
map.insert(&PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0, "Proxmox Backup Chunk Archive v1.0");
|
map.insert(&PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0, "Proxmox Backup Chunk Archive v1.0");
|
||||||
map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0, "Proxmox Backup Snapshot Archive v1.0");
|
map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0, "Proxmox Backup Snapshot Archive v1.0");
|
||||||
|
@ -152,11 +152,11 @@ pub struct ChunkArchiveEntryHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize,Deserialize,Clone,Debug)]
|
#[derive(Serialize,Deserialize,Clone,Debug)]
|
||||||
/// Drive Label
|
/// Media Label
|
||||||
///
|
///
|
||||||
/// Drive Labels are used to uniquely identify a media. They are
|
/// Media labels are used to uniquely identify a media. They are
|
||||||
/// stored as first file on the tape.
|
/// stored as first file on the tape.
|
||||||
pub struct DriveLabel {
|
pub struct MediaLabel {
|
||||||
/// Unique ID
|
/// Unique ID
|
||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
/// Media Changer ID or Barcode
|
/// Media Changer ID or Barcode
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! The Inventory persistently stores the list of known backup
|
//! The Inventory persistently stores the list of known backup
|
||||||
//! media. A backup media is identified by its 'MediaId', which is the
|
//! media. A backup media is identified by its 'MediaId', which is the
|
||||||
//! DriveLabel/MediaSetLabel combination.
|
//! MediaLabel/MediaSetLabel combination.
|
||||||
|
|
||||||
use std::collections::{HashMap, BTreeMap};
|
use std::collections::{HashMap, BTreeMap};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -31,7 +31,7 @@ use crate::{
|
||||||
TAPE_STATUS_DIR,
|
TAPE_STATUS_DIR,
|
||||||
MediaLabelInfo,
|
MediaLabelInfo,
|
||||||
file_formats::{
|
file_formats::{
|
||||||
DriveLabel,
|
MediaLabel,
|
||||||
MediaSetLabel,
|
MediaSetLabel,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -42,7 +42,7 @@ use crate::{
|
||||||
/// This combines the label and media set label.
|
/// This combines the label and media set label.
|
||||||
#[derive(Debug,Serialize,Deserialize,Clone)]
|
#[derive(Debug,Serialize,Deserialize,Clone)]
|
||||||
pub struct MediaId {
|
pub struct MediaId {
|
||||||
pub label: DriveLabel,
|
pub label: MediaLabel,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub media_set_label: Option<MediaSetLabel>,
|
pub media_set_label: Option<MediaSetLabel>,
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ impl Inventory {
|
||||||
/// Genreate and insert a new free tape (test helper)
|
/// Genreate and insert a new free tape (test helper)
|
||||||
pub fn generate_free_tape(&mut self, changer_id: &str, ctime: i64) -> Uuid {
|
pub fn generate_free_tape(&mut self, changer_id: &str, ctime: i64) -> Uuid {
|
||||||
|
|
||||||
let label = DriveLabel {
|
let label = MediaLabel {
|
||||||
changer_id: changer_id.to_string(),
|
changer_id: changer_id.to_string(),
|
||||||
uuid: Uuid::generate(),
|
uuid: Uuid::generate(),
|
||||||
ctime,
|
ctime,
|
||||||
|
@ -580,7 +580,7 @@ impl Inventory {
|
||||||
ctime: i64,
|
ctime: i64,
|
||||||
) -> Uuid {
|
) -> Uuid {
|
||||||
|
|
||||||
let label = DriveLabel {
|
let label = MediaLabel {
|
||||||
changer_id: changer_id.to_string(),
|
changer_id: changer_id.to_string(),
|
||||||
uuid: Uuid::generate(),
|
uuid: Uuid::generate(),
|
||||||
ctime,
|
ctime,
|
||||||
|
@ -602,7 +602,7 @@ impl Inventory {
|
||||||
set: MediaSetLabel,
|
set: MediaSetLabel,
|
||||||
ctime: i64,
|
ctime: i64,
|
||||||
) -> Uuid {
|
) -> Uuid {
|
||||||
let label = DriveLabel {
|
let label = MediaLabel {
|
||||||
changer_id: changer_id.to_string(),
|
changer_id: changer_id.to_string(),
|
||||||
uuid: Uuid::generate(),
|
uuid: Uuid::generate(),
|
||||||
ctime,
|
ctime,
|
||||||
|
|
|
@ -28,7 +28,7 @@ use crate::{
|
||||||
Inventory,
|
Inventory,
|
||||||
MediaStateDatabase,
|
MediaStateDatabase,
|
||||||
file_formats::{
|
file_formats::{
|
||||||
DriveLabel,
|
MediaLabel,
|
||||||
MediaSetLabel,
|
MediaSetLabel,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ impl BackupMedia {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the drive label
|
/// Returns the drive label
|
||||||
pub fn label(&self) -> &DriveLabel {
|
pub fn label(&self) -> &MediaLabel {
|
||||||
&self.id.label
|
&self.id.label
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue