move worker_task.rs into proxmox-rest-server crate
Also moved pbs-datastore/src/task.rs to pbs-tools, which now depends on 'log'.
This commit is contained in:
@ -19,7 +19,7 @@ use pbs_api_types::{
|
||||
};
|
||||
|
||||
use crate::config::node;
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
use crate::tools::{
|
||||
apt,
|
||||
pbs_simple_http,
|
||||
|
@ -18,7 +18,7 @@ use pbs_tools::cert;
|
||||
use crate::acme::AcmeClient;
|
||||
use crate::api2::types::AcmeDomain;
|
||||
use crate::config::node::NodeConfig;
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
pub const ROUTER: Router = Router::new()
|
||||
.get(&list_subdirs_api_method!(SUBDIRS))
|
||||
|
@ -17,7 +17,7 @@ use crate::tools::disks::{
|
||||
};
|
||||
use crate::tools::systemd::{self, types::*};
|
||||
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
const BASE_MOUNT_DIR: &str = "/mnt/datastore/";
|
||||
|
||||
|
@ -15,7 +15,7 @@ use crate::tools::disks::{
|
||||
DiskUsageInfo, DiskUsageType, DiskManage, SmartData,
|
||||
get_disks, get_smart_data, get_disk_usage_info, inititialize_gpt_disk,
|
||||
};
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
pub mod directory;
|
||||
pub mod zfs;
|
||||
|
@ -19,7 +19,7 @@ use crate::tools::disks::{
|
||||
DiskUsageType,
|
||||
};
|
||||
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
|
||||
#[api(
|
||||
|
@ -24,7 +24,7 @@ use pbs_api_types::{Authid, NODE_SCHEMA, PRIV_SYS_CONSOLE};
|
||||
use pbs_tools::auth::private_auth_key;
|
||||
use pbs_tools::ticket::{self, Empty, Ticket};
|
||||
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
use crate::tools;
|
||||
|
||||
pub mod apt;
|
||||
|
@ -13,7 +13,7 @@ use pbs_api_types::{
|
||||
};
|
||||
use pbs_config::network::{self, NetworkConfig};
|
||||
|
||||
use crate::server::{WorkerTask};
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
fn split_interface_list(list: &str) -> Result<Vec<String>, Error> {
|
||||
let value = parse_property_string(&list, &NETWORK_INTERFACE_ARRAY_SCHEMA)?;
|
||||
|
@ -9,7 +9,7 @@ use proxmox::api::router::SubdirMap;
|
||||
|
||||
use pbs_api_types::{Authid, NODE_SCHEMA, SERVICE_ID_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
|
||||
|
||||
use crate::server::WorkerTask;
|
||||
use proxmox_rest_server::WorkerTask;
|
||||
|
||||
static SERVICE_NAME_LIST: [&str; 7] = [
|
||||
"proxmox-backup",
|
||||
|
@ -16,7 +16,8 @@ use pbs_api_types::{
|
||||
};
|
||||
|
||||
use crate::api2::pull::check_pull_privs;
|
||||
use crate::server::{self, upid_log_path, upid_read_status, TaskState, TaskListInfoIterator};
|
||||
|
||||
use proxmox_rest_server::{upid_log_path, upid_read_status, TaskState, TaskListInfoIterator};
|
||||
use pbs_config::CachedUserInfo;
|
||||
|
||||
// matches respective job execution privileges
|
||||
@ -125,6 +126,25 @@ pub fn tasktype(state: &TaskState) -> TaskStateType {
|
||||
}
|
||||
}
|
||||
|
||||
fn into_task_list_item(info: proxmox_rest_server::TaskListInfo) -> pbs_api_types::TaskListItem {
|
||||
let (endtime, status) = info
|
||||
.state
|
||||
.map_or_else(|| (None, None), |a| (Some(a.endtime()), Some(a.to_string())));
|
||||
|
||||
pbs_api_types::TaskListItem {
|
||||
upid: info.upid_str,
|
||||
node: "localhost".to_string(),
|
||||
pid: info.upid.pid as i64,
|
||||
pstart: info.upid.pstart,
|
||||
starttime: info.upid.starttime,
|
||||
worker_type: info.upid.worker_type,
|
||||
worker_id: info.upid.worker_id,
|
||||
user: info.upid.auth_id,
|
||||
endtime,
|
||||
status,
|
||||
}
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
@ -217,7 +237,7 @@ async fn get_task_status(
|
||||
result["tokenid"] = Value::from(task_auth_id.tokenname().unwrap().as_str());
|
||||
}
|
||||
|
||||
if crate::server::worker_is_active(&upid).await? {
|
||||
if proxmox_rest_server::worker_is_active(&upid).await? {
|
||||
result["status"] = Value::from("running");
|
||||
} else {
|
||||
let exitstatus = upid_read_status(&upid).unwrap_or(TaskState::Unknown { endtime: 0 });
|
||||
@ -314,7 +334,7 @@ async fn read_task_log(
|
||||
rpcenv["total"] = Value::from(count);
|
||||
|
||||
if test_status {
|
||||
let active = crate::server::worker_is_active(&upid).await?;
|
||||
let active = proxmox_rest_server::worker_is_active(&upid).await?;
|
||||
rpcenv["active"] = Value::from(active);
|
||||
}
|
||||
|
||||
@ -354,7 +374,7 @@ fn stop_task(
|
||||
user_info.check_privs(&auth_id, &["system", "tasks"], PRIV_SYS_MODIFY, false)?;
|
||||
}
|
||||
|
||||
server::abort_worker_async(upid);
|
||||
proxmox_rest_server::abort_worker_async(upid);
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
@ -502,7 +522,7 @@ pub fn list_tasks(
|
||||
|
||||
match (&info.state, &statusfilter) {
|
||||
(Some(_), _) if running => continue,
|
||||
(Some(crate::server::TaskState::OK { .. }), _) if errors => continue,
|
||||
(Some(TaskState::OK { .. }), _) if errors => continue,
|
||||
(Some(state), Some(filters)) => {
|
||||
if !filters.contains(&tasktype(state)) {
|
||||
continue;
|
||||
@ -517,7 +537,7 @@ pub fn list_tasks(
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(info.into());
|
||||
result.push(into_task_list_item(info));
|
||||
|
||||
if result.len() >= limit {
|
||||
break;
|
||||
|
Reference in New Issue
Block a user