update to first proxmox crate split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-10-08 11:19:37 +02:00
parent 6ad1bcaf89
commit 09046671ed
11 changed files with 33 additions and 26 deletions

View File

@ -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" }

View File

@ -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

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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!
};

View File

@ -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);

View File

@ -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::*;

View File

@ -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::*;

View File

@ -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!(

View File

@ -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<TaskState, Error> {
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 }