remove use of deprecated functions from proxmox-time

Depend on proxmox-time 1.1.1

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-11-30 13:12:09 +01:00 committed by Dietmar Maurer
parent ad72fda1d6
commit 68b6c1202c
8 changed files with 17 additions and 19 deletions

View File

@ -101,7 +101,7 @@ proxmox-router = { version = "1.1", features = [ "cli" ] }
proxmox-schema = { version = "1", features = [ "api-macro" ] } proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-section-config = "1" proxmox-section-config = "1"
proxmox-tfa = { version = "2", features = [ "api", "api-types" ] } proxmox-tfa = { version = "2", features = [ "api", "api-types" ] }
proxmox-time = "1" proxmox-time = "1.1.1"
proxmox-uuid = "1" proxmox-uuid = "1"
proxmox-serde = "0.1" proxmox-serde = "0.1"
proxmox-shared-memory = "0.2" proxmox-shared-memory = "0.2"

View File

@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] }
proxmox-lang = "1.0.0" proxmox-lang = "1.0.0"
proxmox-schema = { version = "1.0.1", features = [ "api-macro" ] } proxmox-schema = { version = "1.0.1", features = [ "api-macro" ] }
proxmox-serde = "0.1" proxmox-serde = "0.1"
proxmox-time = "1.1" proxmox-time = "1.1.1"
proxmox-uuid = { version = "1.0.0", features = [ "serde" ] } proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
proxmox-sys = "0.2" # only needed for nodename()?? proxmox-sys = "0.2" # only needed for nodename()??

View File

@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
use proxmox_schema::{api, Schema, StringSchema, ApiStringFormat, Updater}; use proxmox_schema::{api, Schema, StringSchema, ApiStringFormat, Updater};
use proxmox_time::{parse_calendar_event, parse_time_span, CalendarEvent, TimeSpan}; use proxmox_time::{CalendarEvent, TimeSpan};
use crate::{ use crate::{
PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_FORMAT,
@ -62,7 +62,7 @@ impl std::str::FromStr for MediaSetPolicy {
return Ok(MediaSetPolicy::AlwaysCreate); return Ok(MediaSetPolicy::AlwaysCreate);
} }
let event = parse_calendar_event(s)?; let event = s.parse()?;
Ok(MediaSetPolicy::CreateAt(event)) Ok(MediaSetPolicy::CreateAt(event))
} }
@ -97,7 +97,7 @@ impl std::str::FromStr for RetentionPolicy {
return Ok(RetentionPolicy::KeepForever); return Ok(RetentionPolicy::KeepForever);
} }
let time_span = parse_time_span(s)?; let time_span = s.parse()?;
Ok(RetentionPolicy::ProtectFor(time_span)) Ok(RetentionPolicy::ProtectFor(time_span))
} }

View File

@ -47,7 +47,7 @@ use proxmox_backup::{
}; };
use pbs_buildcfg::configdir; use pbs_buildcfg::configdir;
use proxmox_time::{compute_next_event, parse_calendar_event}; use proxmox_time::CalendarEvent;
use pbs_api_types::{ use pbs_api_types::{
Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig, DataStoreConfig, Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig, DataStoreConfig,
@ -565,7 +565,7 @@ async fn schedule_datastore_garbage_collection() {
None => continue, None => continue,
}; };
let event = match parse_calendar_event(&event_str) { let event: CalendarEvent = match event_str.parse() {
Ok(event) => event, Ok(event) => event,
Err(err) => { Err(err) => {
eprintln!("unable to parse schedule '{}' - {}", event_str, err); eprintln!("unable to parse schedule '{}' - {}", event_str, err);
@ -585,7 +585,7 @@ async fn schedule_datastore_garbage_collection() {
} }
}; };
let next = match compute_next_event(&event, last, false) { let next = match event.compute_next_event(last, false) {
Ok(Some(next)) => next, Ok(Some(next)) => next,
Ok(None) => continue, Ok(None) => continue,
Err(err) => { Err(err) => {
@ -1024,7 +1024,7 @@ fn generate_host_stats_sync() {
} }
fn check_schedule(worker_type: &str, event_str: &str, id: &str) -> bool { fn check_schedule(worker_type: &str, event_str: &str, id: &str) -> bool {
let event = match parse_calendar_event(event_str) { let event: CalendarEvent = match event_str.parse() {
Ok(event) => event, Ok(event) => event,
Err(err) => { Err(err) => {
eprintln!("unable to parse schedule '{}' - {}", event_str, err); eprintln!("unable to parse schedule '{}' - {}", event_str, err);
@ -1040,7 +1040,7 @@ fn check_schedule(worker_type: &str, event_str: &str, id: &str) -> bool {
} }
}; };
let next = match compute_next_event(&event, last, false) { let next = match event.compute_next_event(last, false) {
Ok(Some(next)) => next, Ok(Some(next)) => next,
Ok(None) => return false, Ok(None) => return false,
Err(err) => { Err(err) => {

View File

@ -46,7 +46,7 @@ use proxmox_sys::fs::{
create_path, file_read_optional_string, replace_file, CreateOptions, create_path, file_read_optional_string, replace_file, CreateOptions,
}; };
use proxmox_time::{compute_next_event, parse_calendar_event}; use proxmox_time::CalendarEvent;
use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M; use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M;
use pbs_config::{open_backup_lockfile, BackupLockGuard}; use pbs_config::{open_backup_lockfile, BackupLockGuard};
@ -339,9 +339,9 @@ pub fn compute_schedule_status(
status.last_run_endtime = endtime; status.last_run_endtime = endtime;
if let Some(schedule) = schedule { if let Some(schedule) = schedule {
if let Ok(event) = parse_calendar_event(&schedule) { if let Ok(event) = schedule.parse::<CalendarEvent>() {
// ignore errors // ignore errors
status.next_run = compute_next_event(&event, last, false).unwrap_or(None); status.next_run = event.compute_next_event(last, false).unwrap_or(None);
} }
} }

View File

@ -33,7 +33,6 @@ use serde_json::json;
use proxmox_sys::fs::{replace_file, file_get_json, CreateOptions}; use proxmox_sys::fs::{replace_file, file_get_json, CreateOptions};
use proxmox_uuid::Uuid; use proxmox_uuid::Uuid;
use proxmox_time::compute_next_event;
use pbs_config::BackupLockGuard; use pbs_config::BackupLockGuard;
use pbs_api_types::{MediaSetPolicy, RetentionPolicy, MediaStatus, MediaLocation}; use pbs_api_types::{MediaSetPolicy, RetentionPolicy, MediaStatus, MediaLocation};
@ -534,7 +533,7 @@ impl Inventory {
set_start_time set_start_time
} }
MediaSetPolicy::CreateAt(ref event) => { MediaSetPolicy::CreateAt(ref event) => {
match compute_next_event(event, set_start_time, false) { match event.compute_next_event(set_start_time, false) {
Ok(Some(next)) => next, Ok(Some(next)) => next,
Ok(None) | Err(_) => return i64::MAX, Ok(None) | Err(_) => return i64::MAX,
} }

View File

@ -18,7 +18,6 @@ use pbs_api_types::{
Fingerprint, MediaStatus, MediaLocation, MediaSetPolicy, RetentionPolicy, Fingerprint, MediaStatus, MediaLocation, MediaSetPolicy, RetentionPolicy,
MediaPoolConfig, MediaPoolConfig,
}; };
use proxmox_time::compute_next_event;
use pbs_config::BackupLockGuard; use pbs_config::BackupLockGuard;
use crate::tape::{ use crate::tape::{
@ -291,7 +290,7 @@ impl MediaPool {
} }
MediaSetPolicy::CreateAt(event) => { MediaSetPolicy::CreateAt(event) => {
if let Some(set_start_time) = self.inventory.media_set_start_time(&self.current_media_set.uuid()) { if let Some(set_start_time) = self.inventory.media_set_start_time(&self.current_media_set.uuid()) {
if let Ok(Some(alloc_time)) = compute_next_event(event, set_start_time as i64, false) { if let Ok(Some(alloc_time)) = event.compute_next_event(set_start_time as i64, false) {
if current_time >= alloc_time { if current_time >= alloc_time {
create_new_set = Some(String::from("policy CreateAt event triggered")); create_new_set = Some(String::from("policy CreateAt event triggered"));
} }

View File

@ -100,8 +100,8 @@ fn test_media_expire_time() -> Result<(), Error> {
let sl2= MediaSetLabel::with_data("p1", Uuid::generate(), 0, ctime + 120, None); let sl2= MediaSetLabel::with_data("p1", Uuid::generate(), 0, ctime + 120, None);
let tape2_uuid = inventory.generate_used_tape("tape2", sl2, 0); let tape2_uuid = inventory.generate_used_tape("tape2", sl2, 0);
let event = proxmox_time::parse_calendar_event("*:0/2")?; let event = "*:0/2".parse()?;
let span = proxmox_time::parse_time_span("120 seconds")?; let span = "120 seconds".parse()?;
let pool = MediaPool::new( let pool = MediaPool::new(
"p1", "p1",