diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml index 2af3ba35..a00986cf 100644 --- a/proxmox-rest-server/Cargo.toml +++ b/proxmox-rest-server/Cargo.toml @@ -7,7 +7,7 @@ description = "REST server implementation" # for example [dev-dependencies] -proxmox = { version = "0.14.0", features = ["router","api-macro"] } +proxmox-schema = { version = "1", features = [ "api-macro" ] } tokio = { version = "1.6", features = [ "rt-multi-thread", "signal", "process" ] } [dependencies] @@ -30,7 +30,12 @@ tokio-openssl = "0.6.1" tower-service = "0.3.0" url = "2.1" -proxmox = { version = "0.14.0", features = [ "router"] } +proxmox = "0.14.0" +proxmox-io = "1" +proxmox-lang = "1" +proxmox-router = "1" +proxmox-schema = { version = "1", features = [ "api-macro", "upid-api-impl" ] } +proxmox-time = "1" # fixme: remove this dependency (pbs_tools::broadcast_future) pbs-tools = { path = "../pbs-tools" } diff --git a/proxmox-rest-server/examples/minimal-rest-server.rs b/proxmox-rest-server/examples/minimal-rest-server.rs index 6400fdbf..1ddcfeb8 100644 --- a/proxmox-rest-server/examples/minimal-rest-server.rs +++ b/proxmox-rest-server/examples/minimal-rest-server.rs @@ -9,8 +9,9 @@ use hyper::{Body, Response, Method}; use http::request::Parts; use http::HeaderMap; -use proxmox::api::{api, router::SubdirMap, Router, RpcEnvironmentType, UserInformation}; -use proxmox::list_subdirs_api_method; +use proxmox_schema::api; +use proxmox_router::{list_subdirs_api_method, SubdirMap, Router, RpcEnvironmentType, UserInformation}; + use proxmox_rest_server::{ServerAdapter, ApiConfig, AuthError, RestServer, RestEnvironment}; // Create a Dummy User information system diff --git a/proxmox-rest-server/src/api_config.rs b/proxmox-rest-server/src/api_config.rs index 99990114..990315dd 100644 --- a/proxmox-rest-server/src/api_config.rs +++ b/proxmox-rest-server/src/api_config.rs @@ -12,8 +12,8 @@ use hyper::http::request::Parts; use handlebars::Handlebars; use serde::Serialize; -use proxmox::api::{ApiMethod, Router, RpcEnvironmentType, UserInformation}; use proxmox::tools::fs::{create_path, CreateOptions}; +use proxmox_router::{ApiMethod, Router, RpcEnvironmentType, UserInformation}; use crate::{ServerAdapter, AuthError, FileLogger, FileLogOptions, CommandSocket, RestEnvironment}; diff --git a/proxmox-rest-server/src/daemon.rs b/proxmox-rest-server/src/daemon.rs index d5ed86b1..cbaaaa7b 100644 --- a/proxmox-rest-server/src/daemon.rs +++ b/proxmox-rest-server/src/daemon.rs @@ -13,8 +13,8 @@ use anyhow::{bail, format_err, Error}; use futures::future::{self, Either}; use nix::unistd::{fork, ForkResult}; -use proxmox::tools::io::{ReadExt, WriteExt}; use proxmox::tools::fd::Fd; +use proxmox_io::{ReadExt, WriteExt}; use pbs_tools::fd::fd_change_cloexec; diff --git a/proxmox-rest-server/src/environment.rs b/proxmox-rest-server/src/environment.rs index 57d0d7d5..3c77d145 100644 --- a/proxmox-rest-server/src/environment.rs +++ b/proxmox-rest-server/src/environment.rs @@ -3,7 +3,7 @@ use std::net::SocketAddr; use serde_json::{json, Value}; -use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; +use proxmox_router::{RpcEnvironment, RpcEnvironmentType}; use crate::ApiConfig; diff --git a/proxmox-rest-server/src/file_logger.rs b/proxmox-rest-server/src/file_logger.rs index b3d5eb20..79972d32 100644 --- a/proxmox-rest-server/src/file_logger.rs +++ b/proxmox-rest-server/src/file_logger.rs @@ -110,8 +110,8 @@ impl FileLogger { } let line = if self.options.prefix_time { - let now = proxmox::tools::time::epoch_i64(); - let rfc3339 = match proxmox::tools::time::epoch_to_rfc3339(now) { + let now = proxmox_time::epoch_i64(); + let rfc3339 = match proxmox_time::epoch_to_rfc3339(now) { Ok(rfc3339) => rfc3339, Err(_) => "1970-01-01T00:00:00Z".into(), // for safety, should really not happen! }; diff --git a/proxmox-rest-server/src/formatter.rs b/proxmox-rest-server/src/formatter.rs index 601a7561..6d050997 100644 --- a/proxmox-rest-server/src/formatter.rs +++ b/proxmox-rest-server/src/formatter.rs @@ -6,7 +6,8 @@ use serde_json::{json, Value}; use hyper::{Body, Response, StatusCode}; use hyper::header; -use proxmox::api::{HttpError, schema::ParameterError, RpcEnvironment}; +use proxmox_router::{HttpError, RpcEnvironment}; +use proxmox_schema::ParameterError; /// Extension to set error message for server side logging pub(crate) struct ErrorMessageExtension(pub String); diff --git a/proxmox-rest-server/src/h2service.rs b/proxmox-rest-server/src/h2service.rs index f7c7b978..f5fcdeea 100644 --- a/proxmox-rest-server/src/h2service.rs +++ b/proxmox-rest-server/src/h2service.rs @@ -8,8 +8,8 @@ use std::task::{Context, Poll}; use futures::*; use hyper::{Body, Request, Response, StatusCode}; -use proxmox::api::{ApiResponseFuture, HttpError, Router, RpcEnvironment}; -use proxmox::http_err; +use proxmox_router::{ApiResponseFuture, HttpError, Router, RpcEnvironment}; +use proxmox_router::http_err; use crate::{normalize_uri_path, WorkerTask}; use crate::formatter::*; diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs index d72936c2..6e7c94f2 100644 --- a/proxmox-rest-server/src/lib.rs +++ b/proxmox-rest-server/src/lib.rs @@ -27,8 +27,8 @@ use http::HeaderMap; use proxmox::tools::fd::Fd; use proxmox::sys::linux::procfs::PidStat; -use proxmox::api::UserInformation; use proxmox::tools::fs::CreateOptions; +use proxmox_router::UserInformation; mod compression; pub use compression::*; diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index 063b797f..74bc8bb1 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -21,15 +21,15 @@ use tokio::time::Instant; use url::form_urlencoded; use tower_service::Service; -use proxmox::api::schema::{ - parse_parameter_strings, parse_simple_value, verify_json_object, ObjectSchemaType, - ParameterSchema, -}; -use proxmox::api::{ +use proxmox_router::{ check_api_permission, ApiHandler, ApiMethod, HttpError, Permission, RpcEnvironment, RpcEnvironmentType, UserInformation, }; -use proxmox::http_err; +use proxmox_router::http_err; +use proxmox_schema::{ + parse_parameter_strings, parse_simple_value, verify_json_object, ObjectSchemaType, + ParameterSchema, +}; use pbs_tools::compression::{DeflateEncoder, Level}; use pbs_tools::stream::AsyncReaderStream; @@ -192,9 +192,9 @@ fn log_response( Some(AuthStringExtension(auth_id)) => auth_id.clone(), None => "-".to_string(), }; - let now = proxmox::tools::time::epoch_i64(); + let now = proxmox_time::epoch_i64(); // time format which apache/nginx use (by default), copied from pve-http-server - let datetime = proxmox::tools::time::strftime_local("%d/%m/%Y:%H:%M:%S %z", now) + let datetime = proxmox_time::strftime_local("%d/%m/%Y:%H:%M:%S %z", now) .unwrap_or_else(|_| "-".to_string()); logfile.lock().unwrap().log(format!( diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index 51394549..fb0dea9b 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -17,9 +17,9 @@ use nix::fcntl::OFlag; use once_cell::sync::OnceCell; use proxmox::sys::linux::procfs; -use proxmox::try_block; use proxmox::tools::fs::{create_path, replace_file, atomic_open_or_create_file, CreateOptions}; -use proxmox::api::upid::UPID; +use proxmox_lang::try_block; +use proxmox_schema::upid::UPID; use pbs_tools::task::WorkerTaskContext; use pbs_tools::logrotate::{LogRotate, LogRotateFiles}; @@ -120,7 +120,7 @@ impl WorkerTaskSetup { if !worker_is_active_local(&info.upid) { // println!("Detected stopped task '{}'", &info.upid_str); - let now = proxmox::tools::time::epoch_i64(); + let now = proxmox_time::epoch_i64(); let status = upid_read_status(&info.upid).unwrap_or(TaskState::Unknown { endtime: now }); finish_list.push(TaskListInfo { upid: info.upid, @@ -320,7 +320,7 @@ pub fn upid_read_status(upid: &UPID) -> Result { let mut iter = last_line.splitn(2, ": "); if let Some(time_str) = iter.next() { - if let Ok(endtime) = proxmox::tools::time::parse_rfc3339(time_str) { + if let Ok(endtime) = proxmox_time::parse_rfc3339(time_str) { // set the endtime even if we cannot parse the state status = TaskState::Unknown { endtime }; if let Some(rest) = iter.next().and_then(|rest| rest.strip_prefix("TASK ")) { @@ -839,7 +839,7 @@ impl WorkerTask { pub fn create_state(&self, result: &Result<(), Error>) -> TaskState { let warn_count = self.data.lock().unwrap().warn_count; - let endtime = proxmox::tools::time::epoch_i64(); + let endtime = proxmox_time::epoch_i64(); if let Err(err) = result { TaskState::Error { message: err.to_string(), endtime }