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:
parent
ad72fda1d6
commit
68b6c1202c
|
@ -101,7 +101,7 @@ proxmox-router = { version = "1.1", features = [ "cli" ] }
|
|||
proxmox-schema = { version = "1", features = [ "api-macro" ] }
|
||||
proxmox-section-config = "1"
|
||||
proxmox-tfa = { version = "2", features = [ "api", "api-types" ] }
|
||||
proxmox-time = "1"
|
||||
proxmox-time = "1.1.1"
|
||||
proxmox-uuid = "1"
|
||||
proxmox-serde = "0.1"
|
||||
proxmox-shared-memory = "0.2"
|
||||
|
|
|
@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
proxmox-lang = "1.0.0"
|
||||
proxmox-schema = { version = "1.0.1", features = [ "api-macro" ] }
|
||||
proxmox-serde = "0.1"
|
||||
proxmox-time = "1.1"
|
||||
proxmox-time = "1.1.1"
|
||||
proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
|
||||
|
||||
proxmox-sys = "0.2" # only needed for nodename()??
|
||||
|
|
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
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::{
|
||||
PROXMOX_SAFE_ID_FORMAT,
|
||||
|
@ -62,7 +62,7 @@ impl std::str::FromStr for MediaSetPolicy {
|
|||
return Ok(MediaSetPolicy::AlwaysCreate);
|
||||
}
|
||||
|
||||
let event = parse_calendar_event(s)?;
|
||||
let event = s.parse()?;
|
||||
|
||||
Ok(MediaSetPolicy::CreateAt(event))
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl std::str::FromStr for RetentionPolicy {
|
|||
return Ok(RetentionPolicy::KeepForever);
|
||||
}
|
||||
|
||||
let time_span = parse_time_span(s)?;
|
||||
let time_span = s.parse()?;
|
||||
|
||||
Ok(RetentionPolicy::ProtectFor(time_span))
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ use proxmox_backup::{
|
|||
};
|
||||
|
||||
use pbs_buildcfg::configdir;
|
||||
use proxmox_time::{compute_next_event, parse_calendar_event};
|
||||
use proxmox_time::CalendarEvent;
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, TapeBackupJobConfig, VerificationJobConfig, SyncJobConfig, DataStoreConfig,
|
||||
|
@ -565,7 +565,7 @@ async fn schedule_datastore_garbage_collection() {
|
|||
None => continue,
|
||||
};
|
||||
|
||||
let event = match parse_calendar_event(&event_str) {
|
||||
let event: CalendarEvent = match event_str.parse() {
|
||||
Ok(event) => event,
|
||||
Err(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(None) => continue,
|
||||
Err(err) => {
|
||||
|
@ -1024,7 +1024,7 @@ fn generate_host_stats_sync() {
|
|||
}
|
||||
|
||||
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,
|
||||
Err(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(None) => return false,
|
||||
Err(err) => {
|
||||
|
|
|
@ -46,7 +46,7 @@ use proxmox_sys::fs::{
|
|||
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_config::{open_backup_lockfile, BackupLockGuard};
|
||||
|
@ -339,9 +339,9 @@ pub fn compute_schedule_status(
|
|||
status.last_run_endtime = endtime;
|
||||
|
||||
if let Some(schedule) = schedule {
|
||||
if let Ok(event) = parse_calendar_event(&schedule) {
|
||||
if let Ok(event) = schedule.parse::<CalendarEvent>() {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ use serde_json::json;
|
|||
use proxmox_sys::fs::{replace_file, file_get_json, CreateOptions};
|
||||
use proxmox_uuid::Uuid;
|
||||
|
||||
use proxmox_time::compute_next_event;
|
||||
use pbs_config::BackupLockGuard;
|
||||
use pbs_api_types::{MediaSetPolicy, RetentionPolicy, MediaStatus, MediaLocation};
|
||||
|
||||
|
@ -534,7 +533,7 @@ impl Inventory {
|
|||
set_start_time
|
||||
}
|
||||
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(None) | Err(_) => return i64::MAX,
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ use pbs_api_types::{
|
|||
Fingerprint, MediaStatus, MediaLocation, MediaSetPolicy, RetentionPolicy,
|
||||
MediaPoolConfig,
|
||||
};
|
||||
use proxmox_time::compute_next_event;
|
||||
use pbs_config::BackupLockGuard;
|
||||
|
||||
use crate::tape::{
|
||||
|
@ -291,7 +290,7 @@ impl MediaPool {
|
|||
}
|
||||
MediaSetPolicy::CreateAt(event) => {
|
||||
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 {
|
||||
create_new_set = Some(String::from("policy CreateAt event triggered"));
|
||||
}
|
||||
|
|
|
@ -100,8 +100,8 @@ fn test_media_expire_time() -> Result<(), Error> {
|
|||
let sl2= MediaSetLabel::with_data("p1", Uuid::generate(), 0, ctime + 120, None);
|
||||
let tape2_uuid = inventory.generate_used_tape("tape2", sl2, 0);
|
||||
|
||||
let event = proxmox_time::parse_calendar_event("*:0/2")?;
|
||||
let span = proxmox_time::parse_time_span("120 seconds")?;
|
||||
let event = "*:0/2".parse()?;
|
||||
let span = "120 seconds".parse()?;
|
||||
|
||||
let pool = MediaPool::new(
|
||||
"p1",
|
||||
|
|
Loading…
Reference in New Issue