]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/api2/node/services.rs
move worker_task.rs into proxmox-rest-server crate
[proxmox-backup.git] / src / api2 / node / services.rs
index 4c2a17b42ff7389c0eb555e2a3fa03ce6ac34a6f..8df0fb24b9d59b075aa375b015b5eeac1921050e 100644 (file)
@@ -6,11 +6,10 @@ use serde_json::{json, Value};
 use proxmox::{sortable, identity, list_subdirs_api_method};
 use proxmox::api::{api, Router, Permission, RpcEnvironment};
 use proxmox::api::router::SubdirMap;
-use proxmox::api::schema::*;
 
-use crate::api2::types::*;
-use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
-use crate::server::WorkerTask;
+use pbs_api_types::{Authid, NODE_SCHEMA, SERVICE_ID_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
+
+use proxmox_rest_server::WorkerTask;
 
 static SERVICE_NAME_LIST: [&str; 7] = [
     "proxmox-backup",
@@ -22,7 +21,7 @@ static SERVICE_NAME_LIST: [&str; 7] = [
     "systemd-timesyncd",
 ];
 
-fn real_service_name(service: &str) -> &str {
+pub fn real_service_name(service: &str) -> &str {
 
     // since postfix package 3.1.0-3.1 the postfix unit is only here
     // to manage subinstances, of which the default is called "-".
@@ -196,7 +195,7 @@ fn run_service_command(service: &str, cmd: &str, auth_id: Authid) -> Result<Valu
     let upid = WorkerTask::new_thread(
         &workerid,
         Some(service.clone()),
-        auth_id,
+        auth_id.to_string(),
         false,
         move |_worker| {
 
@@ -346,11 +345,6 @@ fn reload_service(
     run_service_command(&service, "reload", auth_id)
 }
 
-
-const SERVICE_ID_SCHEMA: Schema = StringSchema::new("Service ID.")
-    .max_length(256)
-    .schema();
-
 #[sortable]
 const SERVICE_SUBDIRS: SubdirMap = &sorted!([
     (