diff --git a/src/api2/tape/media.rs b/src/api2/tape/media.rs index 683ff1b93..ee5afb800 100644 --- a/src/api2/tape/media.rs +++ b/src/api2/tape/media.rs @@ -91,13 +91,13 @@ pub async fn list_media(pool: Option) -> Result, Err for media in pool.list_media() { let expired = pool.media_is_expired(&media, current_time); - let media_set_uuid = media.media_set_label().as_ref() + let media_set_uuid = media.media_set_label() .map(|set| set.uuid.to_string()); - let seq_nr = media.media_set_label().as_ref() + let seq_nr = media.media_set_label() .map(|set| set.seq_nr); - let media_set_name = media.media_set_label().as_ref() + let media_set_name = media.media_set_label() .map(|set| { pool.generate_media_set_name(&set.uuid, config.template.clone()) .unwrap_or_else(|_| set.uuid.to_string()) @@ -113,11 +113,13 @@ pub async fn list_media(pool: Option) -> Result, Err list.push(MediaListEntry { uuid: media.uuid().to_string(), changer_id: media.changer_id().to_string(), + ctime: media.ctime(), pool: Some(pool_name.to_string()), location: media.location().clone(), status: *media.status(), catalog: catalog_ok, expired, + media_set_ctime: media.media_set_label().map(|set| set.ctime), media_set_uuid, media_set_name, seq_nr, @@ -139,6 +141,7 @@ pub async fn list_media(pool: Option) -> Result, Err list.push(MediaListEntry { uuid: media_id.label.uuid.to_string(), + ctime: media_id.label.ctime, changer_id: media_id.label.changer_id.to_string(), location, status, @@ -146,6 +149,7 @@ pub async fn list_media(pool: Option) -> Result, Err expired: false, media_set_uuid: None, media_set_name: None, + media_set_ctime: None, seq_nr: None, pool: None, }); diff --git a/src/api2/types/tape/media.rs b/src/api2/types/tape/media.rs index 4df5a6714..da030aab2 100644 --- a/src/api2/types/tape/media.rs +++ b/src/api2/types/tape/media.rs @@ -25,6 +25,8 @@ pub struct MediaListEntry { pub changer_id: String, /// Media Uuid pub uuid: String, + /// Creation time stamp + pub ctime: i64, pub location: MediaLocation, pub status: MediaStatus, /// Expired flag @@ -40,6 +42,9 @@ pub struct MediaListEntry { /// Media set seq_nr #[serde(skip_serializing_if="Option::is_none")] pub seq_nr: Option, + /// MediaSet creation time stamp + #[serde(skip_serializing_if="Option::is_none")] + pub media_set_ctime: Option, /// Media Pool #[serde(skip_serializing_if="Option::is_none")] pub pool: Option, diff --git a/src/tape/media_pool.rs b/src/tape/media_pool.rs index d26200d0e..80760edb0 100644 --- a/src/tape/media_pool.rs +++ b/src/tape/media_pool.rs @@ -469,8 +469,13 @@ impl BackupMedia { } /// Returns the media set label - pub fn media_set_label(&self) -> &Option { - &self.id.media_set_label + pub fn media_set_label(&self) -> Option<&MediaSetLabel> { + self.id.media_set_label.as_ref() + } + + /// Returns the media creation time + pub fn ctime(&self) -> i64 { + self.id.label.ctime } /// Updates the media set label