tape: rename changer_id to label_text
This commit is contained in:
@ -269,7 +269,7 @@ pub fn request_and_load_media(
|
||||
if let Ok(Some(media_id)) = handle.read_label() {
|
||||
worker.log(format!(
|
||||
"found media label {} ({})",
|
||||
media_id.label.changer_id,
|
||||
media_id.label.label_text,
|
||||
media_id.label.uuid.to_string(),
|
||||
));
|
||||
if media_id.label.uuid == *uuid {
|
||||
@ -285,9 +285,9 @@ pub fn request_and_load_media(
|
||||
"virtual" => {
|
||||
let mut tape = VirtualTapeDrive::deserialize(config)?;
|
||||
|
||||
let changer_id = label.changer_id.clone();
|
||||
let label_text = label.label_text.clone();
|
||||
|
||||
tape.load_media(&changer_id)?;
|
||||
tape.load_media(&label_text)?;
|
||||
|
||||
let mut handle: Box<dyn TapeDriver> = Box::new(tape.open()?);
|
||||
|
||||
@ -298,12 +298,12 @@ pub fn request_and_load_media(
|
||||
"linux" => {
|
||||
let drive_config = LinuxTapeDrive::deserialize(config)?;
|
||||
|
||||
let changer_id = label.changer_id.clone();
|
||||
let label_text = label.label_text.clone();
|
||||
|
||||
if drive_config.changer.is_some() {
|
||||
|
||||
let mut changer = MtxMediaChanger::with_drive_config(&drive_config)?;
|
||||
changer.load_media(&changer_id)?;
|
||||
changer.load_media(&label_text)?;
|
||||
|
||||
let mut handle: Box<dyn TapeDriver> = Box::new(drive_config.open()?);
|
||||
|
||||
@ -312,11 +312,11 @@ pub fn request_and_load_media(
|
||||
return Ok((handle, media_id));
|
||||
}
|
||||
|
||||
worker.log(format!("Please insert media '{}' into drive '{}'", changer_id, drive));
|
||||
worker.log(format!("Please insert media '{}' into drive '{}'", label_text, drive));
|
||||
|
||||
let to = "root@localhost"; // fixme
|
||||
|
||||
send_load_media_email(drive, &changer_id, to)?;
|
||||
send_load_media_email(drive, &label_text, to)?;
|
||||
|
||||
let mut last_media_uuid = None;
|
||||
let mut last_error = None;
|
||||
@ -340,7 +340,7 @@ pub fn request_and_load_media(
|
||||
if media_id.label.uuid == label.uuid {
|
||||
worker.log(format!(
|
||||
"found media label {} ({})",
|
||||
media_id.label.changer_id,
|
||||
media_id.label.label_text,
|
||||
media_id.label.uuid.to_string(),
|
||||
));
|
||||
return Ok((Box::new(handle), media_id));
|
||||
@ -348,7 +348,7 @@ pub fn request_and_load_media(
|
||||
if Some(media_id.label.uuid.clone()) != last_media_uuid {
|
||||
worker.log(format!(
|
||||
"wrong media label {} ({})",
|
||||
media_id.label.changer_id,
|
||||
media_id.label.label_text,
|
||||
media_id.label.uuid.to_string(),
|
||||
));
|
||||
last_media_uuid = Some(media_id.label.uuid);
|
||||
|
@ -157,7 +157,7 @@ impl VirtualTapeHandle {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn online_media_changer_ids(&self) -> Result<Vec<String>, Error> {
|
||||
fn online_media_label_texts(&self) -> Result<Vec<String>, Error> {
|
||||
let mut list = Vec::new();
|
||||
for entry in std::fs::read_dir(&self.path)? {
|
||||
let entry = entry?;
|
||||
@ -389,12 +389,12 @@ impl MediaChange for VirtualTapeHandle {
|
||||
// slot-assignment here.
|
||||
|
||||
let mut slots = Vec::new();
|
||||
let changer_ids = self.online_media_changer_ids()?;
|
||||
let max_slots = ((changer_ids.len() + 7)/8) * 8;
|
||||
let label_texts = self.online_media_label_texts()?;
|
||||
let max_slots = ((label_texts.len() + 7)/8) * 8;
|
||||
|
||||
for i in 0..max_slots {
|
||||
if let Some(changer_id) = changer_ids.get(i) {
|
||||
slots.push((false, ElementStatus::VolumeTag(changer_id.clone())));
|
||||
if let Some(label_text) = label_texts.get(i) {
|
||||
slots.push((false, ElementStatus::VolumeTag(label_text.clone())));
|
||||
} else {
|
||||
slots.push((false, ElementStatus::Empty));
|
||||
}
|
||||
@ -407,7 +407,7 @@ impl MediaChange for VirtualTapeHandle {
|
||||
bail!("media tranfer is not implemented!");
|
||||
}
|
||||
|
||||
fn export_media(&mut self, _changer_id: &str) -> Result<Option<u64>, Error> {
|
||||
fn export_media(&mut self, _label_text: &str) -> Result<Option<u64>, Error> {
|
||||
bail!("media export is not implemented!");
|
||||
}
|
||||
|
||||
@ -416,13 +416,13 @@ impl MediaChange for VirtualTapeHandle {
|
||||
bail!("invalid slot ID {}", slot);
|
||||
}
|
||||
|
||||
let changer_ids = self.online_media_changer_ids()?;
|
||||
let label_texts = self.online_media_label_texts()?;
|
||||
|
||||
if slot > changer_ids.len() as u64 {
|
||||
if slot > label_texts.len() as u64 {
|
||||
bail!("slot {} is empty", slot);
|
||||
}
|
||||
|
||||
self.load_media(&changer_ids[slot as usize - 1])
|
||||
self.load_media(&label_texts[slot as usize - 1])
|
||||
}
|
||||
|
||||
/// Try to load media
|
||||
@ -479,9 +479,9 @@ impl MediaChange for VirtualTapeDrive {
|
||||
handle.transfer_media(from, to)
|
||||
}
|
||||
|
||||
fn export_media(&mut self, changer_id: &str) -> Result<Option<u64>, Error> {
|
||||
fn export_media(&mut self, label_text: &str) -> Result<Option<u64>, Error> {
|
||||
let mut handle = self.open()?;
|
||||
handle.export_media(changer_id)
|
||||
handle.export_media(label_text)
|
||||
}
|
||||
|
||||
fn load_media_from_slot(&mut self, slot: u64) -> Result<(), Error> {
|
||||
@ -489,9 +489,9 @@ impl MediaChange for VirtualTapeDrive {
|
||||
handle.load_media_from_slot(slot)
|
||||
}
|
||||
|
||||
fn load_media(&mut self, changer_id: &str) -> Result<(), Error> {
|
||||
fn load_media(&mut self, label_text: &str) -> Result<(), Error> {
|
||||
let mut handle = self.open()?;
|
||||
handle.load_media(changer_id)
|
||||
handle.load_media(label_text)
|
||||
}
|
||||
|
||||
fn unload_media(&mut self, target_slot: Option<u64>) -> Result<(), Error> {
|
||||
@ -500,9 +500,9 @@ impl MediaChange for VirtualTapeDrive {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn online_media_changer_ids(&mut self) -> Result<Vec<String>, Error> {
|
||||
fn online_media_label_texts(&mut self) -> Result<Vec<String>, Error> {
|
||||
let handle = self.open()?;
|
||||
handle.online_media_changer_ids()
|
||||
handle.online_media_label_texts()
|
||||
}
|
||||
|
||||
fn clean_drive(&mut self) -> Result<(), Error> {
|
||||
|
Reference in New Issue
Block a user